【问题标题】:error in build gradle module android studio构建gradle模块android studio中的错误
【发布时间】:2018-02-06 23:56:50
【问题描述】:

我在以下代码中有错误:

{
    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'
}

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

Gradle 2.2.0 正在使用

可能是什么问题?

错误日志:

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

【问题讨论】:

  • 请发布完整的错误信息

标签: android android-studio gradle android-gradle-plugin


【解决方案1】:

您需要升级您的compileSdkVersionBuildToolsVersiontargetSdkVersionsupport library 才能使用更新的版本。您可以尝试使用版本 26。您不应使用支持库 = 9.0,因为存在兼容性问题(更多信息请参见 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'
}

【讨论】:

【解决方案2】:

尝试编译compileSdkVersion不兼容的lib版本时会出现此问题,如果您添加google存储库,您的问题将得到解决。

在主项目文件夹中打开 bulid.gradle 并添加以下代码 在所有项目中{

repositories {
        jcenter()
        google()
    }
}

我尝试使用它来解决我的问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-10
    • 2019-01-14
    • 2013-05-13
    • 2015-02-06
    • 2016-08-05
    相关资源
    最近更新 更多