1,問題
Build fails with an error:
Execution failed for task ':react-native-google-analytics-bridge:compileDebugJavaWithJavac'.
package com.google.android.gms.tagmanager does not exist
import com.google.android.gms.tagmanager.TagManager;
RN android 突然報錯,瀏覽查閱一大堆無果,隔了兩天,又查了一下,找到一個解決方案 。
這個問題,是由於google play services 更新,並且自己代碼又用‘+’指定的 版本號導致的。更新之后類不在原來的地方了,所以報缺失包的錯。
2,解決
在 android/build.gradle里添加下面,start 和end 之間的代碼,完美的解決了這個問題。
allprojects {
repositories {
//start here
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.google.android.gms') {
details.useVersion '12.0.1'
}
if (requested.group == 'com.google.firebase') {
details.useVersion '12.0.1'
}
}
}
//end
jcenter()
maven {
url "https://maven.google.com"
}
}
}