【问题标题】:How to fix the gradle build error in android studio?如何修复 android studio 中的 gradle build 错误?
【发布时间】:2018-07-07 09:24:08
【问题描述】:

我刚刚在 Android Studio 中创建了一个新项目,在 gradle 构建之后它显示以下错误。我不知道为什么会这样。

Information:Gradle tasks [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]
C:\Users\DEVPC\.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.1.0.aar\4a763fb9bbd72a5413be967c96404ad9\res\values-v11\values-v11.xml
Error:(67, 5) error: resource style/Widget.AppCompat.Button.Borderless (aka com.asif047.includinglibrary2:style/Widget.AppCompat.Button.Borderless) not found.
Error:(67, 5) error: resource style/Widget.AppCompat.ButtonBar.AlertDialog (aka com.asif047.includinglibrary2:style/Widget.AppCompat.ButtonBar.AlertDialog) not found.
Error:(72, 5) error: resource style/Widget.AppCompat.ButtonBar.AlertDialog (aka com.asif047.includinglibrary2:style/Widget.AppCompat.ButtonBar.AlertDialog) not found.
Error:(72, 5) error: resource style/Widget.AppCompat.Button.Borderless (aka com.asif047.includinglibrary2:style/Widget.AppCompat.Button.Borderless) not found.
Error:(77, 5) error: resource style/Widget.AppCompat.ButtonBar.AlertDialog (aka com.asif047.includinglibrary2:style/Widget.AppCompat.ButtonBar.AlertDialog) not found.
Error:(77, 5) error: resource style/Widget.AppCompat.Button.Borderless (aka com.asif047.includinglibrary2:style/Widget.AppCompat.Button.Borderless) not found.
C:\Users\DEVPC\.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.1.0.aar\4a763fb9bbd72a5413be967c96404ad9\res\values-v21\values-v21.xml
Error:(49, 5) error: resource string/abc_font_family_title_material (aka com.asif047.includinglibrary2:string/abc_font_family_title_material) not found.
Error:(49, 5) error: resource dimen/abc_text_size_menu_header_material (aka com.asif047.includinglibrary2:dimen/abc_text_size_menu_header_material) not found.
Error:(111, 5) error: resource dimen/abc_floating_window_z (aka com.asif047.includinglibrary2:dimen/abc_floating_window_z) not found.
Error:resource style/Theme.AppCompat.Light.DarkActionBar (aka com.asif047.includinglibrary2:style/Theme.AppCompat.Light.DarkActionBar) not found.
E:\E-COMMERCE NEW\IncludingLibrary2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v14\values-v14.xml
Error:(4) error: resource dimen/abc_text_size_button_material (aka com.asif047.includinglibrary2:dimen/abc_text_size_button_material) not found.
Error:(4) resource dimen/abc_text_size_button_material (aka com.asif047.includinglibrary2:dimen/abc_text_size_button_material) not found.
Error:resource style/Base.Theme.AppCompat.Dialog.FixedSize (aka com.asif047.includinglibrary2:style/Base.Theme.AppCompat.Dialog.FixedSize) not found.
Error:resource style/TextAppearance.AppCompat (aka com.asif047.includinglibrary2:style/TextAppearance.AppCompat) not found.
Error:resource style/Base.Theme.AppCompat.Light.Dialog.FixedSize (aka com.asif047.includinglibrary2:style/Base.Theme.AppCompat.Light.Dialog.FixedSize) not found.
Error:resource style/Base.V7.Theme.AppCompat.Light.Dialog (aka com.asif047.includinglibrary2:style/Base.V7.Theme.AppCompat.Light.Dialog) not found.
Error:resource style/Base.V7.Theme.AppCompat.Dialog (aka com.asif047.includinglibrary2:style/Base.V7.Theme.AppCompat.Dialog) not found.
Error:resource style/Base.V7.ThemeOverlay.AppCompat.Dialog (aka com.asif047.includinglibrary2:style/Base.V7.ThemeOverlay.AppCompat.Dialog) not found.
E:\E-COMMERCE NEW\IncludingLibrary2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v11\values-v11.xml
Error:(63) resource style/Widget.AppCompat.ButtonBar.AlertDialog (aka com.asif047.includinglibrary2:style/Widget.AppCompat.ButtonBar.AlertDialog) not found.
Error:(64) resource style/Widget.AppCompat.Button.Borderless (aka com.asif047.includinglibrary2:style/Widget.AppCompat.Button.Borderless) not found.
Error:(68) resource style/Widget.AppCompat.ButtonBar.AlertDialog (aka com.asif047.includinglibrary2:style/Widget.AppCompat.ButtonBar.AlertDialog) not found.
Error:(69) resource style/Widget.AppCompat.Button.Borderless (aka com.asif047.includinglibrary2:style/Widget.AppCompat.Button.Borderless) not found.
Error:(73) resource style/Widget.AppCompat.ButtonBar.AlertDialog (aka com.asif047.includinglibrary2:style/Widget.AppCompat.ButtonBar.AlertDialog) not found.
Error:(74) resource style/Widget.AppCompat.Button.Borderless (aka com.asif047.includinglibrary2:style/Widget.AppCompat.Button.Borderless) not found.
Error:resource style/Base.V7.Widget.AppCompat.AutoCompleteTextView (aka com.asif047.includinglibrary2:style/Base.V7.Widget.AppCompat.AutoCompleteTextView) not found.
Error:resource style/Base.V7.Widget.AppCompat.EditText (aka com.asif047.includinglibrary2:style/Base.V7.Widget.AppCompat.EditText) not found.
Error:resource style/Base.V7.Theme.AppCompat (aka com.asif047.includinglibrary2:style/Base.V7.Theme.AppCompat) not found.
E:\E-COMMERCE NEW\IncludingLibrary2\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v21\values-v21.xml
Error:(50) resource dimen/abc_text_size_menu_header_material (aka com.asif047.includinglibrary2:dimen/abc_text_size_menu_header_material) not found.
Error:(49) resource string/abc_font_family_title_material (aka com.asif047.includinglibrary2:string/abc_font_family_title_material) not found.
Error:(113) resource dimen/abc_floating_window_z (aka com.asif047.includinglibrary2:dimen/abc_floating_window_z) not found.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processDebugResources'.
Failed to execute aapt

这里给出了 gradle 文件信息:

> apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.asif047.includinglibrary2"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    } }

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'

}

【问题讨论】:

  • 放入gradle文件和gradle版本详情。
  • 我已经编辑并给出了gradle文件信息@AbhayKoradiya
  • 你试过cleanre-build项目吗?
  • 检查here

标签: android android-gradle-plugin android-support-library android-styles


【解决方案1】:

此错误可能有多种原因。由于我不确定您使用的项目级别 gradle 和 gradle 版本,因此如果您使用任何旧版本,我建议您更新您的 gradle。有一个SO post 可能对你有帮助。

【讨论】:

    【解决方案2】:

    我遇到了这个问题,并且我正在使用修改后的 android.jar(它显示了所有隐藏的 API)。 我不使用单元测试,也没有明显的方法可以在 Android Studio 2.2.2 中禁用它,所以我找到了解决这个问题的方法:

    1. Go to File -> Settings -> Build, Execution, Deployment -> Compiler
    2. Add to "Command-line Options":
             -x :app:prepareReleaseUnitTestDependencies -x :app:mockableAndroidJar -x 
             :app:compileReleaseUnitTestSources
    3. Press "OK" and try to Rebuild Project again.
    

    现在单元测试编译任务将永远被跳过,不会抛出任何错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多