0

I'm compiling a project using proguard with Google Play Services 7.5, Android 21 and Support v4 library. My method count is higher if i compile it with android studio than if i compile it with eclipse. I used a program called dex-method-count into two apks generated with both programas and i discovered that this is the reason:

AndroidStudio+gradle:

    support: 5416
        v4: 2755
            app: 594
            content: 33
            graphics: 96
                drawable: 96
            internal: 74
                view: 74
            media: 123
                session: 60
            os: 13
            text: 17
            util: 166
            view: 1024
                accessibility: 204
            widget: 615
        v7: 2661
            app: 232
            appcompat: 1
            internal: 1757
                app: 77
                text: 3
                transition: 1
                view: 628
                    menu: 536
                widget: 1047
            view: 24
            widget: 647

Eclipse + Ant:

    support: 2073
        v4: 2073
            app: 549
            content: 21
            media: 123
                session: 60
            os: 11
            util: 157
            view: 757
                accessibility: 204
            widget: 455

As you can see in the first option it is adding a lot of methods from support v7, why? how can this be avoided?

Thanks

PD: My build gradle files for the library and the application:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 'Google Inc.:Google APIs:22'
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 10
    }

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

dependencies {
    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.google.android.gms:play-services:7.5.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

the application:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'Google Inc.:Google APIs:22'
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.example.launcher"
        minSdkVersion 10
        targetSdkVersion 10
    }

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

dependencies {
    compile project(':caponateLibrary')
    compile 'com.google.android.gms:play-services:7.5.0'
}
NullPointerException
  • 36,107
  • 79
  • 222
  • 382

1 Answers1

1

com.google.android.gms:play-services has dependencies on com.google.android:wearable and com.google.android:play-services-cast. Each of those have dependecies on v7 support libraries (recyclerview-v7 and mediarouter-v7, respectively).

Unless you are using just about everything in the Play Services SDK, you will be much better served using finer-grained dependencies (see "Selectively compiling APIs into your executable" on this page). Not only will this get rid of a bunch of Play Services bloat, but it may get rid of your v7 methods, depending on what bits of Play Services you are using.

BTW, compileSdkVersion 'Google Inc.:Google APIs:22' is pointless, unless you are still using Maps V1, which would be rather surprising at this stage. compileSdkVersion 22 would be a better choice.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491