当使用带有 minifyEnabled true 的 proguard 时,我在 assembleRelease 期间收到警告,并且我的应用程序没有加载我使用 glide 进行加载的大多数图像。
在调试版本中,如果我设置 minifyEnabled false 一切正常。你能帮忙吗?
构建.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.xxxxxx"
minSdkVersion 16
targetSdkVersion 23
versionCode 17
versionName "1.20151021"
}
allprojects {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}
android.applicationVariants.all { variant ->
def appName
//Check if an applicationName property is supplied; if not use the name of the parent project.
if (project.hasProperty("applicationName")) {
appName = applicationName
} else {
appName = parent.name
}
variant.outputs.each { output ->
def newApkName
//If there's no ZipAlign task it means that our artifact will be unaligned and we need to mark it as such.
if (output.zipAlign) {
newApkName = "${appName}-${output.baseName}-${variant.versionName}.apk"
} else {
newApkName = "${appName}-${output.baseName}-${variant.versionName}-unaligned.apk"
}
output.outputFile = new File(output.outputFile.parent, newApkName)
}
}
signingConfigs {
free {
storeFile file('xxxxxx')
storePassword "$System.env.KEYSTORE_PASSWORD"
keyAlias "xxxxx"
keyPassword "$System.env.KEYSTORE_PASSWORD"
}
pro {
storeFile file('xxxx')
storePassword "$System.env.KEYSTORE_PASSWORD"
keyAlias "xxxxxx"
keyPassword "$System.env.KEYSTORE_PASSWORD"
}
}
buildTypes {
release {
// signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
free {
applicationId "com.xxxxxx"
buildConfigField 'Boolean', 'IS_APP_PRO', 'false'
signingConfig signingConfigs.free
}
pro {
applicationId "com.xxxxxxx"
buildConfigField 'Boolean', 'IS_APP_PRO', 'true'
signingConfig signingConfigs.pro
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.google.android.gms:play-services-ads:8.1.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.android.support:support-v4:23.0.1'
}
proguard-rules.pro
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
assembleRelease 期间的警告:
Executing tasks: [assembleRelease]
Configuration on demand is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preFreeReleaseBuild UP-TO-DATE
:app:checkFreeReleaseManifest
:app:preFreeDebugBuild UP-TO-DATE
:app:preProDebugBuild UP-TO-DATE
:app:preProReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportCardviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds810Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing810Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBasement810Library UP-TO-DATE
:app:prepareFreeReleaseDependencies
:app:compileFreeReleaseAidl UP-TO-DATE
:app:compileFreeReleaseRenderscript UP-TO-DATE
:app:generateFreeReleaseBuildConfig UP-TO-DATE
:app:generateFreeReleaseAssets UP-TO-DATE
:app:mergeFreeReleaseAssets UP-TO-DATE
:app:generateFreeReleaseResValues UP-TO-DATE
:app:generateFreeReleaseResources UP-TO-DATE
:app:mergeFreeReleaseResources UP-TO-DATE
:app:processFreeReleaseManifest UP-TO-DATE
:app:processFreeReleaseResources
:app:generateFreeReleaseSources
:app:processFreeReleaseJavaRes UP-TO-DATE
:app:compileFreeReleaseJavaWithJavac UP-TO-DATE
:app:compileFreeReleaseNdk UP-TO-DATE
:app:compileFreeReleaseSources UP-TO-DATE
:app:lintVitalFreeRelease
Unexpected failure during lint analysis of ArticlesRecyclerViewAdapter.java (this is a bug in lint or one of the libraries it depends on)
TypeSystem.getUnannotatedType(TypeSystem.java:180)->TypeSystem.getParameterizedType(TypeSystem.java:238)->TypeSystem.getParameterizedType(TypeSystem.java:261)->LookupEnvironment.createParameterizedType(LookupEnvironment.java:949)
Unexpected failure during lint analysis of CategoriesRecyclerViewAdapter.java (this is a bug in lint or one of the libraries it depends on)
TypeSystem.getUnannotatedType(TypeSystem.java:180)->TypeSystem.getParameterizedType(TypeSystem.java:238)->TypeSystem.getParameterizedType(TypeSystem.java:261)->LookupEnvironment.createParameterizedType(LookupEnvironment.java:949)
Unexpected failure during lint analysis of ArticleDetailActivity.java (this is a bug in lint or one of the libraries it depends on)
TypeSystem.getUnannotatedType(TypeSystem.java:180)->TypeSystem.getParameterizedType(TypeSystem.java:238)->TypeSystem.getParameterizedType(TypeSystem.java:261)->LookupEnvironment.createParameterizedType(LookupEnvironment.java:949)
Unexpected failure during lint analysis of SplashActivity.java (this is a bug in lint or one of the libraries it depends on)
TypeSystem.getUnannotatedType(TypeSystem.java:180)->TypeSystem.getParameterizedType(TypeSystem.java:238)->TypeSystem.getParameterizedType(TypeSystem.java:261)->LookupEnvironment.createParameterizedType(LookupEnvironment.java:949)
:app:proguardFreeRelease
Note: there were 7 duplicate class definitions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
:app:dexFreeRelease
:app:shrinkFreeReleaseResources
Removed unused resources: Binary resource data reduced from 16682KB to 3190KB: Removed 80%
Note: If necessary, you can disable resource shrinking by adding
android {
buildTypes {
release {
shrinkResources false
}
}
}
:app:validateFreeSigning
:app:packageFreeRelease
:app:zipalignFreeRelease
:app:assembleFreeRelease
:app:checkProReleaseManifest
:app:prepareProReleaseDependencies
:app:compileProReleaseAidl UP-TO-DATE
:app:compileProReleaseRenderscript UP-TO-DATE
:app:generateProReleaseBuildConfig UP-TO-DATE
:app:generateProReleaseAssets UP-TO-DATE
:app:mergeProReleaseAssets UP-TO-DATE
:app:generateProReleaseResValues UP-TO-DATE
:app:generateProReleaseResources UP-TO-DATE
:app:mergeProReleaseResources UP-TO-DATE
:app:processProReleaseManifest UP-TO-DATE
:app:processProReleaseResources UP-TO-DATE
:app:generateProReleaseSources UP-TO-DATE
:app:processProReleaseJavaRes UP-TO-DATE
:app:compileProReleaseJavaWithJavac UP-TO-DATE
:app:compileProReleaseNdk UP-TO-DATE
:app:compileProReleaseSources UP-TO-DATE
:app:lintVitalProRelease
Unexpected failure during lint analysis of ArticlesRecyclerViewAdapter.java (this is a bug in lint or one of the libraries it depends on)
TypeSystem.getUnannotatedType(TypeSystem.java:180)->TypeSystem.getParameterizedType(TypeSystem.java:238)->TypeSystem.getParameterizedType(TypeSystem.java:261)->LookupEnvironment.createParameterizedType(LookupEnvironment.java:949)
Unexpected failure during lint analysis of CategoriesRecyclerViewAdapter.java (this is a bug in lint or one of the libraries it depends on)
TypeSystem.getUnannotatedType(TypeSystem.java:180)->TypeSystem.getParameterizedType(TypeSystem.java:238)->TypeSystem.getParameterizedType(TypeSystem.java:261)->LookupEnvironment.createParameterizedType(LookupEnvironment.java:949)
Unexpected failure during lint analysis of ArticleDetailActivity.java (this is a bug in lint or one of the libraries it depends on)
TypeSystem.getUnannotatedType(TypeSystem.java:180)->TypeSystem.getParameterizedType(TypeSystem.java:238)->TypeSystem.getParameterizedType(TypeSystem.java:261)->LookupEnvironment.createParameterizedType(LookupEnvironment.java:949)
Unexpected failure during lint analysis of SplashActivity.java (this is a bug in lint or one of the libraries it depends on)
TypeSystem.getUnannotatedType(TypeSystem.java:180)->TypeSystem.getParameterizedType(TypeSystem.java:238)->TypeSystem.getParameterizedType(TypeSystem.java:261)->LookupEnvironment.createParameterizedType(LookupEnvironment.java:949)
:app:proguardProRelease
Note: there were 7 duplicate class definitions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
:app:dexProRelease
:app:shrinkProReleaseResources
Removed unused resources: Binary resource data reduced from 16682KB to 3190KB: Removed 80%
:app:validateProSigning
:app:packageProRelease
:app:zipalignProRelease
:app:assembleProRelease
:app:assembleRelease
BUILD SUCCESSFUL
Total time: 29.188 secs