[英]What am I doing wrong in proguard rules?
我一直在努力完成應用程序中的工作。 一切都已設置並且可以正常工作,但是一旦我要設置proguard rules
,我的應用程序總是崩潰。 我逐一檢查了每個庫 ,並使用了它們在proguard-rules.pro
文件中提供的所有信息。 但是,我無法使其工作。
我總共進行了4次活動,根據這些規則,只有其中一項崩潰了。 我可以進入和退出其他3。
我啟用了調試功能,是因為我了解到,如果應用程序在此模式下運行,則表示它受到保護;當我刪除該應用程序並將其上傳到Play商店時,它將受到反編譯保護。 如果我錯了,請警告我。
這是我的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
multiDexEnabled true
applicationId "com.example.android.rippleblockexplorer"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
shrinkResources true
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
shrinkResources true
debuggable true
}
}
}
dependencies {
testImplementation 'junit:junit:4.12'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.android.support:design:27.1.1'
implementation "org.java-websocket:Java-WebSocket:1.3.8"
implementation 'com.github.curioustechizen.android-ago:library:1.4.0'
implementation 'com.facebook.shimmer:shimmer:0.1.0@aar'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation "com.android.support:cardview-v7:27.1.1"
implementation 'org.ocpsoft.prettytime:prettytime:4.0.1.Final'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
}
這是我的proguard-rules.pro:
# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit2.Platform
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit2.Platform$Java8
# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions
-ignorewarnings
-keep class * {
public private *;
}
##---------------Begin: proguard configuration for Gson ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature
# For using GSON @Expose annotation
-keepattributes *Annotation*
# Gson specific classes
-keep class sun.misc.Unsafe { *; }
#-keep class com.google.gson.stream.** { *; }
# Application classes that will be serialized/deserialized over Gson
#-keep class com.google.gson.examples.android.model.** { *; }
# Prevent proguard from stripping interface information from TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
##---------------End: proguard configuration for Gson ----------
# Retain generated class which implement Unbinder.
-keep public class * implements butterknife.Unbinder { public <init>(**, android.view.View); }
# Prevent obfuscation of types which use ButterKnife annotations since the simple name
# is used to reflectively look up the generated ViewBinding.
-keep class butterknife.*
-keepclasseswithmembernames class * { @butterknife.* <methods>; }
-keepclasseswithmembernames class * { @butterknife.* <fields>; }
-keep class org.ocpsoft.prettytime.i18n.**
#DEBUGGING ENABLER
-keepattributes SourceFile,LineNumberTable
-keep class com.example.android.rippleblockexplorer.model.** { *; }
-dontwarn kotlin.Unit
我完全不確定要添加或刪除的內容。 顯式調試在某處顯示錯誤,但是當我禁用proguard時它完全可以工作。 我不理解為什么。
僅供參考,我正在使用Java thread
(並且您知道,覆蓋了Runnable
等); 如果有幫助的話。
有人有解決方案或建議嗎? 任何幫助都非常感謝。
在調試模式下,proguard文件不起作用。在發布模式下,proguard文件可以工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.