任务 ':app:transformClassesAndResourcesWithProguardForRelease' 的执行失败:java.io.IOException - Proguard



尝试使用Proguard时一直在努力找出问题背后的原因(请参阅下面的堆栈跟踪)。

除了gradle文件中提到的库外,该应用程序还处理打开socketsserializing/deserializing数据,ciphersjwt tokens,处理WifiManagerWifiP2pManager

如果有人能帮助指出这个问题,或者至少帮助我更好地深入研究这个问题,那就太好了。我尝试为不同的库添加所有可能的 proguard 规则,并且不缩小我们自己的父包。

我的成绩文件

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'
apply plugin: 'com.google.gms.google-services'
repositories {
    maven { url 'https://maven.fabric.io/public' }
}    
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true;
    }
    compile project(':android')
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
    compile 'com.google.code.gson:gson:2.4'
    compile 'commons-codec:commons-codec:1.9'
    compile 'com.android.support:design:23.1.1'
    compile 'com.google.android.gms:play-services-analytics:8.3.0'
    compile 'com.android.support:support-v4:23.1.1'
}
android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    defaultConfig {
        applicationId "com.some.org.package"
        minSdkVersion 18
        targetSdkVersion 23
        versionCode 5
        versionName "0.9.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
}

Proguard-rules.pro

Proguard 文件链接

./gradlew clean assembleRelease -d --stacktrace

https://jsfiddle.net/w7htgrxd/3

构建日志明确提及构建失败的原因。有各种对缺少类的引用,错误的配置,尽管正在使用但未保留的属性,....

我建议您查看引用的手册页并应用建议的更改,其中大多数是-keepattributes ....-dontwarn ...

如果您无法解决所有警告,您最终还可以添加-ignorewarnings以忽略其余警告,并让 ProGuard 继续处理您的申请。

相关内容

最新更新