如何使用一个简单的Java项目的Andr​​oid库开发(不使用的Dalvik等等) [英] How to develop using android libraries in a simple java project (without using dalvik and such)

查看:159
本文介绍了如何使用一个简单的Java项目的Andr​​oid库开发(不使用的Dalvik等等)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我非常厌烦使用模拟器来开发任何Java类,我认为建立在Eclipse项目和而不是通常的JRE我联系到的android.jar(2.1版本),通常在Android项目连接至。我不打算用这个来开发布局或其他特定平台的事情,我只是想创建一个使用HttpClient的一类。它悲惨地崩溃这样。

As I am very pissed off of using the emulator to develop any Java class, I thought of setting up a project in Eclipse and instead of the usual JRE I linked to the Android.jar (version 2.1) that usually the Android projects link to. I don't mean to use this to develop Layouts or other specific platform things, I was just trying to create a class that uses HttpClient. It miserably crashes like this.

在线程异常主要   java.lang.RuntimeException的:存根!在   org.apache.http.impl.client.AbstractHttpClient(AbstractHttpClient.java:5)     在   org.apache.http.impl.client.DefaultHttpClient(DefaultHttpClient.java:7)     在   AdsCatcher(AdsCatcher.java:26)     在TestAll.main(TestAll.java:10)

Exception in thread "main" java.lang.RuntimeException: Stub! at org.apache.http.impl.client.AbstractHttpClient.(AbstractHttpClient.java:5) at org.apache.http.impl.client.DefaultHttpClient.(DefaultHttpClient.java:7) at AdsCatcher.(AdsCatcher.java:26) at TestAll.main(TestAll.java:10)

存根!我的意思是我想开发库(并对其进行测试),所以,当我去到模拟器我没有对付它们。有没有好的办法做到这一点?这似乎不工作由于某种原因。

Stub! I mean I'd like to develop libraries (and test them) so that when I go to the emulator I don't have to deal with them. Is there a good way to do this? This seems not to work for some reason.

推荐答案

这是行不通的,对不起。该的android.jar 文件,作为错误信息表明,仅包含存根了Android的API。这是有道理的,因为该API不能安卓以外的工作 - 对的android.jar 文件只是有编译

This will not work, sorry. The android.jar file, as the error message indicates, contains only stubs of the Android API. This makes sense, since that API cannot work outside of Android -- the android.jar file is just there for compilation.

有关您正在使用的有在Android不依赖类库,欢迎您来创建一个标准的JRE Eclipse项目生成JAR,你再在你的Andr​​oid项目中使用。

For class libraries you are working on that have no dependencies on Android, you are welcome to create a standard JRE Eclipse project that generates a JAR that you then use in your Android project.

在你的情况,你的可以的能够创建使用,它使用HttpClient的JRE的类库。最新版本的Apache可以从Android的版本略有不同,虽然如此,而也许的,你会没事,还有你会遇到运行时错误是由于方法签名和这样的变化(一定几率的VerifyError )。

In your case, you may be able to create a class library using the JRE that uses HttpClient. The latest version from Apache may differ slightly from the version in Android, though, so while probably you will be OK, there's a chance you will run into runtime errors due to changes in method signatures and such (VerifyError).

这篇关于如何使用一个简单的Java项目的Andr​​oid库开发(不使用的Dalvik等等)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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