CrashLytics test project in Android Studio with proguard enabled do not obfuscate Class and method names. As you see in provided rules file, I don't use any rules "proguard-rules.pro".
- Where I am doing wrong?
- Is there a reference document or tutorial for explaining Proguard rules?
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 analyser shows that Class and method names are completely clear
below screenshot shows that proguard is working
Ok, I cannot obfuscate Activity names because it should be referable via Manifest file, but how about method names onCreate and forceCrash, why they are still readble?
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"); } } 
