且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2022-10-17 21:01:12

似乎唯一可用的方法是描述 here 这个其他问题的可接受的答案



然而,解决方案是相当新的与最新的Android SDK搭配使用R6和SDK 2.0.X不支持)。它有一些重要的警告,我希望Google已经在工作:




  • 没有二进制库链接。这意味着主要应用程序需要访问源(在Eclipse中意味着所有链接的库项目都打开)。

  • 资源(布局,可绘图等)的名称被处理全局即可。这意味着如果您有两个main.xml布局,则只会使用最相关(库列表中最上方)。

  • 缺少功能/ BUG 。该文档规定,库项目的导出活动必须在库项目的AndroidManifest.xml中声明。这个在当前版本中不起作用。 TicTacToe 示例中的评论提示这是所需的工作,但是必须在主应用程序项目的AndroidManifest.xml中明确定义当前版本的Android Tools使用的库项目活动。


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?

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.