android - 由于 google-play-service,无法将请求的类放入单个 dex 文件中

标签 android google-play-services wear-os

尝试向我们现有的 Android 应用添加广告,编译后我得到了这个:

Cannot fit requested classes in a single dex file. Try supplying a main-dex list.

环顾四周,建议是减少播放服务的大小,这就是我所拥有的:

implementation 'com.google.android.gms:play-services-ads:12.0.1' // newly added
implementation 'com.google.android.gms:play-services:12.0.1'

我在代码中使用了 Android Wear,所以当我减少到:

implementation 'com.google.android.gms:play-services-ads:12.0.1'
implementation 'com.google.android.gms:play-services-wearable:12.0.1'

现在我得到了:

resource style/Theme.AppCompat (...) not found. 

我尝试添加

compile "com.android.support:appcompat-v7:21.0.+"

我遇到了更多的冲突问题。我最好的解决方案是什么?我当前的解决方法是将 AppCompat 改回 Activity。将不胜感激其他答案!

最佳答案

您可以引用这个thread .尝试在应用程序 gradle 中添加此库:implementation 'com.android.support:multidex:1.0.3'。然后在app gradle的defaultConfig中添加multiDexEnabled true。也来自这个documentation ,当您的应用及其引用的库超过 65,536 个方法时,您会遇到构建错误,表明您的应用已达到 Android 构建架构的限制。

关于android - 由于 google-play-service,无法将请求的类放入单个 dex 文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49890720/

相关文章:

android - 是否可以查询Google Play服务器以了解用户是否购买了某件商品?

Android Google 登录卡在循环中

java - 为什么我的 arduino uno with xbee shield v1.4 with bluetooth bee 没有从 android 接收任何数据?

java - 我可以用一个 View 来替换mapbox android 中的图标吗?

c# - 使用 Xamarin 实现新的 Google 登录

android - 通知背景图片从未在时钟上显示

android - 将 Android Wear 模块添加到我的应用程序

Android Wear 嵌入式应用与配套应用

android - ListView flutter 中的问题开关值

android - Google HeaderGridView 问题