:无法实例化应用程序和ClassNotFound同时分享apk

当我从android工作室运行的应用程序,它在模拟器和设备运行良好。

但是当我分享apk的debugging/发布版本时,用户点击应用程序图标时就会崩溃。

跟踪我可以在日志中看到的错误

03-11 09:16:12.654 25384-25384/com.microtechnicianapp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.microtechnicianapp, PID: 25384 java.lang.RuntimeException: Unable to instantiate application com.microtechnicianapp.App: java.lang.ClassNotFoundException: Didn't find class "com.microtechnicianapp.App" on path: DexPathList[[zip file "/data/app/com.microtechnicianapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.microtechnicianapp-1/lib/x86, /vendor/lib, /system/lib]] at android.app.LoadedApk.makeApplication(LoadedApk.java:563) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4491) at android.app.ActivityThread.access$1500(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.microtechnicianapp.App" on path: DexPathList[[zip file "/data/app/com.microtechnicianapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.microtechnicianapp-1/lib/x86, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) at android.app.Instrumentation.newApplication(Instrumentation.java:979) at android.app.LoadedApk.makeApplication(LoadedApk.java:558) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4491) at android.app.ActivityThread.access$1500(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) Suppressed: java.lang.ClassNotFoundException: com.microtechnicianapp.App at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 13 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available 

已经阅读了很multithreading,但从早上起就没有任何作用。

在Gradle中尝试了很多东西

 apply plugin: 'com.android.application' apply plugin: 'com.neenbedankt.android-apt' apply plugin: 'realm-android' android { compileSdkVersion 25 buildToolsVersion '25.0.0' defaultConfig { applicationId "com.microtechnicianapp" minSdkVersion 19 targetSdkVersion 24 versionCode 1 versionName "1.2" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } debug { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } dexOptions { preDexLibraries false } } repositories { maven { url "http://dl.bintray.com/lukaville/maven" } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:design:25.0.0' compile 'com.squareup.retrofit2:retrofit:2.1.0' compile 'com.bluelinelabs:logansquare:1.3.6' compile 'com.github.aurae.retrofit2:converter-logansquare:1.4.1' compile 'org.greenrobot:eventbus:3.0.0' compile 'com.google.firebase:firebase-messaging:9.8.0' compile 'com.google.android.gms:play-services-maps:9.8.0' compile 'com.google.android.gms:play-services-location:9.8.0' compile 'com.github.gcacace:signature-pad:1.2.0' compile 'com.github.davidpizarro:autolabelui:1.0.1' compile 'com.nbsp:library:1.1' compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar' compile 'com.google.zxing:core:3.2.1' testCompile 'junit:junit:4.12' apt 'com.bluelinelabs:logansquare-compiler:1.3.6' compile 'com.google.android.gms:play-services-appindexing:9.8.0' compile 'com.mikhaellopez:circularprogressbar:1.1.1' compile 'com.android.support:multidex:1.0.0' } apply plugin: 'com.google.gms.google-services' 

我使用的是android studio 2.3因此gradle版本是gradle-3.3-all.zip

Solutions Collecting From Web of ":无法实例化应用程序和ClassNotFound同时分享apk"

我今天面临同样的问题,我目前已经降级我的gradle版本和生成的debuggingapk工作得很好,感觉像这可能是一个问题与gradle版本,将更新此答案,如果我发现与实际问题。

但目前将Gradle从2.3.0降级到2.2.0似乎解决了这个问题。

我有一个与我的应用程序之一的debuggingapk相同的崩溃。 发行版本(用发行版密钥签名)工作。 我的应用程序使用multidex。

我结束了在Android Studio中禁用即时运行(文件 – >设置 – >生成 – >即时运行),并重build后,debuggingapk工作以及!

在这里find这个解决scheme: https : //codentrick.com/cant-run-app-on-device-when-it-installed-from-debug-apk-file/