Android 在emulator上运行的应用程序上的java.lang.ClassNotFoundException
我的应用程序在emulator上运行良好,但在使用apk将应用程序安装到真实设备上后,我出现了此错误Android 在emulator上运行的应用程序上的java.lang.ClassNotFoundException,android,gradle,android-build,Android,Gradle,Android Build,我的应用程序在emulator上运行良好,但在使用apk将应用程序安装到真实设备上后,我出现了此错误 FATAL EXCEPTION: main Process: com.example.wiserlab.macquest, PID: 9151 java.lang.RuntimeException: Unable to get provider com.example.wiserlab.macquest.model.CustomContentProvider: java.lang.ClassNo
FATAL EXCEPTION: main
Process: com.example.wiserlab.macquest, PID: 9151
java.lang.RuntimeException: Unable to get provider com.example.wiserlab.macquest.model.CustomContentProvider: java.lang.ClassNotFoundException: Didn't find class "com.example.wiserlab.macquest.model.CustomContentProvider" on path: DexPathList[[zip file "/data/app/com.example.wiserlab.macquest-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.wiserlab.macquest-1, /vendor/lib, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:4777)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4369)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4309)
at android.app.ActivityThread.access$1500(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.wiserlab.macquest.model.CustomContentProvider" on path: DexPathList[[zip file "/data/app/com.example.wiserlab.macquest-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.wiserlab.macquest-1, /vendor/lib, /system/lib]]
我确信这个阶级是存在的。我应该把那个类导入其他地方吗
谢谢 如果您启用了proguard,那么您的代码可能会丢失,而崩溃是关于一些使用反射的功能,如Gson
检查仿真器中的生成类型是否与调试中的真实设备相同。此外,您还可以尝试在BuildType设置中设置useProguard false。通过删除build文件夹并重新生成来解决此问题