ADT r17 的 Jar 文件问题 [英] Jar-file issue with ADT r17

查看:19
本文介绍了ADT r17 的 Jar 文件问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从最新的 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的代码,很简单:

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);
    }
}

然后是清单:

<?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 的项目中都遇到了这个问题.我不明白有什么问题.还有其他人遇到这个问题吗?帮助将不胜感激.我没有遇到继承自 FragmentActivity 的 Activity 的问题.我已经卸载/重新安装了该应用程序.做过各种清洁工程".重新启动 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 文件链接的方式有关.要包含的罐子应该放在 libs/文件夹中,ADT 会自动链接它们.否则,它们将在 APK 中丢失,并在调用 jarfile 中的代码时使应用程序崩溃.

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.

这篇关于ADT r17 的 Jar 文件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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