启用了proguard的Android Studio中的CrashLytics测试项目不会混淆类和方法名称。正如您在提供的规则文件中看到的那样,我没有使用任何规则" proguard-rules.pro"。
的build.gradle
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分析器显示类和方法名称完全清晰
截图下方的显示proguard正在运行
好的,我不能混淆Activity名称,因为它应该通过Manifest文件引用,但是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");
}
}
答案 0 :(得分:1)
替换
proguardFiles 'proguard-rules.pro'
与
对齐 getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
答案 1 :(得分:1)
活动名称永远不会被混淆,因为它们在manifest.xml中被引用。和android通过反射访问这些活动,因此无法更改其名称)
答案 2 :(得分:0)
显然,实际上没有人混淆活动名称。 但是,您可以手动更改它。 只需将其名称修改为所需的名称即可。
对于混淆的方法和类,只需使用:
-obfuscationdictionary file.txt
-classobfuscationdictionary file.txt