在Eclipse上创建Android模块化应用程序 [英] Creating Android Modular Applications on Eclipse

查看:135
本文介绍了在Eclipse上创建Android模块化应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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



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



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



有没有人经历过类似的请求开发工作?任何好的教程或提示开始?

解决方案

似乎唯一可用的方法是描述 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.

这篇关于在Eclipse上创建Android模块化应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