在将Android Studio更新为2.3.1并且gradle to后,应用程序崩溃并出现ClassNotFoundException

时间:2017-04-16 14:46:16

标签: android android-gradle

我昨天将Android工作室更新为2.3.1并将gradle包装器更新为gradle-3.3-all。更新后,我的应用程序停止正常构建,并在设备中安装后继续崩溃。

Stacktrace是

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'

我尝试使用gradlew installMockDebug安装应用程序,但无法运行。 我禁用了其他帖子中提到的即时运行但没有帮助。任何想法如何解决它?

编辑: 我的build.gradle文件是:

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'

2 个答案:

答案 0 :(得分:1)

我最近遇到过这个问题。通过Android Studio安装时该应用程序运行正常。但是,当通过单击apk文件安装时(例如,当通过电子邮件共享apk时),应用程序启动时应用程序崩溃并出现ClassNotFoundException。

能够通过构建apk来解决这个问题, 构建>建立APK

enter image description here

答案 1 :(得分:0)

Chanage this file
gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip