我一直试图建立Urban Airship几天,它真的让我很紧张。 由于他们的指示不明确,我必须按照this one进行操作。 但是,我目前正在收到此错误日志并试图查看是否可以找到一些帮助。 如有任何建议,将不胜感激!谢谢!
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)
我找到了类似的qnestion和答案,
- 从构建路径中删除所有Android库项目和外部jar。
在项目中创建名为“libs”的文件夹。
- 将所有外部.jars放在该文件夹中,ADT现在应将它们放在“Android Dependencies”下。
- 以正常方式重新导入所有以前的Android库项目。
但它对我不起作用。
这是Manifestfile,如果删除应用程序名称,应用程序运行正常。 但我需要这样才能启用推送通知..
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);
}
}
答案 0 :(得分:2)
如果在运行时获得NoClassDefFoundError
,那么我怀疑您没有将它们包含在运行时工作。您必须选中每个.jar的复选框,如下所示: