【发布时间】:2021-06-22 15:13:49
【问题描述】:
我正在创建一个颤振应用程序,并且正在尝试针对 Android 进行测试。当我打开模拟器时,它运行正常,但是当我尝试运行我的应用程序时,我得到了这个错误......谁能帮忙解决?它在我的 iPhone 上的 Xcode 中完美运行,但似乎无法在 Android 上运行...
Launching lib/main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... FAILURE: Build failed with an exception.
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... * What went wrong:
Running Gradle task 'assembleDebug'... Execution failed for task ':app:processDebugResources'.
Running Gradle task 'assembleDebug'... > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Running Gradle task 'assembleDebug'... > Android resource linking failed
Running Gradle task 'assembleDebug'... /Users/ragz/.gradle/caches/transforms-2/files-2.1/554200784d0157df45da8212b6e09519/play-services-ads-lite-19.7.0/AndroidManifest.xml:27:5-43:15: AAPT: error: unexpected element found in .
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... * Try:
Running Gradle task 'assembleDebug'... Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... * Get more help at https://help.gradle.org
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... BUILD FAILED in 4m 29s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 305.2s
The build failed likely due to AndroidX incompatibilities in a plugin.
The tool is about to try using Jetifier to solve the incompatibility.
Building plugin flutter_tts...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 87.4s
*********************************************************
WARNING: This version of flutter_tts will break your Android build if it or its dependencies aren't compatible with AndroidX.
See for more information on the problem and how to fix it.
This warning prints for all Android build failures. The real root cause of the error may be unrelated.
*********************************************************
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'flutter_tts'.
SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/ragz/.pub-cache/hosted/pub.dartlang.org/flutter_tts-3.0.0/android/local.properties'.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 1m 24s
Exception: The plugin flutter_tts could not be built due to the issue
above.
【问题讨论】:
-
你能提供你的 Flutter 医生吗?
-
运行
flutter doctor并粘贴输出。看起来没有定义ANDROID_SDK_ROOT变量。 -
当然,发送颤振医生的输出。
-
@Doc,没有 ANDROID_SDK_ROOT 变量是什么意思?我该怎么做才能改变它???到目前为止,这是问题的根源吗?
-
对我来说看起来不错。问题似乎与 androidX 兼容性有关。你的 gradle 文件中需要
android.useAndroidX=true android.enableJetifier=true。搜索如何修复 androidX 问题。
标签: android flutter gradle visual-studio-code android-emulator