Build fails with an error: Execution failed for task ':react-native-google-analytics-bridge:compileDebugJavaWithJavac'.

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"
           }
        }
    }