2015-09-12 31 views
7

android stüdyoda proguard hatası, bunu etkin ama apk dosyası oluşturmak istediğinizde, bana bu hata veriyor:android - Uygulamam için ProGuard kullanmak istediğiniz

Information:Gradle tasks [:app:assembleRelease] 
:app:preBuild UP-TO-DATE 
:app:preReleaseBuild UP-TO-DATE 
:app:checkReleaseManifest 
:app:preDebugBuild UP-TO-DATE 
:app:prepareComAndroidSupportAppcompatV72300Library UP-TO-DATE 
:app:prepareComAndroidSupportCardviewV72300Library UP-TO-DATE 
:app:prepareComAndroidSupportDesign2300Library UP-TO-DATE 
:app:prepareComAndroidSupportRecyclerviewV72300Library UP-TO-DATE 
:app:prepareComAndroidSupportSupportV42300Library UP-TO-DATE 
:app:prepareJpWasabeefRecyclerviewAnimators122Library UP-TO-DATE 
:app:prepareReleaseDependencies 
:app:compileReleaseAidl UP-TO-DATE 
:app:compileReleaseRenderscript UP-TO-DATE 
:app:generateReleaseBuildConfig UP-TO-DATE 
:app:generateReleaseAssets UP-TO-DATE 
:app:mergeReleaseAssets UP-TO-DATE 
:app:generateReleaseResValues UP-TO-DATE 
:app:generateReleaseResources UP-TO-DATE 
:app:mergeReleaseResources UP-TO-DATE 
:app:processReleaseManifest UP-TO-DATE 
:app:processReleaseResources UP-TO-DATE 
:app:generateReleaseSources UP-TO-DATE 
:app:processReleaseJavaRes UP-TO-DATE 
:app:compileReleaseJava UP-TO-DATE 
:app:compileReleaseNdk UP-TO-DATE 
:app:compileReleaseSources UP-TO-DATE 
:app:lintVitalRelease 
:app:proguardRelease 
Note: there were 7 duplicate class definitions. 
     (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass) 
Warning:library class org.apache.http.conn.scheme.LayeredSocketFactory extends or implements program class org.apache.http.conn.scheme.SocketFactory 
Warning:org.acra.ErrorReporter: can't find referenced method 'void setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)' in library class android.app.Notification 
Warning:library class android.webkit.WebView depends on program class android.net.http.SslCertificate 
Warning:library class org.apache.http.conn.ssl.SSLSocketFactory depends on program class org.apache.http.conn.scheme.HostNameResolver 
Warning:library class org.apache.http.conn.ssl.SSLSocketFactory depends on program class org.apache.http.params.HttpParams 
Warning:library class org.apache.http.params.HttpConnectionParams depends on program class org.apache.http.params.HttpParams 
Warning:there were 17 instances of library classes depending on program classes. 
     You must avoid such dependencies, since the program classes will 
     be processed, while the library classes will remain unchanged. 
     (http://proguard.sourceforge.net/manual/troubleshooting.html#dependency) 
Warning:there were 1 unresolved references to library class members. 
     You probably need to update the library versions. 
     (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember) 
:app:proguardRelease FAILED 
Error:Execution failed for task ':app:proguardRelease'. 
> java.io.IOException: Please correct the above warnings first. 

Ben son kullanıyorum sdk 23 sürümü, bu benim gradle dosyasıdır:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion '23.0.0' 

    defaultConfig { 
     applicationId "com.x.x" 
     minSdkVersion 11 
     targetSdkVersion 23 
    } 

    buildTypes { 
     release { 
      minifyEnabled true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 
     } 
    } 
} 



dependencies { 
    compile 'com.android.support:appcompat-v7:23.0.0' 
    compile 'com.android.support:recyclerview-v7:23.0.0' 
    compile files('libs/acra-4.5.0.jar') 
    compile files('libs/universal-image-loader-1.8.4-with-sources.jar') 
    compile files('libs/org.apache.http.legacy.jar') 
    compile 'com.android.support:cardview-v7:23.0.0' 
    compile 'jp.wasabeef:recyclerview-animators:1.2.2' 
    compile 'com.android.support:design:23.0.0' 
} 

Sorun nedir? bu kodda yanlış yaptığım yer

sayesinde http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass

Sen uygulama bağımlılıkları yinelenen sınıf tanımları vardır ve bu sadece uyarılar olduğunu kontrol edin LogCat belirtildiği gibi

+1

Ben senin bağımlılık merak ediyorum '('libs/org.apache.http.legacy.jar')' ... dosyaları derlemek Eski apache lib, jar'a ihtiyacınız yok, 'android {}' bölümüne 'useLibrary 'org.apache.http.legacy' öğesini eklemeniz yeterlidir. – fattire

cevap

-3

. \ Araçları> android-sdk-yolu - proguard-android.txt yer:

# 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: 
-dontwarn com.google.code.** 
-dontwarn org.apache.** 
-dontwarn jp.wasabeef.recyclerview.** 
-dontwarn com.nostra13.universalimageloader.** 
-dontwarn org.acra.** 

#wasabeef recyclerview 
-keep class jp.wasabeef.recyclerview.** { *; } 
-keepattributes Signature 
#HTTP Legacy 
-keep class org.apache.** { *; } 
-keepattributes Signature 
#Universal Image Loader 
-keep class com.nostra13.universalimageloader.** { *; } 
-keepattributes Signature 
#Acra 
-keep class org.acra.** { *; } 
-keepattributes Signature 
#Support libraries 
-keep class com.android.** { *; } 
-keepattributes Signature 





# Keep the annotations 
-keepattributes *Annotation* 


-allowaccessmodification 
-keepattributes *Annotation* 
-renamesourcefileattribute SourceFile 
-keepattributes SourceFile,LineNumberTable 
-repackageclasses '' 


-dontnote com.android.vending.licensing.ILicensingService 

# Explicitly preserve all serialization members. The Serializable interface 
# is only a marker interface, so it wouldn't save them. 
-keepclassmembers class * implements java.io.Serializable { 
    static final long serialVersionUID; 
    private static final java.io.ObjectStreamField[] serialPersistentFields; 
    private void writeObject(java.io.ObjectOutputStream); 
    private void readObject(java.io.ObjectInputStream); 
    java.lang.Object writeReplace(); 
    java.lang.Object readResolve(); 
} 

# Preserve all native method names and the names of their classes. 
-keepclasseswithmembernames class * { 
    native <methods>; 
} 

-keepclasseswithmembernames class * { 
    public <init>(android.content.Context, android.util.AttributeSet); 
} 

-keepclasseswithmembernames class * { 
    public <init>(android.content.Context, android.util.AttributeSet, int); 
} 

# Preserve static fields of inner classes of R classes that might be accessed 
# through introspection. 
-keepclassmembers class **.R$* { 
    public static <fields>; 
} 

# Preserve the special static methods that are required in all enumeration classes. 
-keepclassmembers enum * { 
    public static **[] values(); 
    public static ** valueOf(java.lang.String); 
} 

-keep public class * { 
    public protected *; 
} 

-keep class * implements android.os.Parcelable { 
    public static final android.os.Parcelable$Creator *; 
} 

Not: Artık o bunu düzeltmek için proguard-android.txt kod aşağıda ekleyin isterseniz

\ proguard

Teşekkürler!

+3

Vay, bu bir dev proguard dosyası .. sizce bu soruyla ilgili önemli bitler hangileridir? – fattire

20

Sadece ProGuard bu ekleyin: Kullandığınız takdirde

-keep class org.apache.http.** { *; } 
-dontwarn org.apache.http.** 
-dontwarn android.net.** 
+0

İyi cevap, teşekkürler! – Apqu

+0

, proguard'ı bugün kullanmaya başladığım gibi nasıl çalıştığını açıklayabilir misiniz? – Killer