我一直试图让ProGuard
在过去2天内运行,但是无法解决这个问题。
完整错误
java.io.IOException:无法写入[/PATH_TO_POJECT/build/intermediates/classes-proguard/release/classes.jar](无法读取[/ PATH_TO_POJECT / build / intermediates / explosion-aar / com。 facebook.android/FaceBook320/3.20.0/libs/android-support-v13.jar(;;;;;;!META-INF/MANIFEST.MF)](重复的zip条目[android-support-v13.jar:android /support/v13/app/FragmentCompat$ICSFragmentCompatImpl.class]))
我正在使用Android Studio
。我的项目包含几个不同的模块,其中两个模块依赖于android-support-v13.jar
。我确保每个模块的android-support-v13.jar
都相同。
我也试过从这些模块中排除支持jar: 的的build.gradle
compile (project(':FaceBook320')){
exclude module: 'support-v13'
exclude module: 'support-v4'
}
但我仍然得到同样的错误。
我的proguard-project.pro
:
-optimizationpasses 5
#When not preverifing in a case-insensitive filing system, such as Windows. Because this tool unpacks your processed jars, you should then use:
-dontusemixedcaseclassnames
#Specifies not to ignore non-public library classes. As of version 4.5, this is the default setting
-dontskipnonpubliclibraryclasses
#Preverification is irrelevant for the dex compiler and the Dalvik VM, so we can switch it off with the -dontpreverify option.
-dontpreverify
#Specifies to write out some more information during processing. If the program terminates with an exception, this option will print out the entire stack trace, instead of just the exception message.
-verbose
#The -optimizations option disables some arithmetic simplifications that Dalvik 1.0 and 1.5 can't handle. Note that the Dalvik VM also can't handle aggressive overloading (of static fields).
#To understand or change this check http://proguard.sourceforge.net/index.html#/manual/optimizations.html
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
#To repackage classes on a single package
#-repackageclasses ''
#Uncomment if using annotations to keep them.
#-keepattributes *Annotation*
#Keep classes that are referenced on the AndroidManifest
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class com.android.vending.licensing.ILicensingService
#To remove debug logs:
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
}
#To avoid changing names of methods invoked on layout's onClick.
# Uncomment and add specific method names if using onClick on layouts
#-keepclassmembers class * {
# public void onClickButton(android.view.View);
#}
#Maintain java native methods
-keepclasseswithmembernames class * {
native <methods>;
}
#To maintain custom components names that are used on layouts XML.
#Uncomment if having any problem with the approach below
#-keep public class custom.components.package.and.name.**
#To maintain custom components names that are used on layouts XML:
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
#Maintain enums
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
#To keep parcelable classes (to serialize - deserialize objects to sent through Intents)
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
#Keep the R
-keepclassmembers class **.R$* {
public static <fields>;
}
#Results classes that only extend a generic should be preserved as they will be pruned by Proguard
#as they are "empty", others are kept
-keep class com.project.models.**
-keep class com.project.models.singleton.**
#RoboSpice requests should be preserved in most cases
-keepclassmembers class com.project.requests.** {
public void set*(***);
public *** get*();
public *** is*();
}
#if you use public fields instead of setter/getters for your REST POJOs, add this
-keepclassmembers class com.project.models.** {
public <fields>;
}
### Jackson SERIALIZER SETTINGS
-keepclassmembers,allowobfuscation class * {
@org.codehaus.jackson.annotate.* <fields>;
@org.codehaus.jackson.annotate.* <init>(...);
}
### Simple XML SERIALIZER SETTINGS
-keepclassmembers,allowobfuscation class * {
@org.simpleframework.xml.* <fields>;
@org.simpleframework.xml.* <init>(...);
}
-dontskipnonpubliclibraryclassmembers
-keepattributes *Annotation*,EnclosingMethod
-keepnames class org.codehaus.jackson.** { *; }
#Warnings to be removed. Otherwise maven plugin stops, but not dangerous
-dontwarn android.support.**
-dontwarn android.support.v4.**
-dontwarn android.support.v13.**
-dontwarn com.sun.xml.internal.**
-dontwarn com.sun.istack.internal.**
-dontwarn org.codehaus.jackson.**
-dontwarn org.springframework.**
-dontwarn java.awt.**
-dontwarn javax.security.**
-dontwarn java.beans.**
-dontwarn javax.xml.**
-dontwarn java.util.**
-dontwarn org.w3c.dom.**
-dontwarn com.google.common.**
-dontwarn com.octo.android.robospice.persistence.**
#-optimizationpasses 5
-dontoptimize
-keep class twitter4j.CommonsLoggingLoggerFactory
-dontwarn twitter4j.CommonsLoggingLoggerFactory
-keep class twitter4j.Log4JLogger
-dontwarn twitter4j.Log4JLogger
-keep class twitter4j.Log4JLoggerFactory
-dontwarn twitter4j.Log4JLoggerFactory
-keep class twitter4j.management.APIStatisticsOpenMBean
-dontwarn twitter4j.management.APIStatisticsOpenMBean
-keep class twitter4j.management.APIStatisticsOpenMBean
-dontwarn twitter4j.management.APIStatisticsOpenMBean
-keep class twitter4j.SLF4JLogger
-dontwarn twitter4j.SLF4JLogger
-keep class twitter4j.SLF4JLoggerFactory4
-dontwarn twitter4j.SLF4JLoggerFactory
-keep class twitter4j.TwitterAPIMonitor
-dontwarn twitter4j.TwitterAPIMonitor
-keep class android.support.v4.app.** { *; }
-keep class android.support.v4.** { *; }
-keep class android.support.v13.**{ *;}
-keep interface android.support.v4.app.** { *; }
-keep class android.support.v13.app.** { *; }
-keep interface android.support.v13.app.** { *; }
#Preverification is irrelevant for the dex compiler and the Dalvik VM, so we can switch it off with the -dontpreverify option.
-dontpreverify
#To remove debug logs:
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
}
#Facebook
-keep class com.facebook.** { *; }
-keepattributes Signature
#Google Play Services
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
我的完整build.gradle
:
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
dependencies {
//There is an android-support-v13.jar in the libs folder.
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':PullToRefresh')
compile project(':PinnedListView')
compile ('com.google.android.gms:play-services:6.1.71'){
exclude module: 'support-v13'
exclude module: 'support-v4'
}
//The FaceBook320 project depends on android-support-v13.jar
compile (project(':FaceBook320')){
exclude module: 'support-v13'
exclude module: 'support-v4'
}
//The PagerSlidingTabStrip project depends on android-support-v13.jar
compile (project(':PagerSlidingTabStrip')){
exclude module: 'support-v13'
exclude module: 'support-v4'
}
}
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/dependencies'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/README.txt'
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude '!META-INF/MANIFEST.MF'
exclude 'META-INF/MANIFEST.MF'
}
lintOptions {
checkReleaseBuilds true
// 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
}
signingConfigs {
debug {
storeFile file("secret.keystore")
storePassword "secret"
keyAlias "secret"
keyPassword "secret"
}
release {
storeFile file("secret.keystore")
storePassword "secret"
keyAlias "secret"
keyPassword "secret"
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Types
buildTypes {
debug {
applicationIdSuffix ""
versionNameSuffix ""
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.pro'
signingConfig signingConfigs.debug
}
release {
applicationIdSuffix ""
versionNameSuffix ""
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.pro'
signingConfig signingConfigs.release
}
}
}
}
修改:运行gradlew androidDependencies
+--- LOCAL: android-support-v13.jar
+--- LOCAL: commons-io-1.3.2.jar
+--- LOCAL: commons-lang3-3.1.jar
+--- LOCAL: jackson-annotations-2.3.1.jar
+--- LOCAL: jackson-core-2.3.1.jar
+--- LOCAL: jackson-databind-2.3.1.jar
+--- LOCAL: libGoogleAnalyticsServices.jar
+--- LOCAL: robospice-1.4.9.jar
+--- LOCAL: robospice-cache-1.4.9.jar
+--- LOCAL: robospice-spring-android-1.4.9.jar
+--- LOCAL: spring-android-auth-1.0.1.RELEASE.jar
+--- LOCAL: spring-android-core-1.0.1.RELEASE.jar
+--- LOCAL: spring-android-rest-template-1.0.1.RELEASE.jar
+--- LOCAL: twitter4j-core-4.0.1.jar
+--- Droid_AS:PullToRefresh:unspecified
| \--- Droid_AS:PinnedListView:unspecified
+--- Droid_AS:PinnedListView:unspecified
+--- com.google.android.gms:play-services:6.1.71
+--- com.facebook.android:FaceBook320:3.20.0
| \--- LOCAL: android-support-v13.jar
\--- Droid_AS:PagerSlidingTabStrip:unspecified
\--- LOCAL: android-support-v13.jar
我已经看过这个问题的每一个帖子,并尝试了所有,请帮忙! 谢谢!
答案 0 :(得分:1)
在Gradle构建系统中,请不要直接在其jar中链接来包含支持库。 Gradle有一个更好的方法来处理这些依赖关系,这将防止你在这里看到类重复的问题。
在dependencies
块中通过此语句包含support-v13依赖项:
compile 'com.android.support:support-v13:21.0.2'
根据您通过SDK管理器安装的内容,使用适当的版本号。如果您通过项目结构&gt;添加依赖项(您的模块)&gt;依赖性&gt; +&gt;库依赖,它可以帮助您正确使用它。