I've been trying to set up Urban Airship for days and it really stress me out. Since their instruction isn't clear, I had to follow this one to work through. However, I'm currently getting this errorLogs and trying to see if I can find some help. Please any advice would be greatly appreciated! Thank you!
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)
I found a similar qnestion and answers,
-Remove all Android Library projects and external jars from the build path.
-Create a folder named 'libs' in your project.
-Place all external .jars in that folder, the ADT should now place them under 'Android Dependencies'.
-Re-import all your previous Android Library projects the normal way.
but it doesn't work for me.
This is Manifestfile, and the application runs fine if i remove the application name. But I need that in order to enable the push notification..
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);
}
}
If you get
NoClassDefFoundError
during Runtime, then I suspect you did not include them to work at runtime. You have to check the checkbox for each .jar like this: