1

几天来,我一直在尝试建立 Urban Airship,这真的让我很紧张。由于他们的指示不清楚,我不得不按照这个来完成。但是,我目前正在收到此错误日志并尝试查看是否可以找到一些帮助。请任何建议将不胜感激!谢谢!

10-18 12:41:10.585: E/AndroidRuntime(11870): FATAL EXCEPTION: main
10-18 12:41:10.585: E/AndroidRuntime(11870): java.lang.NoClassDefFoundError: com.urbanairship.UAirship
10-18 12:41:10.585: E/AndroidRuntime(11870):    at com.app.android.NotifyMeApplication.onCreate(NotifyMeApplication.java:15)
10-18 12:41:10.585: E/AndroidRuntime(11870):    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:973)
10-18 12:41:10.585: E/AndroidRuntime(11870):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3971)
10-18 12:41:10.585: E/AndroidRuntime(11870):    at android.app.ActivityThread.access$1300(ActivityThread.java:128)
10-18 12:41:10.585: E/AndroidRuntime(11870):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1199)
10-18 12:41:10.585: E/AndroidRuntime(11870):    at android.os.Handler.dispatchMessage(Handler.java:99)
10-18 12:41:10.585: E/AndroidRuntime(11870):    at android.os.Looper.loop(Looper.java:137)
10-18 12:41:10.585: E/AndroidRuntime(11870):    at android.app.ActivityThread.main(ActivityThread.java:4517)
10-18 12:41:10.585: E/AndroidRuntime(11870):    at java.lang.reflect.Method.invokeNative(Native Method)
10-18 12:41:10.585: E/AndroidRuntime(11870):    at java.lang.reflect.Method.invoke(Method.java:511)
10-18 12:41:10.585: E/AndroidRuntime(11870):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
10-18 12:41:10.585: E/AndroidRuntime(11870):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
10-18 12:41:10.585: E/AndroidRuntime(11870):    at dalvik.system.NativeStart.main(Native Method)

我找到了类似的问题和答案,

- 从构建路径中删除所有 Android 库项目和外部 jar。

- 在您的项目中创建一个名为“libs”的文件夹。

- 将所有外部 .jar 文件放在该文件夹中,ADT 现在应该将它们放在“Android 依赖项”下。

- 以正常方式重新导入所有以前的 Android 库项目。

但这对我不起作用。

这是清单文件,如果我删除应用程序名称,应用程序运行良好。但我需要它才能启用推送通知..

AndroidManifest.xml

<application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" 
        android:name="com.app.android.NotifyMeApplication"
        android:debuggable="true"
        android:allowClearUserData="true"
        android:enabled="true" >

NotifyMeApplication.java

package com.app.android;

import com.urbanairship.Logger;
import com.urbanairship.UAirship;
import com.urbanairship.push.PushManager;
import com.urbanairship.push.PushPreferences;

import android.app.Application;

public class NotifyMeApplication extends Application{

    @Override
    public void onCreate() {
        super.onCreate();
                UAirship.takeOff(this); // always needs to be called when starting an application

                // even though we call takeoff push notifications are disabled by default
                // you have to explicitly turn them on like so
                PushManager.enablePush();

                // let the push manager know about our intent receiver
                PushManager.shared().setIntentReceiver(IntentReceiver.class); 
                // name must match broadcast receiver from step 7

                // set some preferences for sounds and vibration
                PushPreferences prefs = PushManager.shared().getPreferences();
                prefs.setSoundEnabled(true);
                prefs.setVibrateEnabled(true);

                // apid is a unique identifier for a particular device
                String lPushId = prefs.getPushId();
                Logger.info("My Application onCreate - App APID: " + lPushId);

    }
}
4

1 回答 1

2

如果您NoClassDefFoundError在运行时获得,那么我怀疑您没有将它们包括在运行时工作。您必须像这样检查每个 .jar 的复选框:

在此处输入图像描述

于 2012-10-18T22:38:38.100 回答