The error "caused by: java.lang.ClassNotFoundException:"

During the Android vogella tutorial regarding sqlite, I ran into an annoying problem with the following error:

09-05 09:18:06.127: E/AndroidRuntime(981): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.de.vogella.android.todos.contentprovider.MyTodoContentProvider" on path: DexPathList[[zip file "/data/app/com.example.de.vogella.android.todos-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.de.vogella.android.todos-1, /system/lib]] 

I have performed a phased change of all files many times to correctly recreate the R. class. The very strange thing about this case is that I have no idea why com.example.de.vogella.android has anything about com.example. Is this some kind of standard generated name? All my packages / names / paths never started with "com.example" (in this project). I checked all the files and could not find the problem.

More output from LogCat:

 09-05 09:18:06.127: E/AndroidRuntime(981): FATAL EXCEPTION: main 09-05 09:18:06.127: E/AndroidRuntime(981): java.lang.RuntimeException: Unable to get provider com.example.de.vogella.android.todos.contentprovider.MyTodoContentProvider: java.lang.ClassNotFoundException: Didn't find class "com.example.de.vogella.android.todos.contentprovider.MyTodoContentProvider" on path: DexPathList[[zip file "/data/app/com.example.de.vogella.android.todos-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.de.vogella.android.todos-1, /system/lib]] 09-05 09:18:06.127: E/AndroidRuntime(981): at android.app.ActivityThread.installProvider(ActivityThread.java:4882) 09-05 09:18:06.127: E/AndroidRuntime(981): at android.app.ActivityThread.installContentProviders(ActivityThread.java:4485) 09-05 09:18:06.127: E/AndroidRuntime(981): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4425) 09-05 09:18:06.127: E/AndroidRuntime(981): at android.app.ActivityThread.access$1300(ActivityThread.java:141) 09-05 09:18:06.127: E/AndroidRuntime(981): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) 09-05 09:18:06.127: E/AndroidRuntime(981): at android.os.Handler.dispatchMessage(Handler.java:99) 09-05 09:18:06.127: E/AndroidRuntime(981): at android.os.Looper.loop(Looper.java:137) 09-05 09:18:06.127: E/AndroidRuntime(981): at android.app.ActivityThread.main(ActivityThread.java:5103) 09-05 09:18:06.127: E/AndroidRuntime(981): at java.lang.reflect.Method.invokeNative(Native Method) 09-05 09:18:06.127: E/AndroidRuntime(981): at java.lang.reflect.Method.invoke(Method.java:525) 09-05 09:18:06.127: E/AndroidRuntime(981): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 09-05 09:18:06.127: E/AndroidRuntime(981): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 09-05 09:18:06.127: E/AndroidRuntime(981): at dalvik.system.NativeStart.main(Native Method) 09-05 09:18:06.127: E/AndroidRuntime(981): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.de.vogella.android.todos.contentprovider.MyTodoContentProvider" on path: DexPathList[[zip file "/data/app/com.example.de.vogella.android.todos-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.de.vogella.android.todos-1, /system/lib]] 09-05 09:18:06.127: E/AndroidRuntime(981): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53) 09-05 09:18:06.127: E/AndroidRuntime(981): at java.lang.ClassLoader.loadClass(ClassLoader.java:501) 09-05 09:18:06.127: E/AndroidRuntime(981): at java.lang.ClassLoader.loadClass(ClassLoader.java:461) 09-05 09:18:06.127: E/AndroidRuntime(981): at android.app.ActivityThread.installProvider(ActivityThread.java:4867) 09-05 09:18:06.127: E/AndroidRuntime(981): ... 12 more 09-05 09:18:06.156: E/ActivityThread(950): Failed to find provider info for de.vogella.android.todos.contentprovider 

In the general application, it starts, but from the very beginning it fails with the output:

 Unfortunatelly, {AppName} has stopped. 

My AndroidManifest.xml looks like this

 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="de.vogella.android.todos" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="13" android:targetSdkVersion="18" /> <application android:allowBackup="true" android:icon="@drawable/reminder" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".TodosOverviewActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".TodoDetailActivity" android:windowSoftInputMode="stateVisible|adjustResize" android:label="@string/title_activity_todo_detail" > </activity> <provider android:name=".contentprovider.MyTodoContentProvider" android:authorities="de.vogella.android.todos.contentproviderxxxxxxx" > </provider> </application> </manifest> 

I just started with android, so I see that something trivial is missing.

Thank you very much.

CHANGE Changing <provider> to:

 <provider android:name=".contentprovider.MyTodoContentProvider" android:authorities="de.vogella.android.todos.contentprovider" > </provider> 

