(#) Proguard.cfg file contains generic Android rules
!!! WARNING: Proguard.cfg file contains generic Android rules
This is a warning.
Id
: `ProguardSplit`
Summary
: Proguard.cfg file contains generic Android rules
Severity
: Warning
Category
: Correctness
Platform
: Android
Vendor
: Android Open Source Project
Feedback
: https://issuetracker.google.com/issues/new?component=192708
Since
: Initial
Affects
: Shrinking configuration files
Editing
: This check runs on the fly in the IDE editor
Implementation
: [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/ProguardDetector.java)
Tests
: [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/ProguardDetectorTest.kt)
Copyright Year
: 2011
Earlier versions of the Android tools bundled a single `proguard.cfg`
file containing a ProGuard configuration file suitable for Android
shrinking and obfuscation. However, that version was copied into new
projects, which means that it does not continue to get updated as we
improve the default ProGuard rules for Android.
In the new version of the tools, we have split the ProGuard
configuration into two halves:
* A simple configuration file containing only project-specific flags, in
your project
* A generic configuration file containing the recommended set of
ProGuard options for Android projects. This generic file lives in
the SDK install directory which means that it gets updated along
with the tools.
In order for this to work, the proguard.config property in the
`project.properties` file now refers to a path, so you can reference
both the generic file as well as your own (and any additional files
too).
To migrate your project to the new setup, create a new
`proguard-project.txt` file in your project containing any project
specific ProGuard flags as well as any customizations you have made,
then update your project.properties file to contain:
`proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt`
(##) Example
Here is an example of lint warnings produced by this check:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text
myfile.txt:8:Warning: Local ProGuard configuration contains general
Android configuration: Inherit these settings instead? Modify
project.properties to define
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:myfile.txt
and then keep only project-specific configuration here [ProguardSplit]
-keep public class * extends android.app.Activity
^
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here are the relevant source files:
`myfile.txt`:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text linenumbers
-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