Android 无法使用Proguard混淆类和方法名称
Android Studio中启用proguard的CrashLytics测试项目不会混淆类和方法名称。正如您在提供的规则文件中看到的,我不使用任何规则“proguard rules.pro”Android 无法使用Proguard混淆类和方法名称,android,proguard,android-studio-3.0,Android,Proguard,Android Studio 3.0,Android Studio中启用proguard的CrashLytics测试项目不会混淆类和方法名称。正如您在提供的规则文件中看到的,我不使用任何规则“proguard rules.pro” 我哪里做错了 是否有解释Proguard规则的参考文件或教程 build.gradle buildscript { repositories { maven { url 'https://maven.fabric.io/public' } } dependenci
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// These docs use an open ended version so that our plugin
// can be updated quickly in response to Android tooling updates
// We recommend changing it to the latest version from our changelog:
// https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
classpath 'io.fabric.tools:gradle:1.22.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
signingConfigs {
config {
keyAlias 'key0'
keyPassword 'A123456789'
storeFile file('D:/Android/KeyStorePath/key1.jks')
storePassword 'A123456'
}
}
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.ba.autocompletetextcustomadapter"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.config
}
buildTypes {
release {
debuggable true
minifyEnabled true
shrinkResources false
proguardFiles 'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFiles 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'
compile('com.crashlytics.sdk.android:crashlytics:2.7.0@aar') {
transitive = true
}
}
proguard rules.pro
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in D:\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# 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 *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
apk Analyzer显示类和方法名称完全清晰
下面的屏幕截图显示proguard正在工作
已更新
好的,我不能混淆活动名称,因为它应该可以通过清单文件引用,但是方法名onCreate和forceCrash如何,为什么它们仍然是可读的
import io.fabric.sdk.android.Fabric;
import com.crashlytics.android.Crashlytics;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
setContentView(R.layout.activity_main);
}
public void forceCrash(View view) {
throw new RuntimeException("This is a crash");
}
}
替换
proguard文件的proguard规则.pro'
符合
getDefaultProguardFile('proguard-android.txt'),'proguard rules.pro'
替换
proguard文件的proguard规则.pro'
符合
getDefaultProguardFile('proguard-android.txt'),'proguard rules.pro'
显然,事实上没有任何东西能混淆活动名称。 但是,您可以手动更改它。 只需将其名称修改为您想要的名称 对于混淆方法和类,只需使用:
-obfuscationdictionary file.txt
-classobfuscationdictionary file.txt
显然,事实上没有任何东西能混淆活动名称。 但是,您可以手动更改它。 只需将其名称修改为您想要的名称 对于混淆方法和类,只需使用:
-obfuscationdictionary file.txt
-classobfuscationdictionary file.txt
您是在分析relase apk还是调试apk?Alao我建议你隐藏你的密钥库密码和其他敏感信息。如果你查看build.gradle文件,它们都是相同的。proguard对这两个文件都是启用的。为什么你的发布版本是可调试的weird@Patzu您不应该在调试版本上启用proguard,因为它会混淆APK和输出。是的,我知道,proguard不应在调试模式下启用,它会导致更多的构建时间。我这样做只是为了测试。敏感信息也是暂时的。您是在分析relase apk还是调试apk?Alao我建议你隐藏你的密钥库密码和其他敏感信息。如果你查看build.gradle文件,它们都是相同的。proguard对这两个文件都是启用的。为什么你的发布版本是可调试的weird@Patzu您不应该在调试版本上启用proguard,因为它会混淆APK和输出。是的,我知道,proguard不应在调试模式下启用,它会导致更多的构建时间。我这样做只是为了测试。另外,敏感信息是暂时的。我在发送问题无结果之前也这样做了。我在发送问题无结果之前也这样做了。非常感谢您提供的信息,特别是链接,请查看我的更新。非常感谢您提供的信息,特别是链接,请查看我的更新。该文件中可能有什么。txt?新类名称的字符串。比如:this.that.this或者你可以在这里共享一个带有文本或任何引用的示例文件吗?感谢在该文件中提供@vdTOGwhat.txt?字符串链接以获取新的类名。比如:this.that.this或者你可以在这里共享一个带有文本或任何参考的示例文件吗?谢谢链接@vdTOG