将Android Studio更新至2.3.1并升级至之后,应用程序崩溃,并显示ClassNotFoundException [英] App crashes with ClassNotFoundException after updating Android Studio to 2.3.1 and gradle to

查看:73
本文介绍了将Android Studio更新至2.3.1并升级至之后,应用程序崩溃,并显示ClassNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我昨天将Android Studio更新为2.3.1,并将gradle包装器更新为gradle-3.3-all.更新后,我的应用程序停止正确构建,并在设备上安装后继续崩溃.

I updated Android studio yesterday to 2.3.1 and gradle wrapper to gradle-3.3-all. After updating my app stopped building properly and keep crashing after installing in device.

Stacktrace是

Stacktrace is

04-16 19:37:19.436 ? E/DynamiteModule: Failed to load module descriptor class: Didn't find class "com.google.android.gms.dynamite.descriptors.com.google.firebase.auth.ModuleDescriptor" on path: DexPathList[[zip file "/data/app/tk.swapnilUtilities.myApp-1.apk"],nativeLibraryDirectories=[/data/app-lib/tk.swapnilUtilities.myApp-1, /vendor/lib, /system/lib]]
04-16 19:37:23.620 ? E/CrashlyticsCore: Failed to execute task.
                                        java.util.concurrent.TimeoutException
                                            at java.util.concurrent.FutureTask.get(FutureTask.java:173)
                                            at com.crashlytics.android.core.CrashlyticsBackgroundWorker.submitAndWait(CrashlyticsBackgroundWorker.java:41)
                                            at com.crashlytics.android.core.CrashlyticsController.handleUncaughtException(CrashlyticsController.java:285)
                                            at com.crashlytics.android.core.CrashlyticsController$5.onUncaughtException(CrashlyticsController.java:269)
                                            at com.crashlytics.android.core.CrashlyticsUncaughtExceptionHandler.uncaughtException(CrashlyticsUncaughtExceptionHandler.java:30)
                                            at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
                                            at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
                                            at dalvik.system.NativeStart.main(Native Method)
04-16 19:37:23.622 ? E/AndroidRuntime: FATAL EXCEPTION: main
                                       java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{tk.swapnilUtilities.myApp/tk.swapnilUtilities.myApp.ui.ScrMainActivity}: java.lang.ClassNotFoundException: Didn't find class "tk.swapnilUtilities.myApp.ui.ScrMainActivity" on path: DexPathList[[zip file "/data/app/tk.swapnilUtilities.myApp-1.apk"],nativeLibraryDirectories=[/data/app-lib/tk.swapnilUtilities.myApp-1, /vendor/lib, /system/lib]]
                                           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
                                           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395)
                                           at android.app.ActivityThread.access$600(ActivityThread.java:162)
                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
                                           at android.os.Handler.dispatchMessage(Handler.java:107)
                                           at android.os.Looper.loop(Looper.java:194)
                                           at android.app.ActivityThread.main(ActivityThread.java:5371)
                                           at java.lang.reflect.Method.invokeNative(Native Method)
                                           at java.lang.reflect.Method.invoke(Method.java:525)
                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
                                           at dalvik.system.NativeStart.main(Native Method)
                                        Caused by: java.lang.ClassNotFoundException: Didn't find class "tk.swapnilUtilities.myApp.ui.ScrMainActivity" on path: DexPathList[[zip file "/data/app/tk.swapnilUtilities.myApp-1.apk"],nativeLibraryDirectories=[/data/app-lib/tk.swapnilUtilities.myApp-1, /vendor/lib, /system/lib]]
                                           at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
                                           at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
                                           at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
                                           at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
                                           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2260)
                                           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395) 
                                           at android.app.ActivityThread.access$600(ActivityThread.java:162) 
                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364) 
                                           at android.os.Handler.dispatchMessage(Handler.java:107) 
                                           at android.os.Looper.loop(Looper.java:194) 
                                           at android.app.ActivityThread.main(ActivityThread.java:5371) 
                                           at java.lang.reflect.Method.invokeNative(Native Method) 
                                           at java.lang.reflect.Method.invoke(Method.java:525) 
                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 
                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
                                           at dalvik.system.NativeStart.main(Native Method) 

我正在使用kotlin版本"1.1.1","com.android.tools.build:gradle:2.3.1"、com.google.gms:google-services:3.0.0"、compileSdkVersionValue = 25, buildToolsVersionValue = '25 .0.2'

