简体   繁体   English

构建gradle模块android studio中的错误

[英]error in build gradle module android studio

在此处输入图片说明

I have an error in the following code: 我在以下代码中有一个错误:

{
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.android.support:recyclerview-v7:22.0.0'
    compile 'com.google.android.gms:play-services:9.0.0'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
}

Screenshot https://i.stack.imgur.com/7gkOM.png The error is: 截图https://i.stack.imgur.com/7gkOM.png错误是:

Gradle 2.2.0 is using Gradle 2.2.0正在使用

What could be the problem? 可能是什么问题呢?

Error log: 错误日志:

Information:Gradle tasks [:Avasarangal:generateDebugSources, :Avasarangal:mockableAndroidJar, :Avasarangal:prepareDebugUnitTestDependencies, :Avasarangal:generateDebugAndroidTestSources]
E:\MY ANDROID SOURSE CODE\railway\orginal\Avasarangal\src\main\res\menu\menu_search.xml
Error:(7, 23) No resource found that matches the given name (at 'icon' with value '@drawable/abc_ic_search_api_mtrl_alpha').
E:\MY ANDROID SOURSE CODE\railway\orginal\Avasarangal\src\main\res\menu\search.xml
Error:(7, 23) No resource found that matches the given name (at 'icon' with value '@drawable/abc_ic_search_api_mtrl_alpha').
E:\MY ANDROID SOURSE CODE\railway\orginal\Avasarangal\build\intermediates\res\merged\debug\menu\menu_search.xml
Error:(7, 23) No resource found that matches the given name (at 'icon' with value '@drawable/abc_ic_search_api_mtrl_alpha').
E:\MY ANDROID SOURSE CODE\railway\orginal\Avasarangal\build\intermediates\res\merged\debug\menu\search.xml
Error:(7, 23) No resource found that matches the given name (at 'icon' with value '@drawable/abc_ic_search_api_mtrl_alpha').
Error:Execution failed for task ':Avasarangal:processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
Information:BUILD FAILED
Information:Total time: 1 mins 59.967 secs
Information:5 errors
Information:0 warnings
Information:See complete output in console

You need to upgrade your compileSdkVersion , BuildToolsVersion , targetSdkVersion , and support library to use the more recent version. 您需要升级compileSdkVersionBuildToolsVersiontargetSdkVersionsupport library以使用最新版本。 You can try using version 26. You should not use Google Play Service version >= 9.0 with support library <= 24 because there is compatibility issue (more at https://stackoverflow.com/a/46616652/4758255 ) 您可以尝试使用版本26。您不应将Google Play服务版本> = 9.0与支持库<= 24一起使用,因为存在兼容性问题(有关更多信息, 访问https://stackoverflow.com/a/46616652/4758255

android {

  compileSdkVersion 26
  buildToolsVersion 26.0.2

  defaultConfig {
    minSdkVersion 16
    targetSdkVersion 26
  }
  ...
}

dependencies {
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:recyclerview-v7:26.1.0'
    compile 'com.google.android.gms:play-services:10.0.1'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
}

this problem will appear when try to compile lib version that not compatible with the compileSdkVersion ,your problem will solve if you add the google repository . 尝试编译compileSdkVersion不兼容的lib版本时,将出现此问题,如果您添加google信息库,则将解决您的问题。

open bulid.gradle in main project folder and add the following code in allprojects { 在主项目文件夹中打开bulid.gradle,然后在所有项目中添加以下代码{

repositories {
        jcenter()
        google()
    }
}

I try to using this and solve my problem 我尝试使用它来解决我的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM