Do not include unused library to release apk

android gradle proguard

365 просмотра

2 ответа

I'm use in my android project gson library:

compile ''

I'm use it not in app module, but in my android library and this library added to project. Only several classes (groupA) used gson. Android library is common library and used in several android projects, but in current android project do not used classes from groupA.

I have in build.gradle of app:

android {
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), ''

I build release apk and decompile classes.dex. I do not find classes groupA in apk. It's ok. proguard remove unused code.

Unfortunately I see gson classes. But why? Why proguard do not remove gson classes? gson really do not used in release version of project.

Автор: Yura Shinkarev Источник Размещён: 08.11.2019 11:26

Ответы (2)

0 плюса

I think you should have a look at the proguard file of gson which is included in each build: Recognize the remaining classes there?

Автор: and_dev Размещён: 20.08.2016 02:59

0 плюса

Why proguard do not remove gson classes?

Ask it:
Use the proguard option -whyareyoukeeping to find out why the gson classes are not removed

Автор: larsgrefer Размещён: 20.08.2016 10:32
Вопросы из категории :