在 Eclipse 上创建 Android 模块化应用程序

发布于 2024-09-17 02:29:12 字数 889 浏览 3 评论 0 原文

我目前正在将一个用于在 J2ME 上构建应用程序的框架移植到 Android。该框架由多个编译为库(jar)的项目组成。每个单独的 JAR 都可以包含图形数据(资源、J4ME 屏幕等)。每个项目通常都有一个明确定义的入口点(模块)。当有人想要使用该框架构建应用程序时,他只需创建一个 Midlet 项目并添加库依赖项并使用导入的类。

我们一直使用相同的方法来开发 Android 框架。在本例中,我们仅使用 Eclipse 中的普通 Java 项目来编译为 jar 库。这些项目与 Android 框架 (android.jar) 具有依赖关系。构建新应用程序时,我们在 Eclipse 中创建一个 Android 项目并添加依赖项。

我们的下一步是为 Android 构建更高级的模块,这些模块还可以包含图形信息(活动、对话框、文字、可绘制对象等)。到目前为止,只需要一个 Android Eclipse 项目(最终应用程序),其中包含所有与图形相关的类和资源。似乎在使用资源(文字、可绘制对象等)时,唯一的方法是创建 Android 应用程序,因为资源只能通过 ADT 插件 (R.XXX) 自动创建的整数处理程序来引用。因此,构建图形模块可能无法通过普通的 Java jar 项目来构建。

Android开发者信息说明模块化应用程序是可行的,但我还没有找到解释该过程的简明教程,但有一些提示,例如如何防止 应用程序调用其他应用程序提供的意图。当构建使用其他应用程序资源的应用程序时,这是有效的。我不需要在系统上安装多个应用程序,而是需要由多个组件构建的应用程序。

有没有人有过类似需求的开发经验?有什么好的入门教程或技巧吗?

I am currently porting a framework for building applications on J2ME to Android. This framework consists of several projects that compile to libraries (jars). Each individual JAR can contain graphical data (resources, J4ME screens, etc.). Every project generally has a well defined entry point (module). When someone wants to build an application using the framework he must only create a Midlet project and add library dependencies and use the imported classes.

We have been using the same approach to develop the Android framework. In this case we have only used normal Java Projects inside Eclipse that compile to jar libraries. These projects have dependencies with the Android Framework (android.jar). When building a new application we create an Android Project inside Eclipse and add the dependencies.

Our next step is to build more advanced modules for Android that can also contain graphical information (Activities, Dialogs, Literals, Drawables, etc.). So far only an Android Eclipse project was needed (the end application), that contained all the graphical-related classes and resources. It seems that when using resources (literals, drawables, etc.) the only approach is to create an Android Application, since the resources are only referenceable by means of an integer handler automatically created by ADT plugin (R.XXX). So building graphical modules may not be built by means of plain Java jar projects.

Android developer information explains that modular applications are feasible, but I have not found a concise tutorial explaining the process, but some tips such as how to prevent an error to ocurr when an application invokes an intent made available by other application. This is valid when building applications that use resources from other applications. I do not need several installed applications on the system, but one built from several components.

Has anyone experience developing with similar requierements? Any good tutorial or tips to start out?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

破晓 2024-09-24 02:37:00

似乎唯一可用的方法此处描述为暗示的通过 另一个问题的接受答案

然而,该解决方案相当新(它仅适用于最新的 Android SDK R6,并且不支持 SDK 2.0.X)。它有一些主要的警告,我希望 Google 已经在解决这些警告:

  • 没有二进制库链接。这意味着主应用程序需要访问源代码(在 Eclipse 中意味着打开所有链接库项目)。
  • 资源名称(布局、绘图等)在全局范围内进行处理。这意味着如果您有两个“main.xml”布局,则只会使用最相关的(库列表中最上面的)布局。
  • 缺少功能/BUG。该文档规定,库项目的导出活动只能在库项目的 AndroidManifest.xml 中声明。这在当前版本中不起作用TicTacToe 示例中的注释暗示这是所需的工作,但对于当前版本的 Android Tools 使用的库项目活动必须在主应用程序项目的 AndroidManifest.xml 中显式定义。

It seems that the only available way is described here as hinted by the accepted answer of this other question.

The solution however is rather new (it only works with latest Android SDK tooks R6 and SDKs 2.0.X are left out of support). It has some major caveats on which I hope Google is already working:

  • No binary library linking. This means that the main application needs access to sources (in Eclipse implies having all the linked library projects open).
  • The names of resources (layouts, drawables, etc) are treated globally. This means that if you have two "main.xml" layouts, only the most relevant (uppermost in library list) will be used.
  • Missing funcionalities/BUGs. The documentation states that exported activities of a library project must only be declared in AndroidManifest.xml of library project. This does not work in current version. Comments inside TicTacToe example hints that this is the desired working, but for current release of Android Tools used activities from library projects must be explicitly defined in AndroidManifest.xml of main application project.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文