生成单独的apk失败

时间:2020-02-27 02:16:03

标签: android build.gradle

当我更新到3.6时,当我./gradlew assembleRelease时会有例外。信息就是这样

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:minifyReleaseWithR8'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:166)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:163)
        at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:191)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:156)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
...

Caused by: java.lang.NullPointerException
  at com.android.tools.r8.naming.A.a(:7)
        at com.android.tools.r8.naming.A.c(:1)
        at com.android.tools.r8.naming.w.a(:71)
        at com.android.tools.r8.naming.w.a(:54)
        at com.android.tools.r8.naming.w.a(:61)
        at com.android.tools.r8.naming.w.a(:61)
        at com.android.tools.r8.naming.w.a(:29)
        at com.android.tools.r8.naming.G.a(:25)

...

我的项目gradle是

buildscript {
    ext.kotlin_version = '1.3.61'
    apply from:'config.gradle'
    repositories {
        google()
        jcenter()


    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

        classpath 'com.meituan.android.walle:plugin:1.1.6'
    }
}

allprojects {
    repositories {
        google()

        jcenter()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local/' }
        maven { url "https://jitpack.io" }
    }
}

我的应用gradle是

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'walle'



def dep = rootProject.ext.dependencies
def and = rootProject.ext.android

android {
    compileSdkVersion and.compileSdkVersion
    buildToolsVersion and.buildToolsVersion
    aaptOptions.cruncherEnabled = false

    aaptOptions.useNewCruncher = false
    defaultConfig {
        applicationId and.appid
        minSdkVersion and.minSdkVersion
        targetSdkVersion and.targetSdkVersion
        versionCode 215005
        versionName '3.0'
        multiDexEnabled true
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

        ndk {

            abiFilters 'armeabi' 
        }
        manifestPlaceholders = [
                JPUSH_PKGNAME :  ,
                JPUSH_APPKEY : ' ', 
                JPUSH_CHANNEL : ' ', 
        ]
    }
    signingConfigs {
        release {
            keyAlias ' '
            keyPassword ' '
            storeFile file('./release-key.keystore')
            storePassword '   '
            v1SigningEnabled true
            v2SigningEnabled true

        }

        debug {
            keyAlias '   '
            keyPassword ' '
            storeFile file('. ')
            storePassword ' '
        }
    }

    buildTypes {
        debug {
            debuggable true
            minifyEnabled false
            signingConfig signingConfigs.debug
            buildConfigField('boolean', 'ISRELEASE', '${IS_RELEASE}')
        }
        release {
            debuggable false
            minifyEnabled true
            shrinkResources true  
            zipAlignEnabled true
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            buildConfigField('boolean', 'ISRELEASE', '${IS_RELEASE}')
        }
    }
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']

        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
        encoding = 'UTF-8'
    }

    lintOptions {
        abortOnError false
    }
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

    implementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'


    implementation dep.eventbus
    implementation dep.immersionbar
    implementation dep.immersionbarfragment
    implementation dep.SmartRefreshLayout
//    implementation dep.networking
    implementation project(':android-networking')
//    implementation 'com.amitshekhar.android:jackson-android-networking:1.0.2'
    //glide
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
    implementation dep.glide
    implementation 'com.github.bumptech.glide:okhttp3-integration:4.9.0'
    implementation 'androidx.annotation:annotation:1.1.0'
    annotationProcessor 'androidx.annotation:annotation:1.1.0'

    implementation dep.rxjava2
    implementation dep.okhttp3
    implementation dep.rxandroid
    implementation dep.rxbinding2
    implementation project(':qmui')
    implementation project(':arch')
    implementation project(':emoji')
    implementation project(':reclib-qq')
    implementation 'com.facebook.stetho:stetho:1.1.1'
    //flowLayout
    implementation(project(':flowlayout-lib')) {
        transitive = true
        exclude group: 'androidx.appcompat', module: 'appcompat'
    }
    implementation dep.multidex
    implementation dep.banner
    implementation dep.toast

    implementation dep.brvah
    implementation dep.gson
    implementation dep.baseadapter
    //webview
    api dep.agentweb
    api 'com.just.agentweb:filechooser:4.1.2'//
    api 'com.download.library:Downloader:4.1.2'// 

    implementation dep.picker_view

    implementation dep.picker_picture

//    api dep.aliyun

    implementation 'com.amap.api:3dmap:7.0.0'

    implementation 'com.amap.api:location:4.7.2'

    implementation 'com.amap.api:search:6.9.2'
    /**kotlin*/
    implementation "androidx.core:core-ktx:1.1.0"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    //utils
    implementation 'com.blankj:utilcode:1.25.9'
    //tablayout//https://github.com/H07000223/FlycoTabLayout
    implementation 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar'
    //butter knife
    implementation "com.jakewharton:butterknife:$butterknifeVersion"
    annotationProcessor "com.jakewharton:butterknife-compiler:$butterknifeVersion"


//    api 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:5.5.7'
    api 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:5.3.1'


    implementation 'com.yanzhenjie.recyclerview:x:1.3.2'

    implementation 'com.kingja.loadsir:loadsir:1.3.6'
    /*lottie*/
    implementation('com.airbnb.android:lottie:3.2.0') { exclude group: 'com.androidx' }
    implementation 'cn.jiguang.sdk:jmessage:2.9.0'  // 
    implementation 'cn.jiguang.sdk:jcore:2.2.2'  // 
    implementation project(':reclib-testemoticons')
    implementation 'cn.jiguang.sdk:jpush:3.4.0'  // 


    implementation 'com.github.chrisbanes.photoview:library:1.2.4'
    implementation 'com.github.mtotschnig:StickyListHeaders:2.7.1'
    implementation 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'

    implementation 'com.yanzhenjie:permission:2.0.3'

    debugImplementation 'com.didichuxing.doraemonkit:doraemonkit:3.0_beta2'
    releaseImplementation 'com.didichuxing.doraemonkit:doraemonkit-no-op:3.0_beta2'
//    api project(path: ':LibEasyGlide')

    implementation 'com.binioter:guideview:1.0.0'

    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    //bugly

    implementation 'com.tencent.bugly:crashreport:3.1.7'

    implementation 'com.tencent.bugly:nativecrashreport:3.7.1'


    implementation 'com.meituan.android.walle:library:1.1.6'
    implementation "com.google.android.material:material:$materialVersion"

    api project(path: ':LibEasyGlide')

}

最底层是一些依赖项,它们都是常用库。当我的android studio是3.5.4时,它工作良好,但是当我更新到3.6时,它构建失败。我不知道这个问题

gradle.properties是

org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

1 个答案:

答案 0 :(得分:1)

如果您正在使用新的NDK,请尝试在 gradle.properties(项目属性)

中添加以下代码
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
android.enableD8=true
android.bundle.enableUncompressedNativeLibs=false