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

标签 actionbarsherlock proguard android-studio

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

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

我正在尝试使用 Android Studio Build#AI-130.692269 生成签名 APK。我选中了“运行 ProGuard”和“包含系统 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 完全陌生,因此欢迎提供任何反馈。

最佳答案

我在尝试使用 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 中的部分,错误消失了。

解决方法是在
Duplicate files copied (Android Studio 0.4.0)

关于actionbarsherlock - Android Studio 和 ProGuard - 无法写入资源 [META-INF/MANIFEST.MF](重复的 zip 条目 [volley.jar :META-INF/MANIFEST. MF]),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16970907/

相关文章:

android - Proguard 和 Android 适配器

android - 文件资源检查为红色,尽管 R 有效

java - Google Play 登录始终失败异常 : 4

android - 错误 :Unable to obtain debug bridge in android studio

android - robotium - 单击操作栏选项卡

android - 我应该使用 SupportLibrary ActionBar 还是替代品?

android - 删除 actionbar item 蓝色背景

java - 混淆器 - 错误 : A JNI error has occured

android - ActionBarSherlock 同一选项卡中的重叠 fragment

android - 在应用程序中存储和保护私有(private) API key 的最佳实践