Flutter Release APK错误(找不到ttcIndex,找不到fontVariationSettings等)

时间:2020-10-11 21:29:56

标签: android android-studio flutter gradle dart

端子:

  D:\x\C\Flutter\rte_app>flutter build apk --release
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK
to reduce the APK size.
    To generate an app bundle, run:
        flutter build appbundle --target-platform android-arm,android-arm64,android-x64
        Learn more on: https://developer.android.com/guide/app-bundle
    To split the APKs per ABI, run:
        flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
        Learn more on:
        https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':clipboard_manager:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     C:\Users\memir\.gradle\caches\transforms-2\files-2.1\a528b13ac93e64cafa3d0480e2c93207\core-1.1.
0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not f
ound.

     C:\Users\memir\.gradle\caches\transforms-2\files-2.1\a528b13ac93e64cafa3d0480e2c93207\core-1.1.
0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcIndex not found.


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more l
og output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BU�LD FAILED in 19s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done                      19,9s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try
using Jetfier to solve the incompatibility.
Building plugin audioplayers...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done                    3,6s
Checking the license for package SDK Patch Applier v4 in C:\Users\memir\AppData\Local\Android\Sdk\pl
atforms\licenses
Warning: License for package SDK Patch Applier v4 not accepted.
Checking the license for package Android Emulator in C:\Users\memir\AppData\Local\Android\Sdk\platfo
rms\licenses
Warning: License for package Android Emulator not accepted.
Checking the license for package Android SDK Platform-Tools in C:\Users\memir\AppData\Local\Android\
Sdk\platforms\licenses
Warning: License for package Android SDK Platform-Tools not accepted.
Checking the license for package Android SDK Tools in C:\Users\memir\AppData\Local\Android\Sdk\platf
orms\licenses
Warning: License for package Android SDK Tools not accepted.
Checking the license for package Android SDK Build-Tools 28.0.3 in C:\Users\memir\AppData\Local\Andr
oid\Sdk\platforms\licenses
Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.


FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'audioplayers'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
     patcher;v4 SDK Patch Applier v4
     platform-tools Android SDK Platform-Tools
     build-tools;28.0.3 Android SDK Build-Tools 28.0.3
     tools Android SDK Tools
     emulator Android Emulator
  To build this project, accept the SDK license agreements and install the missing components using
the Android Studio SDK Manager.
  Alternatively, to transfer the license agreements from one workstation to another, see http://d.an
droid.com/r/studio-ui/export-licenses.html

  Using Android SDK: C:\Users\memir\AppData\Local\Android\Sdk\platforms

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more l
og output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUİLD FAILED in 3s


The plugin audioplayers could not be built due to the issue above.

构建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 FileNotFoundException("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'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

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

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
configurations.all {
    resolutionStrategy.eachDependency { details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '28.0.0'
            }
        }
    }
}
subprojects {
    afterEvaluate { project ->
        if (project.name == "plugin_that_causes_the_issue") {
            android {
                compileSdkVersion 28
            }
        }
    }
}

Android Build.Gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
allprojects {
    // Workaround for https://issuetracker.google.com/117900475
    // Remove when upgrading to AGP 3.4 or higher.
    configurations.matching { it.name == '_internal_aapt2_binary' }.all { config ->
        config.resolutionStrategy.eachDependency { details ->
            details.useVersion("3.5.0-alpha03-5252756")
        }
    }
}

Flutter Doctor

[√] Flutter (Channel stable, 1.20.4, on Microsoft Windows [Version 10.0.19041.508], locale tr-TR)
    • Flutter version 1.20.4 at C:\src\flutter
    • Framework revision fba99f6cf9 (4 weeks ago), 2020-09-14 15:32:52 -0700
    • Engine revision d1bc06f032
    • Dart version 2.9.2

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Users\memir\AppData\Local\Android\Sdk
    • Platform android-29, build-tools 30.0.2
    • ANDROID_HOME = C:\Users\memir\AppData\Local\Android\Sdk\platforms
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Android Studio (version 4.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 50.0.1
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.49.2)
    • VS Code at C:\Users\memir\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.14.1

[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.

项目结构: http://prntscr.com/uxcqp2

项目结构问题:模块rte_app_android:依赖项列表中的无效项“ Flutter for Android”

我可以获取调试apk,但无法获取发行版本(我也不知道是否可能)。

1 个答案:

答案 0 :(得分:0)

我删除了剪贴板管理器并将文件传输到一个新项目,现在它可以工作了。