leads to:

 Installation error: INSTALL_FAILED_CONFLICTING_PROVIDER Please check logcat output for more details. Launch canceled! 

with LogCat:

 09-06 02:02:38.198: E/AndroidRuntime(864): FATAL EXCEPTION: main 09-06 02:02:38.198: E/AndroidRuntime(864): java.lang.RuntimeException: Unable to get provider com.example.de.vogella.android.todos.contentprovider.MyTodoContentProvider: java.lang.ClassNotFoundException: Didn't find class "com.example.de.vogella.android.todos.contentprovider.MyTodoContentProvider" on path: DexPathList[[zip file "/data/app/com.example.de.vogella.android.todos-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.de.vogella.android.todos-1, /system/lib]] 09-06 02:02:38.198: E/AndroidRuntime(864): at android.app.ActivityThread.installProvider(ActivityThread.java:4882) 09-06 02:02:38.198: E/AndroidRuntime(864): at android.app.ActivityThread.installContentProviders(ActivityThread.java:4485) 09-06 02:02:38.198: E/AndroidRuntime(864): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4425) 09-06 02:02:38.198: E/AndroidRuntime(864): at android.app.ActivityThread.access$1300(ActivityThread.java:141) 09-06 02:02:38.198: E/AndroidRuntime(864): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) 09-06 02:02:38.198: E/AndroidRuntime(864): at android.os.Handler.dispatchMessage(Handler.java:99) 09-06 02:02:38.198: E/AndroidRuntime(864): at android.os.Looper.loop(Looper.java:137) 09-06 02:02:38.198: E/AndroidRuntime(864): at android.app.ActivityThread.main(ActivityThread.java:5103) 09-06 02:02:38.198: E/AndroidRuntime(864): at java.lang.reflect.Method.invokeNative(Native Method) 09-06 02:02:38.198: E/AndroidRuntime(864): at java.lang.reflect.Method.invoke(Method.java:525) 09-06 02:02:38.198: E/AndroidRuntime(864): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 09-06 02:02:38.198: E/AndroidRuntime(864): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 09-06 02:02:38.198: E/AndroidRuntime(864): at dalvik.system.NativeStart.main(Native Method) 09-06 02:02:38.198: E/AndroidRuntime(864): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.de.vogella.android.todos.contentprovider.MyTodoContentProvider" on path: DexPathList[[zip file "/data/app/com.example.de.vogella.android.todos-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.de.vogella.android.todos-1, /system/lib]] 09-06 02:02:38.198: E/AndroidRuntime(864): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53) 09-06 02:02:38.198: E/AndroidRuntime(864): at java.lang.ClassLoader.loadClass(ClassLoader.java:501) 09-06 02:02:38.198: E/AndroidRuntime(864): at java.lang.ClassLoader.loadClass(ClassLoader.java:461) 09-06 02:02:38.198: E/AndroidRuntime(864): at android.app.ActivityThread.installProvider(ActivityThread.java:4867) 09-06 02:02:38.198: E/AndroidRuntime(864): ... 12 more 09-06 02:02:38.236: E/ActivityThread(834): Failed to find provider info for de.vogella.android.todos.contentprovider 
+3
java android android-emulator
Sep 05 '13 at 13:45
source share
4 answers

I had this problem once. The code worked earlier, and suddenly it stopped working (crashing when the application started) when I synchronized and built an older version of the code.

The fix was to simply close and restart Eclipse, clean up the project, and clear all the dependent library projects. Then he began to work correctly again.

This is some kind of build problem in Eclipse when updating project files.

Update. In particular, if you accidentally modify the ".classpath" file (to revert to an older version), the Eclipse / Android SDK may get confused and not build the project properly. When you restart Eclipse and clean up the project, Eclipse will re-modify the ".classpath" file and build correctly.

+10
Dec 06 '13 at
source share

Change this line in your code:

 <provider android:name="de.vogella.android.todos.contentprovider.MyTodoContentProvider" android:authorities="de.vogella.android.todos.contentproviderxxxxxxx" > </provider> 


Your problem will be resolved.

+1
Sep 05 '13 at 13:54 on
source share

Remember to declare the content provider in your manifest.

+1
Sep 05 '13 at 13:54 on
source share

No com.example is a standard package name, it is created in accordance with the AndroidManifest.xml file, which is located in the root of the project.

There is an attribute in the manifest file called a package, which gives the application a unique name.

Please check the manifest file and, as far as I know, correct the package attribute as

 <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="de.vogella.android.todos" 
0
Sep 05 '13 at 13:55 on
source share



All Articles