Android Studio and ProGuard - cannot write the resource [META-INF / MANIFEST.MF] (Duplicating the zip entry [volley.jar: META-INF / MANIFEST.MF])

I have an Android application that uses actionbarsherlock and the following banks under the libs folder:

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

I am trying to create a signed APK with Android Studio Build # AI-130.692269. I check both the "Run ProGuard" and "Enable System Protection File" checkboxes.

The My ProGuard proguard-project.txt path file looks like this:

 # 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 *; #} 

I edited project.properties, which now looks like this:

 # 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 

This is the result I get:

 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]) 

I am completely new to ProGuard, so any feedback is welcome.

+4
source share
4 answers

I encountered a similar problem when trying to use the joda-time library.

By adding

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

In the android section in the build.gradle file, the error disappeared.

The solution was found in Duplicate File Copy (Android Studio 0.4.0)

+5
source

A similar problem is provided in this URL . Hope this helps.

By the way, make sure you are using the latest version of the Android SDK .. it will create an empty proguard-project.txt project for your project.

+2
source

Starting from version 0.9.1, you can include a file in case of conflict during packaging:

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

See Gradle release notes for more details.

0
source

add -dontwarn to proguard.cfg ignore warnings

-2
source

Source: https://habr.com/ru/post/1484904/


All Articles