我将Android Studio项目升级为gradle,现在APK大15倍

时间:2016-10-25 15:36:38

标签: android android-studio gradle

我有一个较旧的项目,该项目是在Android Studio的第一个版本中编写的。除了应用程序图标之外,项目没有任何大型资产。它用作AdMob SDK 4.3.1的唯一第三方库。由此产生的签名APK为105 Kb。

现在Google要求我从AdMob SDK升级到Google Play Services SDK以继续投放广告。因此,我启动了最新版本的Android Studio,将项目转换为gradle,引用了最新的Google Play Services SDK并重新生成了已签名的SDK(发布模式)。大小为1595 Kb。

我无法弄清楚为什么它如此之大,无法找到减少它的方法。我尝试排除this回答中的库,但生成的文件大小没有变化。

我错过了什么?

这是我的gradle文件:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.1'
    }
}
apply plugin: 'android'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'com.google.android.gms:play-services-ads:9.6.1'
}


android {
    compileSdkVersion 24
    buildToolsVersion "24.0.3"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 24
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

0 个答案:

没有答案