Android发布apk proguard问题

时间:2018-05-22 07:23:24

标签: android gradle proguard android-proguard

我已经将我的Android工作室从3.0.1更新到3.1.2,将我的Gradle版本从4.1升级到4.4 除非发布已签名的APK,否则每次都会发现,我总是遇到同样的问题

任务执行失败':app:transformClassesAndResourcesWithProguardForRelease'。

我的Gradle是

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.3'

    defaultConfig {
        applicationId 'com.***.***'
        minSdkVersion 16
        targetSdkVersion 26 
        versionCode 3
        versionName "3.5.07.180521"
        multiDexEnabled true
        resValue("string", "PORT_NUMBER", "15711")
    }
    aaptOptions {
        additionalParameters "--no-version-vectors"
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            android.applicationVariants.all { variant ->
                variant.outputs.all {
                    outputFileName = "qs_${variant.versionName}.apk"
                }
            }
        }

    }

    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
    productFlavors {
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/ASL2.0'
        exclude 'classes.dex'
    }
}

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

    implementation'com.google.firebase:firebase-messaging:11.8.0'
    implementation'com.google.firebase:firebase-appindexing:11.8.0'
    implementation'com.google.firebase:firebase-core:11.8.0'
    implementation'com.android.support:multidex:1.0.0'
    implementation'com.android.support.constraint:constraint-layout:1.0.2'
    implementation project(path: ':quayosolution')
}


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

生成签名APK期间的我的日志文件可以找到HERE,但日志的结尾是

Warning: there were 779 unresolved references to classes or interfaces.
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning: there were 68 instances of library classes depending on program classes.
         You must avoid such dependencies, since the program classes will
         be processed, while the library classes will remain unchanged.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#dependency)
Warning: there were 6 unresolved references to program class members.
         Your input classes appear to be inconsistent.
         You may need to recompile the code.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
Warning: there were 2 unresolved references to library class members.
         You probably need to update the library versions.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
:app:transformClassesAndResourcesWithProguardForRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> Job failed, see logs for details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 7s
40 actionable tasks: 2 executed, 38 up-to-date

我尝试添加

  

-dontwarn   我的proguard-rules.pro但没有改变。

注意:我可以在将minifyEnabled设置为false时生成APK,但APK尺寸大于预期。

0 个答案:

没有答案