Android Studio和ProGuard - 无法编写资源[META-INF / MANIFEST.MF](重复的zip条目[volley.jar:META-INF / MANIFEST.MF])

时间:2013-06-06 19:47:38

标签: actionbarsherlock proguard android-studio

我有一个使用actionbarsherlock的Android应用程序和libs下的下一个jar 文件夹:

android-support-v4.jar
gson-2.2.4.jar
libGoogleAnalyticsV2.jar
volley.jar

我正在尝试使用Android Studio Build#AI-130.692269生成签名APK。我检查两个复选框“运行ProGuard”和“包含系统程序文件”

我的ProGuard路径文件proguard-project.txt如下所示:

# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

我编辑了project.properties,现在看起来像:

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
proguard.config=/Applications/adt-bundle-mac-x86_64/sdk/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-17
android.library=false
android.library.reference.1=../AndroidBarSherlock/actionbarsherlock

这是我得到的输出:

Information:ProGuard: [SocialPrice] ProGuard, version 4.7
Information:ProGuard: [SocialPrice] Reading input...
Information:ProGuard: [SocialPrice] Reading program jar [/Users/sdelamo/Library/Caches/AndroidStudioPreview/compile-server/_temp_/proguard_input4364141808943557175.jar]
Information:ProGuard: [SocialPrice] Reading program jar [/Users/sdelamo/Documents/Developer/android/facebook-android-sdk-3.0.1/facebook/libs/android-support-v4.jar]
Information:ProGuard: [SocialPrice] Reading program jar [/Users/sdelamo/Documents/workspaceAndroid/SocialPrice/libs/volley.jar]
Information:ProGuard: [SocialPrice] Reading program jar [/Users/sdelamo/Documents/workspaceAndroid/SocialPrice/libs/libGoogleAnalyticsV2.jar]
Information:ProGuard: [SocialPrice] Reading program jar [/Users/sdelamo/Documents/workspaceAndroid/SocialPrice/libs/gson-2.2.4.jar]
Information:ProGuard: [SocialPrice] Reading library jar [/Applications/Android Studio.app/sdk/platforms/android-17/android.jar]
Information:ProGuard: [SocialPrice] Initializing...
Information:ProGuard: [SocialPrice] Note: com.google.analytics.tracking.android.AdHitIdGenerator: can't find dynamically referenced class com.google.ads.AdRequest
Information:ProGuard: [SocialPrice] Note: com.google.gson.internal.UnsafeAllocator: can't find dynamically referenced class sun.misc.Unsafe
Information:ProGuard: [SocialPrice] Note: the configuration refers to the unknown class 'com.google.vending.licensing.ILicensingService'
Information:ProGuard: [SocialPrice] Note: the configuration refers to the unknown class 'com.android.vending.licensing.ILicensingService'
Information:ProGuard: [SocialPrice] Note: there were 2 references to unknown classes.
Information:ProGuard: [SocialPrice]       You should check your configuration for typos.
Information:ProGuard: [SocialPrice] Note: there were 2 unresolved dynamic references to classes or interfaces.
Information:ProGuard: [SocialPrice] Ignoring unused library classes...
Information:ProGuard: [SocialPrice]   Original number of library classes: 3259
Information:ProGuard: [SocialPrice]   Final number of library classes:    841
Information:ProGuard: [SocialPrice] Printing kept classes, fields, and methods...
Information:ProGuard: [SocialPrice] Shrinking...
Information:ProGuard: [SocialPrice] Printing usage to [/Users/sdelamo/Documents/workspaceAndroid/SocialPrice/proguard_logs/usage.txt]...
Information:ProGuard: [SocialPrice] Removing unused program classes and class elements...
Information:ProGuard: [SocialPrice]   Original number of program classes: 921
Information:ProGuard: [SocialPrice]   Final number of program classes:    579
Information:ProGuard: [SocialPrice] Obfuscating...
Information:ProGuard: [SocialPrice] Printing mapping to [/Users/sdelamo/Documents/workspaceAndroid/SocialPrice/proguard_logs/mapping.txt]...
Information:ProGuard: [SocialPrice] Writing output...
Information:ProGuard: [SocialPrice] Preparing output jar [/Users/sdelamo/Library/Caches/AndroidStudioPreview/compile-server/socialprice_a27782ee/android/intermediate_artifacts/SocialPrice/obfuscated_sources.jar]
Information:ProGuard: [SocialPrice]   Copying resources from program jar [/Users/sdelamo/Library/Caches/AndroidStudioPreview/compile-server/_temp_/proguard_input4364141808943557175.jar]
Information:ProGuard: [SocialPrice]   Copying resources from program jar [/Users/sdelamo/Documents/Developer/android/facebook-android-sdk-3.0.1/facebook/libs/android-support-v4.jar]
Information:ProGuard: [SocialPrice]   Copying resources from program jar [/Users/sdelamo/Documents/workspaceAndroid/SocialPrice/libs/volley.jar]
Information:ProGuard: [SocialPrice]   Copying resources from program jar [/Users/sdelamo/Documents/workspaceAndroid/SocialPrice/libs/libGoogleAnalyticsV2.jar]
Information:ProGuard: [SocialPrice]   Copying resources from program jar [/Users/sdelamo/Documents/workspaceAndroid/SocialPrice/libs/gson-2.2.4.jar]
Information:ProGuard: [SocialPrice] Printing classes to [/Users/sdelamo/Documents/workspaceAndroid/SocialPrice/proguard_logs/dump.txt]...
Information:Compilation completed successfully with 4 warnings in 2 min 28 sec
Information:0 errors
Information:4 warnings
Warning:ProGuard: [SocialPrice]       You should check if you need to specify additional program jars.
Warning:ProGuard: [SocialPrice] Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [volley.jar:META-INF/MANIFEST.MF])
Warning:ProGuard: [SocialPrice] Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [libGoogleAnalyticsV2.jar:META-INF/MANIFEST.MF])
Warning:ProGuard: [SocialPrice] Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [gson-2.2.4.jar:META-INF/MANIFEST.MF])

我是ProGuard的新手,所以欢迎任何反馈。

4 个答案:

答案 0 :(得分:5)

我在尝试使用joda-time库时遇到了类似的问题。

添加

packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
}

到build.gradle中的 android 部分,错误消失了。

找到了解决方案 Duplicate files copied (Android Studio 0.4.0)

答案 1 :(得分:2)

this url报告了类似的问题。希望它有所帮助。

BTW还要确保您使用最新版本的Android SDK ..它会为您的项目创建一个空的proguard-project.txt。

答案 2 :(得分:0)

从版本0.9.1开始,在包装过程中发生冲突时可以包含文件:

android.packagingOptions {
    pickFirst 'META-INF/MANIFEST.MF'
}

有关详细信息,请参阅Gradle release notes

答案 3 :(得分:-2)

将-dontwarn添加到proguard.cfg以忽略警告