尝试向我们现有的 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/