错误:找不到与给定名称匹配的资源(在'src'处,值为'@ drawable / googleg_standard_color_18')

时间:2017-09-24 00:21:33

标签: javascript android react-native android-resources react-native-android

首先,我仔细查看并尝试了各种资源未找到的帖子,但仍然没有找到针对这些错误的工作修复,我不确定为什么会出现,因为我上次启动应用程序,它建好了。

enter image description here

错误:(16,30)找不到与给定名称匹配的资源('src'的值为'@ drawable / googleg_disabled_color_18')。

错误:(9,30)找不到与给定名称匹配的资源('src'的值为'@ drawable / googleg_standard_color_18')。

以下是gradle的样子

android {
compileSdkVersion 25
buildToolsVersion '25.0.0'

defaultConfig {
    applicationId "com.moveapps"
    minSdkVersion 16
    targetSdkVersion 23
    multiDexEnabled true
    versionCode 1
    versionName "1.1.0"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
}

非常感谢任何帮助或建议!提前致谢!

问题的核心是我不太明白这里的问题,所以如果有人能指出我可以阅读更多关于这类问题的内容,我很想知道修复背后的原因。

干杯,

编辑:添加Package.json文件

{
  "name": "moveapp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
  "start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
 },
"dependencies": {
"async": "^2.4.0",
"firebase": "^3.9.0",
"images": "^3.0.0",
"lodash": "^4.17.4",
"moment": "^2.18.1",
"react": "15.4.1",
"react-native": "^0.41.2",
"react-native-app-intro": "^1.1.5",
"react-native-apple-healthkit-rn0.40": "^0.2.1-2",
"react-native-chart": "git+https://git@github.com/robcalcroft/react-native-chart.git",
"react-native-communications": "^2.2.1",
"react-native-confetti": "0.0.4",
"react-native-fbsdk": "^0.5.0",
"react-native-fcm": "^6.2.3",
"react-native-firestack": "^2.3.9",
"react-native-google-fit": "^0.2.0",
"react-native-modal-picker": "0.0.16",
"react-native-progress": "^3.2.0",
"react-native-router-flux": "3.37.0",
"react-native-scrollable-tab-view": "^0.7.2",
"react-native-search-bar": "^3.0.0",
"react-native-searchbar": "^1.10.0",
"react-native-vector-icons": "^4.1.1",
"react-redux": "^5.0.2",
"redux": "^3.6.0",
"redux-persist": "^4.7.1",
"redux-thunk": "^2.2.0",
"tipsi-stripe": "^3.7.0",
"uuid": "^3.0.1"
  },
 "devDependencies": {
 "babel-jest": "18.0.0",
 "babel-preset-react-native": "1.9.1",
 "eslint-config-rallycoding": "^3.2.0",
 "jest": "18.1.0",
 "react-test-renderer": "15.4.1"
  },
"jest": {
"preset": "react-native"
 }
}

2 个答案:

答案 0 :(得分:0)

通常,如果您没有安装相同版本的SDK构建工具,则会发生此错误,因此您需要安装buildToolsVersion' 25.0.0'但根据您的package.json依赖关系,您需要将android/app/build.gradle更改为此类

android {

  compileSdkVersion 23
  buildToolsVersion "23.0.1"

  defaultConfig {
    applicationId "com.moveapps"
    minSdkVersion 16
    targetSdkVersion 22
    multiDexEnabled true
    versionCode 1
    versionName "1.1.0"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
}

android/build.gradle就像这样

buildscript {

  dependencies {
      classpath 'com.android.tools.build:gradle:2.2.3' // this is the correct version for build tool

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    //        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
   }
}

也不建议更新反应原生android项目抛出android工作室,因为它会出现案例错误

答案 1 :(得分:0)

所以最后,按照@mohamed Kahlil的建议,我将构建工具版本降级为25到23.0.1。同样,将compileSDK从25改为23。然而,这导致了谷歌服务之间的其他依赖性错误。

首先,我强制所有我发现的google play服务和firebase版本都是我使用的库(fcm等)依赖于10.0.1,但它仍然会产生冲突的错误。直到我找到这个媒体帖子:

https://medium.com/@suchydan/how-to-solve-google-play-services-version-collision-in-gradle-dependencies-ef086ae5c75f

建议通过所有gradle设置,我发现冲突在游戏服务地图,游戏服务钱包和游戏服务身份(即使我没有实际利用这个)。一旦我强迫这三个版本的编译版本,应用程序构建没有任何问题。

谢谢Mohamed帮助我回到正确的方向!

这是我添加的示例代码

` android {
   -    compileSdkVersion 25
   -    buildToolsVersion '25.0.0'
   +    compileSdkVersion 23
   +    buildToolsVersion '23.0.1'

     defaultConfig {
         applicationId "com.moveapps"
         minSdkVersion 16
  -        targetSdkVersion 23
  +        targetSdkVersion 22
         multiDexEnabled true
         versionCode 1
         versionName "1.1.0"
   @@ -149,20 +149,70 @@ repositories {

  dependencies {
     compile project(':tipsi-stripe')
 -    compile project(':react-native-google-fit')
     compile project(':react-native-fbsdk')
 -    compile project(':react-native-fcm')
-    compile project(':react-native-firestack')
+
+    compile(project(':react-native-google-fit')){
+        exclude group: 'com.google.android.gms', module: 'play-services-auth'
+        exclude group: 'com.google.android.gms', module: 'play-services-fitness'
+    }
+
+    compile(project(':react-native-fcm')){
+        exclude group: 'com.google.firebase', module: 'firebase-messaging'
+        exclude group: 'com.google.firebase', module: 'firebase-core'
+    }
+
+    compile(project(':react-native-firestack')){
+        exclude group: 'com.google.firebase', module: 'firebase-messaging'
+        exclude group: 'com.google.firebase', module: 'firebase-core'
+        exclude group: 'com.google.firebase', module: 'firebase-auth'
+        exclude group: 'com.google.firebase', module: 'firebase-analytics'
+        exclude group: 'com.google.firebase', module: 'firebase-storage'
+
+        exclude group: 'com.google.android.gms', module: 'play-services-base'
+        exclude group: 'com.google.android.gms', module: 'play-services-gcm'
+    }
+
+    compile('com.google.android.gms:play-services-auth:10.0.1') {
+        force = true;
+    }
+    compile('com.google.android.gms:play-services-fitness:10.0.1') {
+        force = true;
+    }
+
+    compile('com.google.android.gms:play-services-base:10.0.1') {
+        force = true;
+    }
+
+    compile('com.google.android.gms:play-services-gcm:10.0.1') {
+        force = true;
+    }
+
+    compile('com.google.android.gms:play-services-identity:10.0.1') {
+        force = true;
+    }
+
+    compile('com.google.android.gms:play-services-maps:10.0.1') {
+        force = true;
+    }
+
+    compile('com.google.android.gms:play-services-wallet:10.0.1') {
+        force = true;
+    }
+
     compile('com.google.firebase:firebase-core:10.0.1') {
         force = true;
     }
     compile('com.google.firebase:firebase-messaging:10.0.1') {
         force = true;
     }
-    compile('com.google.android.gms:play-services-gcm:10.0.1') {
+
+    compile('com.google.firebase:firebase-auth:10.0.1') {
         force = true;
     }
-    compile('com.google.android.gms:play-services-base:10.0.1') {
+    compile('com.google.firebase:firebase-analytics:10.0.1') {
+        force = true;
+    }
+    compile('com.google.firebase:firebase-storage:10.0.1') {
         force = true;
     }`