2016-07-04 4 views
-3

서명 된 APK를 생성하는 데 실패했습니다.안드로이드 - Proguard로 서명 된 APK 생성

proguard-rules.pro 파일 :

-optimizationpasses 5 
-dontusemixedcaseclassnames 
-dontskipnonpubliclibraryclasses 
-dontpreverify 
-verbose 
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 

-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 * extends android.app.backup.BackupAgentHelper 
-keep public class * extends android.preference.Preference 
-keep public class com.android.vending.licensing.ILicensingService 

-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); 
} 

-keepclassmembers enum * { 
    public static **[] values(); 
    public static ** valueOf(java.lang.String); 
} 

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

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

# ============ Corrige erros de compilação ============= 
-dontwarn android.support.** 
-keeppackagenames org.jsoup.nodes 
-dontwarn okio.** 
# ====================================================== 

# ==== crashlytics ==== 
-keepattributes *Annotation* 
-keepattributes SourceFile,LineNumberTable 
-keep public class * extends java.lang.Exception 
# ===================== 

내 의존성 :

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.4.0' 
    compile 'com.google.android.gms:play-services-ads:9.2.0' 
    compile 'com.google.android.gms:play-services-analytics:9.2.0' 
    compile 'com.android.support:design:23.4.0' 
    compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
     transitive = true; 
    } 
    compile 'org.jsoup:jsoup:1.9.2' 
    compile 'com.github.hotchemi:android-rate:1.0.1' 
    compile 'com.github.curioustechizen.android-ago:library:1.3.2' 
    compile 'com.jakewharton:butterknife:8.0.1' 
    apt 'com.jakewharton:butterknife-compiler:8.0.1' 
    compile 'com.amitshekhar.android:android-networking:0.0.1' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
} 

빌드 오류 :

Error:Execution failed for task ':mobile:transformClassesAndResourcesWithProguardForRelease'. 
> java.io.IOException: Please correct the above warnings first. 
:mobile:transformClassesAndResourcesWithProguardForRelease FAILED 
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first. 

답변

1

만약 당신이 단지 추가 서명 된 APK를 생성 할 일은 원하는 모든 the

-ignorewarnings 

플래그가 proguard-rules.pro 파일에 있습니다. 이렇게하면 Proguard에서 방출되는 모든 경고가 무시되고 서명 된 APK가 생성됩니다.

그러나이 방법으로 모든 경고를 무시하면 의도하지 않은 결과 (중요한 클래스가 제거되고 기능이 저하되는 등)가 발생할 수 있습니다. 나는 여러분에게 방출 된 각각의 경고를 조사하고 각각의 경고를 개별적으로 처리 할 것을 강력하게 촉구합니다. 규정 된 방식으로 각 경고를 올바르게 처리하거나 경고가 가짜 인 경우 특정 클래스 또는 라이브러리에 대해

-dontwarn 

플래그를 사용하십시오.

이러한 부작용이 모두 제거 될 때까지 프로세스를 반복하면 Proguard에 최적화 된 APK가 문제없이 생깁니다.

+0

어쨌든 당신이 나를 도왔습니다. – Josinaldo

+0

제 경우에는 "-dontwarn com.squareup.okhttp. **"(lib Picasso)를 "proguard-rules.pro"파일에 넣기로 결정했습니다. – Josinaldo

+0

빌드 할 수 있습니까? 부작용이없는 서명 된 APK? –

관련 문제