gpt4 book ai didi

android - 为什么? AndroidStudio + Gradle = 46000方法计数VS Eclipse + Ant = 43000方法计数

转载 作者:行者123 更新时间:2023-12-03 05:15:28 25 4
gpt4 key购买 nike

我正在使用带有Google Play服务7.5,Android 21和支持v4库的proguard编译项目。如果我使用android studio进行编译,则方法计数要比如果使用eclipse进行编译的方法计数高。我将一个名为dex-method-count的程序用于由两个programas生成的两个apk中,我发现这是原因:

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

正如您在第一个选项中看到的那样,它从支持v7中添加了很多方法,为什么呢?如何避免这种情况?

谢谢

PD:我的库和应用程序的构建gradle文件:
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'])
}

应用程序:
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'
}

最佳答案

com.google.android.gms:play-services依赖于com.google.android:wearablecom.google.android:play-services-cast。它们每个都依赖于v7支持库(分别为recyclerview-v7mediarouter-v7)。

除非您使用Play Services SDK中的几乎所有功能,否则使用更细粒度的依赖项将为您提供更好的服务(请参阅this page上的“选择性地将API编译到可执行文件中”)。这不仅可以消除Play Services的膨胀,而且还可以消除v7方法,具体取决于您使用的Play Services的位。

顺便说一句,除非您仍在使用Maps V1,否则compileSdkVersion 'Google Inc.:Google APIs:22'毫无意义,这在现阶段将是非常令人惊讶的。 compileSdkVersion 22将是一个更好的选择。

关于android - 为什么? AndroidStudio + Gradle = 46000方法计数VS Eclipse + Ant = 43000方法计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32098029/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com