JAR文件问题ADT R17 [英] Jar-file issue with ADT r17
问题描述
我似乎有自最新的ADT更新一个棘手的问题,释放17。
I seem to have a tricky problem since the latest ADT update to release 17.
我做了一个简单的应用程序来说明我的问题,我不知道如果我做错什么。我的应用程序的主要活动是从FragmentActivity继承的支持包,不管怎样,应用程序崩溃时启动。
I have made a simple application to illustrate my problem, I don't know if I'm doing anything wrong. The main Activity of my application is inheriting from FragmentActivity in the support package and somehow the application crashes at launch.
要说明这一点,我做了一个样本项目。
To illustrate, I made a sample project.
首先,这里是我哑类,DummyProjectActivity的code,很简单的:
First of all, here is the code of my dummy class, DummyProjectActivity, very simple:
public class DummyProjectActivity extends FragmentActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
然后,有清单:
Then, there is the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="be.emich.labs"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".DummyProjectActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
.jar文件导入正确的项目,我得到这个堆栈跟踪:
The .jar file is imported correctly in the project and I am getting this stack trace:
E/AndroidRuntime(11509): FATAL EXCEPTION: main
E/AndroidRuntime(11509): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{be.emich.labs/be.emich.labs.DummyProjectActivity}: java.lang.ClassNotFoundException: be.emich.labs.DummyProjectActivity
E/AndroidRuntime(11509): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1879)
E/AndroidRuntime(11509): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
E/AndroidRuntime(11509): at android.app.ActivityThread.access$600(ActivityThread.java:122)
E/AndroidRuntime(11509): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
E/AndroidRuntime(11509): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(11509): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(11509): at android.app.ActivityThread.main(ActivityThread.java:4340)
E/AndroidRuntime(11509): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(11509): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(11509): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime(11509): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime(11509): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(11509): Caused by: java.lang.ClassNotFoundException: be.emich.labs.DummyProjectActivity
E/AndroidRuntime(11509): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
E/AndroidRuntime(11509): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E/AndroidRuntime(11509): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/AndroidRuntime(11509): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
E/AndroidRuntime(11509): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
E/AndroidRuntime(11509): ... 11 more
我在做什么错在这里?难道这是在最新的开发工具中的错误?
What am I doing wrong here? Could this be a bug in the latest dev tools?
我遇到了在使用FragmentActivity从兼容性库每一个项目的问题。我不明白什么可能是错误的。任何人有这个问题?帮助将不胜AP preciated。我没有用一个活动,继承FragmentActivity问题。我已经卸载/重新安装应用程序。完成各种清洁工程。重启动Eclipse的。
I am encountering the problem in every project that uses FragmentActivity from the compatibility library. I don't get what could be wrong. Anyone else having this problem? Help would be greatly appreciated. I'm not having the problem with an Activity that inherits from FragmentActivity. I have uninstalled/reinstalled the application. Done various "clean project". Restarted Eclipse.
更新:这个问题显然没有连接到兼容包,但方式ADT R17处理的jar文件链接。罐子被列入应被放入库/文件夹,ADT会自动将它们链接。否则,他们将丢失从APK,使应用程序崩溃时从jar文件的code被调用。
UPDATE: The issue is apparently not linked to the compatibility package but the way ADT r17 handles linking of jar files. Jars to be included should be put into the libs/ folder and ADT will link them automatically. Otherwise they will be missing from the APK and make the app crash whenever the code from the jarfile is invoked.
推荐答案
直到最新版本的工具右键点击>在我的项目添加兼容包并没有工作,我包括手动通过项目属性的jar文件。我试图添加兼容包一次,因为R17看来这是固定我的机器。这解决了问题。
Until the latest release tools right click > Add compatibility package on my project wasn't working and I included the jar file manually through the project properties. I tried "Add compatibility package" again and since r17 it seems this is fixed for my machine. This fixed the problem.
这篇关于JAR文件问题ADT R17的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!