java.util.concurrent.ExecutionException:com.android.builder.internal.aapt.v2.Aapt2Exception:Android资

Posted

技术标签:

【中文标题】java.util.concurrent.ExecutionException:com.android.builder.internal.aapt.v2.Aapt2Exception:Android资源链接失败flutter_youtube【英文标题】:java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed flutter_youtube 【发布时间】:2019-07-14 10:18:12 【问题描述】:

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

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

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

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

出了什么问题:任务 ':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 链接-我\ 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

【问题讨论】:

【参考方案1】:

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


如果您不使用 Android Studio,并且您不知道您的项目中有哪些依赖项,您可以转到计算机上 Flutter 存储所有库的位置。 (在我的 Mac 上是 /Users/my_user/Tools/flutter/.pub-cache/hosted/pub.dartlang.org/)。 然后进行批量搜索并将compileSdkVersion 27 替换为compileSdkVersion 28

【讨论】:

【参考方案2】:

./android/app/build.gradle 中,将compileSdkVersiontargetSdkVersion 更新为28。您的一个库的项目所引用的资源仅添加到API 28 中,因此您不能再继续使用版本27。

【讨论】:

以上是关于java.util.concurrent.ExecutionException:com.android.builder.internal.aapt.v2.Aapt2Exception:Android资的主要内容,如果未能解决你的问题,请参考以下文章