I am using kotlin version '1.1.1', 'com.android.tools.build:gradle:2.3.1', 'com.google.gms:google-services:3.0.0', compileSdkVersionValue = 25, buildToolsVersionValue = '25.0.2'

我尝试使用gradlew installMockDebug安装应用程序,但无法运行. 我禁用了其他文章中提到的即时运行,但没有帮助.有任何解决方法的想法吗?

I tried installing the app using gradlew installMockDebug but it fails to run. I disabled instant run as mentioned in other posts but no help. Any ideas how to fix it?

我的build.gradle文件是:

My build.gradle file is:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

apply plugin: 'kotlin-android'

android {
    compileSdkVersion rootProject.ext.compileSdkVersionValue
    buildToolsVersion rootProject.ext.buildToolsVersionValue

    defaultConfig {
        applicationId "tk.swapnilUtilities"
        minSdkVersion 14
        targetSdkVersion rootProject.ext.compileSdkVersionValue
        versionCode 1
        versionName "0.0.1"

        // Enabling multidex support.
        multiDexEnabled true
        resConfigs "en", "hi"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        /*jackOptions {
            enabled true
        }*/
    }

    buildTypes {
        debug {
            testCoverageEnabled = true
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    productFlavors {
        mock {
        }
        api {

        }
    }

    dataBinding {
        enabled true
    }

    useLibrary 'org.apache.http.legacy'

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'LICENSE.txt'
    }
    /*compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }*/
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile('org.apache.httpcomponents:httpmime:4.3') {
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }
    compile('org.apache.httpcomponents:httpcore:4.4.1') {
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }
    compile rootProject.ext.recyclerview
    compile 'com.github.zhaokaiqiang.klog:library:1.1.0'
    compile 'com.google.code.gson:gson:2.4'
    compile 'commons-io:commons-io:1.3.2'
    compile 'com.android.support.test.espresso:espresso-idling-resource:2.2.2'

    //Testing
    testCompile('junit:junit:4.12', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'org.mockito:mockito-core:1.10.19'
    // Android runner and rules support
    androidTestCompile('com.android.support.test:runner:0.5', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    androidTestCompile 'com.android.support.test:rules:0.5'
    // Espresso support
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    // add this for intent mocking support
    androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2'
    androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.0') {
        exclude group: 'com.android.support', module: 'appcompat'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude module: 'recyclerview-v7'
    }
    testCompile 'org.mockito:mockito-all:1.10.19'
    testCompile 'org.powermock:powermock-api-mockito:1.6.2'
    // Firebase Authentication
    compile 'com.google.firebase:firebase-auth:9.0.2'
    compile 'com.google.firebase:firebase-database:9.0.2'
    compile 'com.firebaseui:firebase-ui-database:0.4.1'
    compile 'com.google.firebase:firebase-storage:9.0.2'
    //RX
    //compile 'io.reactivex:rxjava:1.0.+'
    //compile 'io.reactivex:rxandroid:0.23.+'
    //compile 'io.reactivex.rxjava2:rxjava:2.0.7'
    /*compile 'io.reactivex.rxjava2:rxandroid:2.0.1'*/
    compile rootProject.ext.rxJava
    compile rootProject.ext.rxAndroid
    // Google Sign In SDK (only required for Google Sign In)
    compile 'com.google.android.gms:play-services-auth:9.0.2'
    //Kotlin
    compile "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
    //compile 'com.firebaseui:firebase-ui-storage:0.6.0'
    //compile 'com.firebaseui:firebase-ui-storage:1.0.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile project(':pickphotos')
    compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
        transitive = true;
    }
}
configurations.all {
    resolutionStrategy.force rootProject.ext.annotations
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android-extensions'

推荐答案

我最近遇到了这个问题.通过Android Studio安装时,该应用正常运行.但是,如果通过单击apk文件进行安装(例如,通过电子邮件共享apk时),则应用程序在启动时会因ClassNotFoundException而崩溃.

I recently faced this issue. The app was working fine when installed via Android Studio. However, when installed by clicking on the apk file (for instance, when the apk is shared via email), the app crashes with ClassNotFoundException on app launch.

能够通过使用以下方式构建apk来解决此问题, 生成>生成APK

Was able to resolve this by building the apk using, Build > Build APK

这篇关于将Android Studio更新至2.3.1并升级至之后,应用程序崩溃,并显示ClassNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