Android 播放服务6.5.+粒度依赖项无法正常工作
更新:根据请求,build.gradle中的整个依赖项声明、JAR列表以及包含的库项目的依赖项都列在问题的底部 我正在做一个项目,它使用Google Play Services 7.0.0版的位置、gcm、广告和身份组件 我在应用程序模块的build.gradle中定义了它们:Android 播放服务6.5.+粒度依赖项无法正常工作,android,android-studio,gradle,google-play-services,dependency-management,Android,Android Studio,Gradle,Google Play Services,Dependency Management,更新:根据请求,build.gradle中的整个依赖项声明、JAR列表以及包含的库项目的依赖项都列在问题的底部 我正在做一个项目,它使用Google Play Services 7.0.0版的位置、gcm、广告和身份组件 我在应用程序模块的build.gradle中定义了它们: compile 'com.google.android.gms:play-services-location:7.0.0' compile 'com.google.android.gms:play-services-ad
compile 'com.google.android.gms:play-services-location:7.0.0'
compile 'com.google.android.gms:play-services-ads:7.0.0'
compile 'com.google.android.gms:play-services-identity:7.0.0'
compile 'com.google.android.gms:play-services-gcm:7.0.0
注意:我不知道它是否相关,我不认为它相关,但该项目还包括两个附加的库模块,其中一个将上面的子集声明为依赖项:
compile 'com.google.android.gms:play-services-location:7.0.0'
compile 'com.google.android.gms:play-services-ads:7.0.0'
compile 'com.google.android.gms:play-services-identity:7.0.0'
不过,在尝试构建应用程序后,由于超出了64k方法计数限制,索引失败。我对此有点怀疑,因为在谷歌的优秀员工引入细粒度依赖关系管理之前,我使用了。这种方法效果很好,并且没有超出64k方法的限制
所以现在,我不情愿地将multi-dex引入到项目中,最终能够构建一个.apk,并使用中引起我注意的方法按包计数
结果如下:
google: 18687
ads: 127
mediation: 96
admob: 23
customevent: 41
android: 11873
gms: 11873
actions: 4
ads: 387
doubleclick: 84
identifier: 22
mediation: 75
admob: 2
customevent: 48
purchase: 16
search: 81
analytics: 656
ecommerce: 34
auth: 78
common: 1611
api: 409
data: 141
images: 100
internal: 580
safeparcel: 76
dynamic: 213
gcm: 35
identity: 86
intents: 75
model: 41
internal: 4914
location: 516
places: 232
ui: 7
maps: 2395
internal: 822
model: 1020
internal: 505
security: 12
tagmanager: 955
common: 5798
annotations: 3
base: 558
internal: 11
collect: 4195
io: 299
net: 72
primitives: 383
util: 288
concurrent: 288
gson: 889
annotations: 5
internal: 485
bind: 284
reflect: 18
stream: 102
TL;博士
Play服务被列为具有超过18k的方法,并且似乎还包括一些我在build.gradle中从未定义为依赖项的组件,例如maps
然后,我使用Jake Wharton的文章中提到的方法,直接从android sdk linux/extras/google/m2repository/com/google/android/gms/play services中一个接一个地为我使用的组件编制了索引
结果如下:
Base:
Read in 3592 method IDs.
<root>: 3592
: 6
android: 420
accounts: 5
app: 62
content: 71
pm: 12
res: 9
database: 21
graphics: 42
drawable: 21
net: 11
os: 102
support: 56
v4: 56
app: 45
content: 4
util: 7
text: 1
util: 22
view: 4
widget: 23
com: 2831
google: 2831
android: 2831
gms: 2831
actions: 4
auth: 78
common: 1611
api: 409
data: 141
images: 100
internal: 580
safeparcel: 76
dynamic: 213
internal: 913
security: 12
java: 324
io: 25
lang: 143
ref: 2
reflect: 13
math: 2
nio: 17
util: 137
concurrent: 26
atomic: 4
locks: 7
regex: 6
org: 11
json: 11
Overall method count: 3592
---
Location:
Read in 1554 method IDs.
<root>: 1554
android: 65
app: 1
content: 13
location: 3
net: 1
os: 41
text: 1
util: 5
com: 1417
google: 1417
android: 1417
gms: 1417
common: 75
api: 13
data: 8
internal: 53
safeparcel: 36
internal: 833
location: 505
places: 232
ui: 7
maps: 4
model: 4
java: 72
lang: 31
util: 41
concurrent: 1
Overall method count: 1554
---
GCM:
Read in 72 method IDs.
<root>: 72
android: 27
app: 2
content: 16
pm: 1
os: 8
util: 1
com: 24
google: 24
android: 24
gms: 24
gcm: 24
java: 21
io: 1
lang: 12
util: 8
concurrent: 5
atomic: 2
Overall method count: 72
---
Ads:
Read in 3878 method IDs.
<root>: 3878
android: 471
app: 50
content: 75
pm: 5
res: 7
database: 13
sqlite: 7
graphics: 12
drawable: 1
location: 4
media: 5
net: 25
os: 67
provider: 1
telephony: 3
text: 2
util: 16
view: 67
webkit: 64
widget: 67
com: 3059
google: 3059
ads: 127
mediation: 96
admob: 23
customevent: 41
android: 2932
gms: 2932
ads: 353
doubleclick: 84
mediation: 75
admob: 2
customevent: 48
purchase: 16
search: 81
analytics: 2
common: 39
internal: 37
safeparcel: 27
dynamic: 5
internal: 2533
java: 318
io: 16
lang: 126
ref: 2
reflect: 3
math: 7
net: 23
security: 11
spec: 1
text: 2
util: 133
concurrent: 28
atomic: 7
org: 30
json: 30
Overall method count: 3878
---
Identity
Read in 179 method IDs.
<root>: 179
android: 34
accounts: 1
app: 2
content: 5
os: 23
text: 1
util: 2
com: 135
google: 135
android: 135
gms: 135
common: 28
api: 4
internal: 21
safeparcel: 15
identity: 75
intents: 75
model: 41
internal: 32
java: 10
lang: 6
util: 4
Overall method count: 179
TOTAL: 9275
以下是值得购买的罐子列表:
adjust-android-4.0.2.jar
amazon-in-app-purchasing-1.0.3.jar
android-support-v7-recyclerview.jar
DistimoSDK.jar
eventbus-2.2.1.jar
FlurryAnalytics_3.3.2.jar
httpmime-4.1.2.jar
MobileAppTracker-3.0.jar
plasma-1.95.0.jar
SKMaps.jar
socialauth-4.3.jar
socialauth-android-3.0.jar
以下是包含的两个库项目的build.gradle脚本的依赖项:
compile files('libs/videoadsdk.jar')
compile files('libs/openudidandroid.jar')
compile 'com.google.android.gms:play-services-location:7.0.0'
compile 'com.google.android.gms:play-services-ads:7.0.0'
compile 'com.google.android.gms:play-services-identity:7.0.0'
及
第二个是Facebook,它的libs目录中有Bolts.jar
希望这有帮助 @Jared,很抱歉刚才才看到你的评论。我还有其他几个依赖项,build.gradle和as jar中都有,明天我会列出它们,因为现在已经是半夜了:我之所以在这里只提到Play服务,是因为它们有最高的方法计数,当使用粒度依赖项时,产生的apk似乎不符合这种粒度。您的应用程序中确实存在大量依赖项。我可以看一看,试着剪掉一些。你怎么会得到这么多?你刚开始做这个吗?实际上这不是一个个人项目,而是一个相当大和复杂的生产应用程序,目前的安装基数超过10万台设备。代码库现在已经有5年的历史了,但在过去的6个月里,我领导了大量的重构和重新设计工作,因此我知道,事实上它并没有膨胀,所有的依赖关系实际上都在生产代码中使用。这就是为什么我特别询问Play服务的原因,因为当查看.apk中的实际结果时,它们的细粒度依赖关系管理似乎不像广告中所宣传的那样有效。那么,你就会明白,为什么我不能简单地将源代码交给修补程序:我从未要求提供源代码。
compile files('libs/videoadsdk.jar')
compile files('libs/openudidandroid.jar')
compile 'com.google.android.gms:play-services-location:7.0.0'
compile 'com.google.android.gms:play-services-ads:7.0.0'
compile 'com.google.android.gms:play-services-identity:7.0.0'
dependencies {
compile 'com.android.support:support-v4:22.0.0'
}