1

I have an empty project (no classes whatsoever, no activities), only a dependency to com.google.android.material:material:1.3.0 for the code to compile (there is a style defined which uses this).

I enabled shrinking option, yet, after generating the signes APK, there is a classes.dex file in the apk with a shitload of code, even though the app has no code. Why and how to I get rid of those, to make sure the apk contains only what is needed, no extra bloatware? Thank you.

This is the expanded apk:

This is the expanded apk.

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
StevenS
  • 11
  • 1
  • com.google.android.material:material:1.3.0 has a long list of [compile dependencies](https://mvnrepository.com/artifact/com.google.android.material/material/1.3.0). If you are sure those dependencies are not needed you can [exclude them in Gradle](https://docs.gradle.org/current/userguide/dependency_downgrade_and_exclude.html#sec:excluding-transitive-deps). – Robert Apr 26 '21 at 10:25

2 Answers2

1

For code shrinking please turn on Proguard and you have the option to customized Proguard rules as you need.

   buildTypes {
    release {
        shrinkResources true
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug {
    }
}
Shohan Ahmed Sijan
  • 4,391
  • 1
  • 33
  • 39
  • Thank you for your answer, but, as I said, these are already turned on. This is what baffles me. It's better than with no proguard turned on, but still the apk contains code and resources. The expected result is NO CODE AT ALL and no unnecessary resources included in the apk. – StevenS Apr 26 '21 at 11:53
0

TRY 1

Open .jar file (appodeal.jar) and remove all .dex files.

TRY 2

Use the built-in inspection Java | Declaration redundancy | Unused declaration.

To run it on whole project go to Analyze -> Run inspection by name..., type Unused declaration and select desired scope. Then carefully check output and mark some classes as entry points if needed.

Select Unused declaration node in list and perform Safe delete action on all unused declarations at once.

Ole Pannier
  • 3,208
  • 9
  • 22
  • 33
  • Thanks for answering, but it seems that's not it. I managed to dig a bit deeper and found that there are all kinds of proguard rules in the material dependency which keep a lot of stuff, regardless of usage. So, no matter what, an "optimized" apk is not so optimized after all, it still carries a lot of Google bloatware. – StevenS Apr 27 '21 at 13:59
  • More than that isn't possible. Here is the official video from Android Developers, what is clearly showing what will be removed maximum. So Android keeps the data (that looks unnecessary to you, for the case it need some attributes in the future.). https://www.youtube.com/watch?v=HxeW6DHEDQU&ab_channel=AndroidDevelopers – Ole Pannier Apr 27 '21 at 19:19