Ошибка при выпуске APK-версии Flutter (ttcIndex не найден, настройки шрифтов не найдены и многое другое)

#android #android-studio #flutter #gradle #dart

#Android #android-studio #flutter #gradle #dart

Вопрос:

Терминал:

   D:xCFlutterrte_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:Usersmemir.gradlecachestransforms-2files-2.1a528b13ac93e64cafa3d0480e2c93207core-1.1.
0resvaluesvalues.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not f
ound.

     C:Usersmemir.gradlecachestransforms-2files-2.1a528b13ac93e64cafa3d0480e2c93207core-1.1.
0resvaluesvalues.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:UsersmemirAppDataLocalAndroidSdkpl
atformslicenses
Warning: License for package SDK Patch Applier v4 not accepted.
Checking the license for package Android Emulator in C:UsersmemirAppDataLocalAndroidSdkplatfo
rmslicenses
Warning: License for package Android Emulator not accepted.
Checking the license for package Android SDK Platform-Tools in C:UsersmemirAppDataLocalAndroid
Sdkplatformslicenses
Warning: License for package Android SDK Platform-Tools not accepted.
Checking the license for package Android SDK Tools in C:UsersmemirAppDataLocalAndroidSdkplatf
ormslicenses
Warning: License for package Android SDK Tools not accepted.
Checking the license for package Android SDK Build-Tools 28.0.3 in C:UsersmemirAppDataLocalAndr
oidSdkplatformslicenses
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:UsersmemirAppDataLocalAndroidSdkplatforms

* 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.
  

Build 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.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:srcflutter
    • 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:UsersmemirAppDataLocalAndroidSdk
    • Platform android-29, build-tools 30.0.2
    • ANDROID_HOME = C:UsersmemirAppDataLocalAndroidSdkplatforms
    • Java binary at: C:Program FilesAndroidAndroid Studiojrebinjava
    • 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 FilesAndroidAndroid 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:UsersmemirAppDataLocalProgramsMicrosoft 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 для Android» в списке зависимостей

Я могу получить отладочный apk, но я не могу получить версию релиза (я также не уверен, возможно ли это).

Комментарии:

1. Похоже, вы не приняли условия SDK : Failed to install the following Android SDK packages as some licences have not been accepted.

2. Я выполнил оба flutter doctor --android-licenses 2 (точный путь к папке android_sdk) tools bin sdkmanager —licenses’, но, тем не менее, я получаю ту же ошибку. Прежде чем опубликовать вопрос, я перепробовал все решения, которые я понял, как это сделать.

Ответ №1:

Я удалил clipboard_manager и перенес свои файлы в новый проект, теперь он работает.