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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM