java.util.concurrent.ExecutionException:com.android.builder.internal.aapt.v2.Aapt2Exception:Android资源链接失败flutter_youtube

时间:2019-02-20 16:33:51

标签: java android xml gradle flutter

我正在尝试使用“ flutter build apk”构建项目,并且遇到以下错误:

在我的项目中,我使用的是flutter_youtube插件:flutter_youtube:^ 1.1.4

我不确定此错误的含义以及如何解决。

  
    

失败:构建失败,并出现异常。

  
     
      
  • 出了什么问题:任务':flutter_youtube:verifyReleaseResources'的执行失败。

         
        

    java.util.concurrent.ExecutionException:com.android.builder.internal.aapt.v2.Aapt2Exception:Android资源     链接失败输出:     C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ merged \ release \ values-v28 \ values-v28.xml:7:错误:未找到资源android:attr / dialogCornerR adius。
        C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ merged \ release \ values-v28 \ values-v28.xml:11:     错误:找不到资源android:attr / dialogCornerRadius。
        C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ merged \ release \ values \ values.xml:964:     错误:未找到资源android:attr / fontVariationSettings。
        C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ merged \ release \ values \ values.xml:965:     错误:找不到资源android:attr / ttcIndex。错误:失败     链接参考。

      
         

    命令:   C:\ Users \ demo.gradle \ caches \ transforms-1 \ files-1.1 \ aapt2-3.2.1-4818971-windows.jar \ 6c5c55067bc3e37332d1bee0d534dc21 \ aapt2-3.2.1-4818971-windows \ aapt2.exe   链接-I \         C:\ Users \ demo \ AppData \ Local \ Android \ sdk \ platforms \ android-27 \ android.jar \          - 表现\         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ aapt_friendly_merged_manifests \ release \ processReleaseManifest \ aapt \ AndroidManifest.xml \         -o \         C:\ Users \ demo \ AppData \ Local \ Temp \ aapt-2465429262595787253-out \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ anim_abc_fade_in.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ anim_abc_fade_out.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ anim_abc_grow_fade_in_from_bottom.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ anim_abc_popup_enter.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ anim_abc_popup_exit.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ anim_abc_shrink_fade_out_from_bottom.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ anim_abc_slide_in_bottom.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ anim_abc_slide_in_top.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ anim_abc_slide_out_bottom.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ anim_abc_slide_out_top.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ anim_abc_tooltip_enter.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ anim_abc_tooltip_exit.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ color-v21_abc_btn_colored_borderless_text_material.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ color-v23_abc_btn_colored_borderless_text_material.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ color-v23_abc_btn_colored_text_material.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ color-v23_abc_color_highlight_material.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ color-v23_abc_tint_btn_checkable.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ color-v23_abc_tint_default.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ color-v23_abc_tint_edittext.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ color-v23_abc_tint_seek_thumb.xml.flat \         -R \         C:\ Users \ demo \ AndroidStudioProjects \ flutter_new \ build \ flutter_youtube \ intermediates \ res \ compiled \ release \ color-v23_abc_tint_spinner.xml.flat \

  •   

这是我的应用程序gradle:

  def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28
    buildToolsVersion  '28'

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.demo"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    /*configurations.all {
        resolutionStrategy.force 'com.android.support:support-compat:27.1.1'
        resolutionStrategy.force 'com.android.support:appcompat-v7:27.1.1'
        resolutionStrategy.force 'com.android.support:support-v4:27.1.1'
        resolutionStrategy.force 'com.android.support:support-annotations:27.1.1'


    }*/
}

flutter {
    source '../..'
}

dependencies {

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    api 'com.google.firebase:firebase-core:16.0.0'
    api "android.arch.core:runtime:1.1.1"
    api "android.arch.core:common:1.1.1"
    api 'androidx.multidex:multidex:2.0.0'
    api 'androidx.fragment:fragment:1.0.0'
    api 'com.google.android.material:material:1.0.0'

}

apply plugin: 'com.google.gms.google-services'

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '28.0.0'
            }
        }
    }
}

这是我的pubspec.yaml:

    name: demo
description: A new Flutter project.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# Read more about versioning at semver.org.
version: 1.0.0+1

environment:
  sdk: ">=2.0.0-dev.68.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  cloud_firestore: 0.9.0+1 # add dependency for Firebase Core
  share:
      git:
       url: https://github.com/d-silveira/flutter-share.git
  file_picker: ^1.1.1
  carousel_pro: ^0.0.13
  font_awesome_flutter: 8.2.0
  path_provider: ^0.4.0
  flutter_youtube: ^1.1.4
  shared_preferences: ^0.4.0
  firebase_core: ^0.3.0
  cached_network_image: ^0.5.1
  clippy_flutter: 1.0.0
  url_launcher: 5.0.1
  material_design_icons_flutter: 3.1.3493

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  english_words: ^3.1.5
dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_launcher_icons: 0.7.0

flutter_icons:
  android: true
  ios: true

# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.io/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.io/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  fonts:
    - family: MyFlutterApp
      fonts:
        - asset: fonts/MyFlutterApp.ttf
    - family: Lato
      fonts:
        - asset: fonts/Lato-LightItalic.ttf
    - family: LatoSemiBoldItalic
      fonts:
        - asset: fonts/Lato-SemiBoldItalic.ttf

  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.io/custom-fonts/#from-packages

2 个答案:

答案 0 :(得分:1)

在Android Studio中打开您的项目。在左侧,转到您添加的每个依赖项项目,打开build.gradle文件。每个“ compileSdkVersion”都应该为28。这为我解决了这个问题!

答案 1 :(得分:0)

./android/app/build.gradlecompileSdkVersion更新到28中。您的其中一个库的项目引用的资源仅添加到API 28中,因此您无法继续使用版本27。