0

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

引起:java.lang.NoClassDefFoundError: com/android/tools/r8/dex/ApplicationReader

构建.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

4

1 回答 1

0

顶层build.gradle似乎缺少对 Android Gradle 插件的依赖。请添加类似这样的内容(取决于您要使用的版本):

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

如果您在 Android Studio 中创建一个空项目,则该项目应该全部到位。

于 2019-06-21T05:07:20.097 回答