我已經成功地開發建設過程中我的應用程序的調試版本雖然伴隨着以下警告的Android的build.gradle:使用支持庫未按建設
"W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable.
當我做了fullRelease構建我遇到以下錯誤:
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForFullRelease'.
> java.io.IOException: Can't write [/PATH_TO_APP/app/build/intermediates/transforms/proguard/full/release/jar s/3/1f/main.jar] (Can't read [/PATH_TO_APP/app/build/intermediates/exploded- aar/com.android.support/support- fragment/24.2.1/jars/classes.jar(;;;;;;**.class)] (Duplicate zip entry [android/support/v4/app/r.class == classes.jar:android/support/v4/app/Fragment$1.class]))
爲了在Android 6.0+中使用AppCompat權限,我加入了支持庫。以下是我的build.gradle文件。
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '24.0.3'
useLibrary 'org.apache.http.legacy'
ext {
supportLibVersion = '24.2.1'
}
lintOptions {
abortOnError false
}
defaultConfig {
applicationId "com.whatever.appname"
testApplicationId 'com.whatever.appname'
versionCode 8
minSdkVersion 9
targetSdkVersion 24
}
buildTypes {
debug {
debuggable true
minifyEnabled false
signingConfig signingConfigs.debug
}
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFile 'PATH_TO_PROGUARD/proguard-project.txt'
}
}
signingConfigs {
release {
keyPassword 'PASSWORD'
storePassword 'PASSWORD'
keyAlias 'ALIAS'
storeFile file('PATH_TO_KEYSTORE/keystore_file')
}
debug {
keyAlias 'KEY_ALIAS'
keyPassword 'PASSWORD'
storePassword 'PASSWORD'
storeFile file('PATH_TO_DEBUG_KEYSTORE/debug.keystore')
}
}
productFlavors {
full {
versionName '10.6.0'
applicationId 'com.whatever.appname'
testApplicationId 'APP_TEST_ID'
versionCode 8
proguardFile '/PATH_TO_PROGUARD/proguard-project.txt'
signingConfig signingConfigs.release
targetSdkVersion 24
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
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'
}
dependencies {
compile 'ch.acra:acra:4.7.0'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:support-compat:24.2.1'
compile 'com.android.support:support-core-utils:24.2.1'
compile 'com.android.support:support-core-ui:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-annotations:24.2.1'
compile fileTree(include: ['*.jar'], dir: 'libs')
}
在我的ProGuard-project.txt文件,由於使用一些過時的類的,有的爲我的應用程序相關的和具體項目有:
-keep class org.apache.http.** { *; }
-dontwarn org.apache.commons.**
-dontwarn org.apache.http.**
-dontwarn android.net.http.AndroidHttpClient
-dontwarn com.google.android.gms.**
-dontwarn com.android.volley.toolbox.**
-ignorewarnings
對於那些好奇,當我完全從構建刪除ProGuard的過程中,做一個應用清潔,隨後fullRelease的身材,我遇到的問題的不同:
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/graphics/drawable/AnimatedVectorDrawableCompat$1;
和:
Error:Execution failed for task ':app:transformClassesWithDexForFullRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
任何人都可以闡明我遇到的錯誤,並可能提出一個解決辦法嗎?當然,我最好將proguard過程納入構建過程。
UPDATE:此外,在命令行中運行任何gradle這個任務時,我遇到了錯誤:
problem occurred evaluating project ':app'.
> java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0
這使我相信無論是在程序兼容性和支持庫的Java 8語言功能的地方是正在使用的,而我對編譯Java 7中
這意味着您的依賴關係中的一些依賴關係會被衝突版本添加兩次。你可能想檢查支持庫中的AnimatedVectorDrawableCompat類,但也可能是其中一個。 – breakline
我認爲你是對的,但我認爲這是一個獲取正確版本的支持庫的問題,我願意構建對於API Level 23,如果通過允許降級支持我們的appcompat庫等來協助。 – Mat