This question already has an answer here:
Joda Time in Eclipse: NoClassDefFoundError
(1 answer)
Closed 9 years ago.
I want to get the current date and time by means of DateTime Class ,I have download Joda from http://sourceforge.net/projects/joda-time/files/joda-time/
and I added three jar files which are in the extracted folder to java build path of my project properties.and my code is like the following code:
import org.joda.time.DateTime;
public class TappedNFC extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tapped_nfc);
Button BeamButton=(Button)findViewById(R.id.BeamButton);
BeamButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
DateTime dt = new DateTime();
int month = dt.getMonthOfYear();
TextView tx=(TextView)findViewById(R.id.textView1);
tx.setText(Integer.toString(month));
}
});
}
but the logcat gets exception:
03-04 14:57:18.309: E/AndroidRuntime(540): FATAL EXCEPTION: main
03-04 14:57:18.309: E/AndroidRuntime(540): java.lang.NoClassDefFoundError: org.joda.time.DateTime
03-04 14:57:18.309: E/AndroidRuntime(540): at com.example.tappednfc.TappedNFC$1.onClick(TappedNFC.java:28)
03-04 14:57:18.309: E/AndroidRuntime(540): at android.view.View.performClick(View.java:3460)
03-04 14:57:18.309: E/AndroidRuntime(540): at android.view.View$PerformClick.run(View.java:13955)
03-04 14:57:18.309: E/AndroidRuntime(540): at android.os.Handler.handleCallback(Handler.java:605)
03-04 14:57:18.309: E/AndroidRuntime(540): at android.os.Handler.dispatchMessage(Handler.java:92)
03-04 14:57:18.309: E/AndroidRuntime(540): at android.os.Looper.loop(Looper.java:137)
03-04 14:57:18.309: E/AndroidRuntime(540): at android.app.ActivityThread.main(ActivityThread.java:4340)
03-04 14:57:18.309: E/AndroidRuntime(540): at java.lang.reflect.Method.invokeNative(Native Method)
03-04 14:57:18.309: E/AndroidRuntime(540): at java.lang.reflect.Method.invoke(Method.java:511)
03-04 14:57:18.309: E/AndroidRuntime(540): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-04 14:57:18.309: E/AndroidRuntime(540): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-04 14:57:18.309: E/AndroidRuntime(540): at dalvik.system.NativeStart.main(Native Method)
I haven't used Joda before,So please help me to solve this problem.
Thanks a lot.
When you say you added them to your build path did you use the normal (but incorrect for Android) route of "Properties" > "Java Build Path" > "Add External Jars" ? The correct way to bundle external jars in your Android project is to create a "libs" (note the plural) directory and directly paste them under the directory.
A project build will then show your dependent jars under "Android Dependencies" and they will be bundled correctly into the APK. If you don't follow that route then the external jars are not added and you'll see the sorts of exceptions you noted.
Related
I am having issues with my PhoneGap application that has Urban Airship push notifications running. Everything works fine except when closing the app using Android's native task killer (swiping the app off). When the phone is left idle for 30 seconds to a minute I get the error, "Unfortunately, [app] has stopped". I was viewing LogCat and when this error occured I got these errors:
03-04 10:16:30.420: E/EmbeddedLogger(595): App crashed! Process: com.appname.pacakagename
03-04 10:16:30.420: E/EmbeddedLogger(595): App crashed! Package: com.appname.pacakagename v1 (1.1.2)
03-04 10:16:30.420: E/AndroidRuntime(10257): FATAL EXCEPTION: main
03-04 10:16:30.420: E/AndroidRuntime(10257): java.lang.ExceptionInInitializerError
03-04 10:16:30.420: E/AndroidRuntime(10257): at java.lang.Class.newInstanceImpl(Native Method)
03-04 10:16:30.420: E/AndroidRuntime(10257): at java.lang.Class.newInstance(Class.java:1130)
03-04 10:16:30.420: E/AndroidRuntime(10257): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2909)
03-04 10:16:30.420: E/AndroidRuntime(10257): at android.app.ActivityThread.access$1600(ActivityThread.java:162)
03-04 10:16:30.420: E/AndroidRuntime(10257): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1504)
03-04 10:16:30.420: E/AndroidRuntime(10257): at android.os.Handler.dispatchMessage(Handler.java:99)
03-04 10:16:30.420: E/AndroidRuntime(10257): at android.os.Looper.loop(Looper.java:158)
03-04 10:16:30.420: E/AndroidRuntime(10257): at android.app.ActivityThread.main(ActivityThread.java:5789)
03-04 10:16:30.420: E/AndroidRuntime(10257): at java.lang.reflect.Method.invokeNative(Native Method)
03-04 10:16:30.420: E/AndroidRuntime(10257): at java.lang.reflect.Method.invoke(Method.java:525)
03-04 10:16:30.420: E/AndroidRuntime(10257): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
03-04 10:16:30.420: E/AndroidRuntime(10257): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:843)
03-04 10:16:30.420: E/AndroidRuntime(10257): at dalvik.system.NativeStart.main(Native Method)
03-04 10:16:30.420: E/AndroidRuntime(10257): Caused by: java.lang.NullPointerException
03-04 10:16:30.420: E/AndroidRuntime(10257): at com.urbanairship.Preferences.migratePreferencesFromFileToDb(Preferences.java:173)
03-04 10:16:30.420: E/AndroidRuntime(10257): at com.urbanairship.analytics.AnalyticsPreferences.<init>(AnalyticsPreferences.java:32)
03-04 10:16:30.420: E/AndroidRuntime(10257): at com.urbanairship.analytics.EventService.<clinit>(EventService.java:58)
03-04 10:16:30.420: E/AndroidRuntime(10257): ... 13 more
03-04 10:16:30.430: W/asset(595): Copying FileAsset 0x7860b3b0 (zip:/data/app/com.appname.pacakagename-2.apk:/resources.arsc) to buffer size 200924 to make it aligned.
03-04 10:16:30.430: E/EmbeddedLogger(595): Application Label: appname
So from this I can see these lines:
03-04 10:16:30.420: E/AndroidRuntime(10257): Caused by: java.lang.NullPointerException
03-04 10:16:30.420: E/AndroidRuntime(10257): at com.urbanairship.Preferences.migratePreferencesFromFileToDb(Preferences.java:173)
I wasn't sure where to look to debug that error, I ran this:
find ./ -type f -name *Preferences*
But I couldn't find any file called Preferences.java.
The plugin this is referring to is:
https://github.com/urbanairship/phonegap-ua-push
The Android src is here:
https://github.com/urbanairship/phonegap-ua-push/tree/master/src/android
This was solved by upgrading to the latest version of the Urban Airship plugin and my version of PhoneGap.
I have created a custom dialog layout. When invoked, the dialog pops up fine. But when I try to set the content inside the dialog using the two lines commented below, it throws an illegal state exception.
private void showCustomDialog(String content){
final Dialog d = new Dialog(this);
d.setContentView(R.layout.spread_info_popup);
d.show();
// TextView contentTv = (TextView) findViewById(R.id.my_dialog_content);
// contentTv.setText(content);
}
What is wrong here ?
Do i need to inflate the layout spread_info_popup before referring to TextView within it with an id of my_dialog_content ?
the Stacktrace:
03-04 15:03:54.690: E/AndroidRuntime(4194): FATAL EXCEPTION: main
03-04 15:03:54.690: E/AndroidRuntime(4194): java.lang.IllegalStateException: Could not execute method of the activity
03-04 15:03:54.690: E/AndroidRuntime(4194): at android.view.View$1.onClick(View.java:3591)
03-04 15:03:54.690: E/AndroidRuntime(4194): at android.view.View.performClick(View.java:4084)
03-04 15:03:54.690: E/AndroidRuntime(4194): at android.view.View$PerformClick.run(View.java:16966)
03-04 15:03:54.690: E/AndroidRuntime(4194): at android.os.Handler.handleCallback(Handler.java:615)
03-04 15:03:54.690: E/AndroidRuntime(4194): at android.os.Handler.dispatchMessage(Handler.java:92)
03-04 15:03:54.690: E/AndroidRuntime(4194): at android.os.Looper.loop(Looper.java:137)
03-04 15:03:54.690: E/AndroidRuntime(4194): at android.app.ActivityThread.main(ActivityThread.java:4745)
03-04 15:03:54.690: E/AndroidRuntime(4194): at java.lang.reflect.Method.invokeNative(Native Method)
03-04 15:03:54.690: E/AndroidRuntime(4194): at java.lang.reflect.Method.invoke(Method.java:511)
03-04 15:03:54.690: E/AndroidRuntime(4194): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
03-04 15:03:54.690: E/AndroidRuntime(4194): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-04 15:03:54.690: E/AndroidRuntime(4194): at dalvik.system.NativeStart.main(Native Method)
03-04 15:03:54.690: E/AndroidRuntime(4194): Caused by: java.lang.reflect.InvocationTargetException
03-04 15:03:54.690: E/AndroidRuntime(4194): at java.lang.reflect.Method.invokeNative(Native Method)
03-04 15:03:54.690: E/AndroidRuntime(4194): at java.lang.reflect.Method.invoke(Method.java:511)
03-04 15:03:54.690: E/AndroidRuntime(4194): at android.view.View$1.onClick(View.java:3586)
03-04 15:03:54.690: E/AndroidRuntime(4194): ... 11 more
03-04 15:03:54.690: E/AndroidRuntime(4194): Caused by: java.lang.NullPointerException
03-04 15:03:54.690: E/AndroidRuntime(4194): at com.me.reader.ui.activity.CompleteList.showSpreadInfoPopup(CompleteList.java:122)
03-04 15:03:54.690: E/AndroidRuntime(4194): at com.me.reader.ui.activity.CompleteList.setSpreadDescriptionfromXML(CompleteList.java:104)
03-04 15:03:54.690: E/AndroidRuntime(4194): at com.me.reader.ui.activity.CompleteList.onAboutIconClicked(CompleteList.java:81)
03-04 15:03:54.690: E/AndroidRuntime(4194): ... 14 more
you should look for the view inside the Dialog:
TextView contentTv = (TextView) dialog.findViewById(R.id.my_dialog_content);
contentTv.setText(content);
here the documentation.
im new to android and i have a prob in ksoap2 jar . im getting the following exception while running the program and the program closes with error- unfortunately the app stopped. im using ksoap2-android-assembly-2.5.8-jar-with-dependencies for the jars and i have included it both in the build path lib and also in /lib folder but still the problem persists.
im using the .zip file i dont kno how to convert it to jar ... is this the prob. please help , thanks in advance .
03-04 06:24:38.337: E/AndroidRuntime(790): FATAL EXCEPTION: main
03-04 06:24:38.337: E/AndroidRuntime(790): java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject
03-04 06:24:38.337: E/AndroidRuntime(790): at com.android.example.ksoap2demo.MainActivity.onCreate(MainActivity.java:27)
03-04 06:24:38.337: E/AndroidRuntime(790): at android.app.Activity.performCreate(Activity.java:5104)
03-04 06:24:38.337: E/AndroidRuntime(790): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
03-04 06:24:38.337: E/AndroidRuntime(790): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
03-04 06:24:38.337: E/AndroidRuntime(790): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-04 06:24:38.337: E/AndroidRuntime(790): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-04 06:24:38.337: E/AndroidRuntime(790): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-04 06:24:38.337: E/AndroidRuntime(790): at android.os.Handler.dispatchMessage(Handler.java:99)
03-04 06:24:38.337: E/AndroidRuntime(790): at android.os.Looper.loop(Looper.java:137)
03-04 06:24:38.337: E/AndroidRuntime(790): at android.app.ActivityThread.main(ActivityThread.java:5041)
03-04 06:24:38.337: E/AndroidRuntime(790): at java.lang.reflect.Method.invokeNative(Native Method)
03-04 06:24:38.337: E/AndroidRuntime(790): at java.lang.reflect.Method.invoke(Method.java:511)
03-04 06:24:38.337: E/AndroidRuntime(790): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-04 06:24:38.337: E/AndroidRuntime(790): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-04 06:24:38.337: E/AndroidRuntime(790): at dalvik.system.NativeStart.main(Native Method)
First problem which i can for see is rename the folder to libs instead of lib. and if you unzip the .zip file you will probably get the jar file and that jar file you need to put in the libs folder and add in the build path. that will resolve the problem.
Turns out external jars such as
ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar
to be put under /libs folder so Eclipse ADT automatically adds your jars to the buildpath of your application. It was a buildpath missing defined class error after all.. I hope this will help you, too!
Has anyone tried to run Apache Felix on Android 4.1 oder 4.2 ?
To me, it look as if something has been changed on the android classloader and now it no longer works.
i start apache felix programmatically as follow:
config.put("felix.bootdelegation.implicit", "false");
config.put("felix.service.urlhandlers","false");
...
felix.start();
my bundle is also "dexed" !
I'm getting this error:
03-04 23:38:51.360: W/System.err(1431): org.osgi.framework.BundleException: Activator start error in bundle org.apache.felix.shell.remote [25].
...
03-04 23:38:51.360: W/System.err(1431): at dalvik.system.NativeStart.main(Native Method)
03-04 23:38:51.360: W/System.err(1431): Caused by: java.lang.UnsupportedOperationException: can't load this type of class file
03-04 23:38:51.360: W/System.err(1431): at java.lang.VMClassLoader.defineClass(Native Method)
03-04 23:38:51.360: W/System.err(1431): at java.lang.ClassLoader.defineClass(ClassLoader.java:292)
03-04 23:38:51.360: W/System.err(1431): at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.findClass(BundleWiringImpl.java:2128)
03-04 23:38:51.360: W/System.err(1431): at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1432)
03-04 23:38:51.360: W/System.err(1431): at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)
03-04 23:38:51.360: W/System.err(1431): at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
03-04 23:38:51.360: W/System.err(1431): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-04 23:38:51.360: W/System.err(1431): at org.apache.felix.framework.BundleWiringImpl.getClassByDelegation(BundleWiringImpl.java:1317)
03-04 23:38:51.360: W/System.err(1431): at org.apache.felix.framework.Felix.createBundleActivator(Felix.java:4170)
03-04 23:38:51.360: W/System.err(1431): at org.apache.felix.framework.Felix.activateBundle(Felix.java:1972)
03-04 23:38:51.360: W/System.err(1431): ... 15 more
Can somebody confirm that ?
Is their a solution ?
Maybe their is a property that has to be change in apache felix ?!?!
I've added a new comment to the bug report system: https://issues.apache.org/jira/browse/FELIX-3854?focusedCommentId=13594757&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13594757
I'm creating a gps app for the android! And now I've stumbled upon a problem. The app doesn't start at all... Any ideas of how to fix this?
04-05 12:54:50.877: D/dalvikvm(540): Not late-enabling CheckJNI (already on)
04-05 12:54:51.018: I/dalvikvm(540): Turning on JNI app bug workarounds for target SDK version 5...
04-05 12:54:51.417: I/dalvikvm(540): Could not find method org.acra.ACRA.init, referenced from method com.kulplex.gaia.GaiaApp.onCreate
04-05 12:54:51.417: W/dalvikvm(540): VFY: unable to resolve static method 652: Lorg/acra/ACRA;.init (Landroid/app/Application;)V
04-05 12:54:51.417: D/dalvikvm(540): VFY: replacing opcode 0x71 at 0x0000
04-05 12:54:51.457: D/AndroidRuntime(540): Shutting down VM
04-05 12:54:51.457: W/dalvikvm(540): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
04-05 12:54:51.477: E/AndroidRuntime(540): FATAL EXCEPTION: main
04-05 12:54:51.477: E/AndroidRuntime(540): java.lang.NoClassDefFoundError: org.acra.ACRA
04-05 12:54:51.477: E/AndroidRuntime(540): at com.kulplex.gaia.GaiaApp.onCreate(GaiaApp.java:54)
04-05 12:54:51.477: E/AndroidRuntime(540): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969)
04-05 12:54:51.477: E/AndroidRuntime(540): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3954)
04-05 12:54:51.477: E/AndroidRuntime(540): at android.app.ActivityThread.access$1300(ActivityThread.java:123)
04-05 12:54:51.477: E/AndroidRuntime(540): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185)
04-05 12:54:51.477: E/AndroidRuntime(540): at android.os.Handler.dispatchMessage(Handler.java:99)
04-05 12:54:51.477: E/AndroidRuntime(540): at android.os.Looper.loop(Looper.java:137)
04-05 12:54:51.477: E/AndroidRuntime(540): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-05 12:54:51.477: E/AndroidRuntime(540): at java.lang.reflect.Method.invokeNative(Native Method)
04-05 12:54:51.477: E/AndroidRuntime(540): at java.lang.reflect.Method.invoke(Method.java:511)
04-05 12:54:51.477: E/AndroidRuntime(540): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-05 12:54:51.477: E/AndroidRuntime(540): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-05 12:54:51.477: E/AndroidRuntime(540): at dalvik.system.NativeStart.main(Native Method)
I had this same issue after updating to the latest Android tools.
In the project properties, Java Build Path, Order and Export section, I had to make sure the Android Private Libraries was checked.
Then I had to clean the project. After that it seems to work.
It was indeed an issue with 'Order and Export' of the Java Build Path.
When upgrading, the 'Order and Export' of the new 'Android Private Libraries' is not always checked. And the android-support-v4.jar is now in this 'Android Private Libraries' section.
To fix this, go to 'Order and Export' and check 'Android Private Libraries'. Then refresh/clean/rebuild.
After you done this 'fix' for a library project, you may need to just close and re-open any depending project, because they may not see this 'fix' immediately.
I found the answer here.
If you've recently updated to ADT 17 and above, they've changed the lib library handling.
so you need to rename your lib dir to libs,
then right click your project > properties > Java build path > Libraries > select all the jars with error markings on them and click remove > click add JARs > select all jars from your new libs dir.
Hope this helps.