eclipse中多个依赖的Android项目 [英] multiple dependent android projects in eclipse

查看:137
本文介绍了eclipse中多个依赖的Android项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始玩android开发,java + eclipse对我来说是相当新鲜的。我设法创建简单的项目并在我的设备上运行它。现在我想创建简单的游戏(实际上更多的),我希望使用所有的共享代码库(游戏循环,初始化等)。



<问题是我不知道如何正确地做到这一点。我创建了一个名为engine的android项目,所有这些都是我需要的基本的东西,并使其在设备上工作。现在我试图在名为mygame的同一个工作区中创建另一个项目。 MyGame的主类(活动)是从继承自Activity的EngineApp(我的引擎项目的主要活动)继承的MyGameApp。



我将引擎项目添加到属性中mygame构建路径选项卡中的所需项目中。问题是,当我尝试运行这个项目时,它崩溃了ClassNotFoundException试图找到我的MyGameApp类。



非常感谢任何帮助(或指向某些文章的指针,说明如何完成)。几小时的谷歌搜索没有多少帮助:/

解决方案

你需要设置一个 Android 项目


Android 库项目是一个拥有共享的Android源代码和资源的开发项目。其他Android应用程序项目可以引用库项目,并在构建时将其编译源包含在其 .apk 文件中。多个应用程序项目可以引用同一个库项目,任何一个应用项目都可以引用多个库项目。


文档继续说明将现有项目转换为图书馆项目:


您还可以将现有的应用程序项目转换为库。为此,只需打开项目的属性并选择是库复选框。其他应用项目现在可以将现有项目作为图书馆项目参考。



I just started to play with android dev and java+eclipse is pretty new to me. I managed to create simple project and run it on my device. Now I want to create simple game (more of them actually) and I would love to use shared code base for all of them (game loop, initialization, etc..).

Problem is that I have no idea how to correctly do this. I created android project called engine with all basic stuff that I need and made it work on device. Now I tried to create another project in same workspace called mygame. Main class (activity) of mygame is MyGameApp which inherits from EngineApp (main activity of my engine project) which inherits from Activity.

I added engine project into required projects in mygame build path tab in properties. Problem is that when I try to run this project it crashes on ClassNotFoundException trying to find my MyGameApp class.

Any help (or pointer to some articles that explain how this is done) is greatly appreciated. few hours of googling didn't help much :/

解决方案

You need to set up an Android Library Project

An Android library project is a development project that holds shared Android source code and resources. Other Android application projects can reference the library project and, at build time, include its compiled sources in their .apk files. Multiple application projects can reference the same library project and any single application project can reference multiple library projects.

The docs go on to say how to convert an existing project to a library project:

You can also convert an existing application project into a library. To do so, simply open the Properties for the project and select the "is Library" checkbox. Other application projects can now reference the existing project as a library project.

这篇关于eclipse中多个依赖的Android项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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