NoClassDefFoundError:生成APK

时间:2019-06-19 22:52:20

标签: compilation androidx r8

将我的应用程序迁移到android x and gradle 5 我发送生成apk或进行安装的那一刻给了我这个错误

原因:java.lang.NoClassDefFoundError:com / android / tools / r8 / dex / ApplicationReader

Build.graddle

 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' }

    google()
}


android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    defaultConfig {
        vectorDrawables.useSupportLibrary = true
        applicationId "gortiz.com.goapp"
        minSdkVersion 18
        targetSdkVersion 28
        versionCode 37
        versionName '2.0.37'
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}




dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')


    implementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
        transitive = true;
    }
    implementation 'androidx.appcompat:appcompat:1.+'

    implementation 'androidx.vectordrawable:vectordrawable-animated:1.+'


    implementation 'androidx.mediarouter:mediarouter:1.+'

    implementation 'androidx.core:core:1.+'


    implementation 'androidx.multidex:multidex:2.+'
    implementation 'com.google.android.material:material:1.+'
    implementation 'commons-io:commons-io:2.5'
    implementation 'androidx.constraintlayout:constraintlayout:1.+'
    implementation 'androidx.legacy:legacy-support-v4:1.+'
    implementation 'com.google.code.gson:gson:2.8.1'
    implementation 'com.github.satyan:sugar:1.5'
    implementation 'com.squareup.picasso:picasso:2.5.0'

    implementation 'me.panavtec:wizard:1.2'
    implementation 'com.github.johnkil.print:print:1.2.+'
    implementation 'com.github.bmelnychuk:atv:1.2.+'

    implementation 'androidx.legacy:legacy-support-v13:1.0.0'

     testImplementation 'junit:junit:4.12'
    implementation 'androidx.recyclerview:recyclerview:1.+'


    implementation ('com.google.firebase:firebase-messaging:17.3.4'){
        exclude group: 'com.google.firebase', module: 'firebase-iid'
    }
    implementation 'com.google.android.gms:play-services-maps:17.+'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    implementation 'com.google.android.gms:play-services-analytics:16.0.7'
    implementation 'com.google.android.gms:play-services-places:16.0.0'
    implementation 'com.google.android.gms:play-services-gcm:16.0.0'
    implementation 'com.google.android.gms:play-services-base:16.1.0'
    implementation 'com.google.firebase:firebase-core:16.0.7'
    implementation 'com.google.android.gms:play-services-vision:18.+'
    implementation 'com.google.firebase:firebase-config:18.+'
    implementation 'com.google.firebase:firebase-iid:17.0.2'
    implementation 'androidx.annotation:annotation:1.1.0'





}



apply plugin: 'com.google.gms.google-services'

graddle.properties

org.gradle.jvmargs=-Xmx1536m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.useAndroidX=true
android.enableJetifier=true

原因:java.lang.NoClassDefFoundError:com / android / tools / r8 / dex / ApplicationReader

1 个答案:

答案 0 :(得分:0)

顶级build.gradle似乎缺少对Android Gradle插件的依赖。请添加以下内容(具体取决于您要使用的版本):

buildscript {
    ...
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
        ...
    }
    ...
}

如果您在Android Studio中创建了一个空项目,应该将其全部放置到位。