I've been having an issue with starting my application recently. It was working fine a few weeks back but during that time I made a few changes including importing refractoring it(I added a bunch of packages but then reverted those changes), updating from the ADT from the android site (which still runs on Eclipse Juno) to eclipse Kepler (and I downloaded the ADT plugin) and I also imported it to my new laptop (also using Kepler). Now when I import the application using Import -> Existing Android Code Into Workspace I get an error message saying that "Could not set the project desciption from "(myappname)" because the project description file (.project) is out of sync with the file system.". If I ignore this message and continue, and run the application on my phone LogCat gives me an error message ClassNotFoundException on my main launcher activity.
I've looked around and tried to solve this problem by rebuilding the path (with android private libraries checked). That's the only relevant fix I've found but it doesn't work.
I should point out a few things that might or might not help:
-I tried to run an older version of the application and that works (after import and on Kepler even though it was written on the Juno Eclipse).
-My application imports the support package v7-compat (which worked before all the changes)
I've been stuck on this problem for a few days now and with no luck. Any and all help would be appreciated. Oh and if anyone needs more information to help me solve this just ask.
Edit:
Here is the error log:
01-27 19:22:59.603: E/AndroidRuntime(16471): FATAL EXCEPTION: main
01-27 19:22:59.603: E/AndroidRuntime(16471): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.Spit.pocketbook/com.Spit.pocketbook.SwipeActivity}: java.lang.ClassNotFoundException: com.Spit.pocketbook.SwipeActivity
01-27 19:22:59.603: E/AndroidRuntime(16471): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2034)
01-27 19:22:59.603: E/AndroidRuntime(16471): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
01-27 19:22:59.603: E/AndroidRuntime(16471): at android.app.ActivityThread.access$700(ActivityThread.java:143)
01-27 19:22:59.603: E/AndroidRuntime(16471): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
01-27 19:22:59.603: E/AndroidRuntime(16471): at android.os.Handler.dispatchMessage(Handler.java:99)
01-27 19:22:59.603: E/AndroidRuntime(16471): at android.os.Looper.loop(Looper.java:137)
01-27 19:22:59.603: E/AndroidRuntime(16471): at android.app.ActivityThread.main(ActivityThread.java:4950)
01-27 19:22:59.603: E/AndroidRuntime(16471): at java.lang.reflect.Method.invokeNative(Native Method)
01-27 19:22:59.603: E/AndroidRuntime(16471): at java.lang.reflect.Method.invoke(Method.java:511)
01-27 19:22:59.603: E/AndroidRuntime(16471): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
01-27 19:22:59.603: E/AndroidRuntime(16471): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
01-27 19:22:59.603: E/AndroidRuntime(16471): at dalvik.system.NativeStart.main(Native Method)
01-27 19:22:59.603: E/AndroidRuntime(16471): Caused by: java.lang.ClassNotFoundException: com.Spit.pocketbook.SwipeActivity
01-27 19:22:59.603: E/AndroidRuntime(16471): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
01-27 19:22:59.603: E/AndroidRuntime(16471): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
01-27 19:22:59.603: E/AndroidRuntime(16471): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
01-27 19:22:59.603: E/AndroidRuntime(16471): at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
01-27 19:22:59.603: E/AndroidRuntime(16471): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2025)
01-27 19:22:59.603: E/AndroidRuntime(16471): ... 11 more
Thanks ahead of time,
Spit
A class that was declared in manifest was not found in code.
Check that package and class names are the same in your manifest and code. Based on the stacktrace generated by data in your manifest, your code should have class SwipeActivity in package com.Spit.pocketbook. Note that class and package names are case sensitive. By convention, package names are all lowercase so the capital S in the package name looks suspicious.
Related
I'm part of a team developing several android applications for a combined system. The system contains administration tools, games and other kind of applications.
The users has requested that they from one application can access the settings of all apps in the system.
My initial idea was that each application could implement a settings fragment following a predefined interface which i then could load to show in my settings application.
I found this post, with a fairly new answer Use external application fragment/activity inside application, and this is how I thought this could be implemented.
I tried implementing the example given by #sandrstar by it gives me the following error
04-24 07:02:36.596 1715-1715/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
at dalvik.system.DexFile.defineClass(Native Method)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:211)
at dalvik.system.DexPathList.findClass(DexPathList.java:315)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:62)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at dk.giraf.launcher.test.mainapplication.MainActivity.onCreate(MainActivity.java:46)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5039)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Is what I am attemping even possible? Other suggestions for implementations are welcome.
I try to use LanguageTool library http://www.languagetool.org/java-api/ in my android app,
try
{
JLanguageTool langTool = new JLanguageTool(new Polish());
}
catch (IOException e) {}
but I'm getting an error. I added maven library using Modules-->Dependencies-->Add-->library -->from maven.
Everything works, when I test it as console application.
11-07 19:54:35.071: ERROR/AndroidRuntime(2982): FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at com.example.orto_test.MyActivity.onCreate(MyActivity.java:35)
at android.app.Activity.performCreate(Activity.java:5206)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
at android.app.ActivityThread.access$700(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at org.languagetool.JLanguageTool.getBuildDate(JLanguageTool.java:93)
at org.languagetool.JLanguageTool.<clinit>(JLanguageTool.java:77)
... 15 more
Thanks in advance!
According to http://languagetool-user-forum.2306527.n4.nabble.com/ClassDefNotFoundError-org-languagetool-language-AmericanEnglish-td4641443.html Languagtool 2.2 can be used on Android successfully. You might want to contact the languagetool-user-forum if you have trouble in getting things to work.
I am getting class not found exception on some android devices, it's happening only on some devices.
This is the call-stack i have got,
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.picframes.android/com.picframes.android.first}: java.lang.ClassNotFoundException: com.picframes.android.first
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2240)
at android.app.ActivityThread.access$600(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:4987)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.picframes.android.first
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1039)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
Any suggestions for resolving this problem, I could not reproduce this problem on my device.
On devices with which android version program works and where it doesn't work? I am not sure if this is the case but you probably get this error on older devices, is that right? You should make sure that all the functionality of your program is available on older systems. Use your manifest file:
<uses-sdk android:minSdkVersion="integer"
android:targetSdkVersion="integer"
android:maxSdkVersion="integer" />
to define minimum sdk version, and you will get errors in your code if you are trying to use features that are not available on the device that you target.
Android is throwing NoClassDefFoundError for ~1% of my users, no specific SDK version.
It's happening In my activity in the onCreate function when it try's to get an instance to a Singleton class i have in my project.
The singleton class it self doesn't reference any libs jar.
I tried on same devices it's heppening (e.g. SGH-T989) with no success.
Edit: adding the stack trace
at com.myapp.activities.RootActivity.getLoaderInstance(RootActivity.java:450)
at com.myapp.activities.RootActivity.doOnCreate(RootActivity.java:215)
at com.myapp.android.activities.AbstractActivity.onCreate(AbstractActivity.java:130)
at android.app.Activity.performCreate(Activity.java:5188)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
at android.app.ActivityThread.access$700(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4938)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
When I try to run my app on my Samsung Note II, I get a ResourceNotFoundException for this line
setContentView(R.layout.activity_main);
However, I don't get this exception when I run it on the emulator or my Samsung Note 10.1.
Both are running Jellybean and my xml files are in folder called layout-land, and the XML file is in there. I tried cleaning my project and re-building, but it still doesn't work.
Does anyone have an idea what's wrong?
Let me know if I can provide any more information. Thanks!
01-27 22:11:32.975: E/AndroidRuntime(28330): FATAL EXCEPTION: main
01-27 22:11:32.975: E/AndroidRuntime(28330): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ventusthecorgi.hungrycorgi/com.mypackage.app.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030003
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.app.ActivityThread.access$600(ActivityThread.java:140)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.os.Handler.dispatchMessage(Handler.java:99)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.os.Looper.loop(Looper.java:137)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.app.ActivityThread.main(ActivityThread.java:4898)
01-27 22:11:32.975: E/AndroidRuntime(28330): at java.lang.reflect.Method.invokeNative(Native Method)
01-27 22:11:32.975: E/AndroidRuntime(28330): at java.lang.reflect.Method.invoke(Method.java:511)
01-27 22:11:32.975: E/AndroidRuntime(28330): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
01-27 22:11:32.975: E/AndroidRuntime(28330): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
01-27 22:11:32.975: E/AndroidRuntime(28330): at dalvik.system.NativeStart.main(Native Method)
01-27 22:11:32.975: E/AndroidRuntime(28330): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030003
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.content.res.Resources.getValue(Resources.java:1026)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2131)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.content.res.Resources.getLayout(Resources.java:865)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
01-27 22:11:32.975: E/AndroidRuntime(28330): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:307)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.app.Activity.setContentView(Activity.java:1916)
01-27 22:11:32.975: E/AndroidRuntime(28330): at com.ventusthecorgi.hungrycorgi.MainActivity.onCreate(MainActivity.java:22)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.app.Activity.performCreate(Activity.java:5191)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
I suspect that you have your problematic layout files only in the layout-land directory (based on what you wrote in the question). This means that if the device is launched in portrait mode, Android will search for your layout in layout-port directory, then layout, but not layout-land. I might be wrong but my hunch is that your Samsung Note II starts in portrait mode and thus doesn't see the layout file.
You have to provide a fallback layout resource. Either copy the layout from layout-land to layout-port and modify it accordingly for portrait mode or just copy it to layout directory as a fallback layout.
AFAIK, Samsung Galaxy Note II 's default orientation is not in landscape
try putting a set of resource files in /res/layout for those devices which are not fit the specific layout characteristics
The xml files are in layout-land so they are only valid when the app/device is in landscape mode. Try moving/copying them to just layout and you should be fine. You may want to put a generic layout in the layout directory and a landscape optimized layout in layout-land (or look at other resource selection criteria).