I'm creating a flutter app, and I'm trying to test it for Android. When I open up the emulator, it runs normally, but when I try to run my app, I get this error... Can anyone help solve? It runs perfectly in Xcode on my iPhone, but doesn't seem to run on 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.
Check if your minSDKVersion 21 in build.gradle.
Here's my flutter doctor run (it seems like nothing is wrong to me, maybe there is? im not sure) -
[✓] Flutter (Channel stable, 2.0.2, on macOS 11.2 20D64 darwin-x64, locale en-GB)
• Flutter version 2.0.2 at /Users/ragz/flutter
• Framework revision 8962f6dc68 (2 weeks ago), 2021-03-11 13:22:20 -0800
• Engine revision 5d8bf811b3
• Dart version 2.12.1
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/ragz/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.4, Build version 12D4e
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.54.3)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.20.0
[✓] Connected device (2 available)
• sdk gphone x86 arm (mobile) • emulator-5554 • android-x86 • Android 11 (API
30) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome
Related
I get following exception when building flutter apk or appbundle. It happens randomly. I don't know what triggers it. How can I debug this further?
Dart snapshot generator failed with exit code -9
FAILURE: Build failed with an exception.
* Where:
Script '/var/theproject/libs/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1035
* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command '/var/theproject/libs/flutter/bin/flutter'' finished with non-zero exit value 1
* 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 6m 51s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 412.5s
Gradle task assembleRelease failed with exit code 1
Here is my flutter doctor -v result:
Flutter (Channel stable, 2.2.2, on Linux, locale en_US.UTF-8)
• Flutter version 2.2.2 at /var/theproject/libs/flutter
• Framework revision d79295af24 (6 days ago), 2021-06-11 08:56:01
-0700
• Engine revision 91c9fc8fe0
• Dart version 2.13.3
[✓] Android toolchain - develop for Android devices (Android SDK version
29.0.3)
• Android SDK at /var/theproject/libs/android-sdk-linux
• Platform android-30, build-tools 29.0.3
• Java binary at: /usr/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_282-b08)
• All Android licenses accepted.
[✗] Chrome - develop for the web (Cannot find Chrome executable at
google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome
executable.
[!] Android Studio (not installed)
• Android Studio not found; download from
https://developer.android.com/studio/index.html
(or visit
https://flutter.dev/docs/get-started/install/linux#android-setup for
detailed instructions).
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
I had the same problem, what it solved was to use variables from other class with static and not by creating a instance:
Works fine:
import file
ClassName.variable
Bug:
import file
var instance = ClassName()
instance.variable
I'm trying to build an apk running flutter build apk --split-per-abi and I'm getting this message:
Note that a week ago this wasn't happening.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\sandbox\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 646
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> The value for this property cannot be changed any further.
* 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 4s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 5,5s
Gradle task assembleRelease failed with exit code 1
I then ran flutter doctor -v to see if android and flutter were outdated.
After updating and restarting Android Studio I'm getting the same error. Any idea what could be the problem?
C:\sandbox\AndroidStudioProjects\dataps05>flutter doctor -v
[√] Flutter (Channel stable, 1.22.4, on Microsoft Windows [Versión 10.0.18363.1256], locale es-ES)
• Flutter version 1.22.4 at C:\sandbox\flutter
• Framework revision 1aafb3a8b9 (7 weeks ago), 2020-11-13 09:59:28 -0800
• Engine revision 2c956a31c0
• Dart version 2.10.4
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at C:\Users\gabri\AppData\Local\Android\Sdk
• Platform android-30, build-tools 30.0.2
• 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.1.0)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code (version 1.51.1)
• VS Code at C:\Users\gabri\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.16.0
[!] Connected device
! No devices available
! Doctor found issues in 2 categories.
Do the following for flutter doctor warnings
flutter channel dev
flutter doctor
flutter channel master
flutter doctor
and try this for your problem.
i'm runing Pop_OS! 20.10
flutter doctor -v
[✓] Flutter (Channel stable, 1.22.3, on Linux, locale en_US.UTF-8) •
Flutter version 1.22.3 at /home/samdc/DevTools/flutter • Framework
revision 8874f21 (3 months ago), 2020-10-29 14:14:35 -0700 • Engine
revision a1440ca392 • Dart version 2.10.3 • Pub download mirror
https://pub.flutter-io.cn • Flutter download mirror
https://storage.flutter-io.cn
[✓] Android toolchain - develop for Android devices (Android SDK
version 30.0.3) • Android SDK at /home/samdc/DevTools/Android/SDK •
Platform android-30, build-tools 30.0.3 • Java binary at:
/opt/android-studio/jre/bin/java • Java version OpenJDK Runtime
Environment (build
1.8.0_242-release-1644-b3-6222593) • All Android licenses accepted.
[!] Android Studio • Android Studio at /opt/android-studio ✗ Flutter
plugin not installed; this adds Flutter specific functionality. ✗ Dart
plugin not installed; this adds Dart specific functionality. •
android-studio-dir = /opt/android-studio • Java version OpenJDK
Runtime Environment (build
1.8.0_242-release-1644-b3-6222593)
[✓] VS Code (version 1.52.1) • VS Code at /usr/share/code • Flutter
extension version 3.18.1
[✓] Connected device (1 available) • Google Nexus 5 (mobile) •
192.168.56.101:5555 • android-x86 • Android 5.1 (API 22)
dart --version
Dart SDK version: 2.10.3 (stable) (Tue Oct 27 14:44:30 2020 +0100) on
"linux_x64"
java --version
openjdk 14.0.2 2020-07-14 OpenJDK Runtime Environment (build
14.0.2+12-Ubuntu-1) OpenJDK 64-Bit Server VM (build 14.0.2+12-Ubuntu-1, mixed mode, sharing)
gradle -v
Gradle 6.8
Build time: 2021-01-08 16:38:46 UTC
Revision: b7e82460c5373e194fb478a998c4fcfe7da53a7e
Kotlin: 1.4.20
Groovy: 2.5.12
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 14.0.2 (Private Build 14.0.2+12-Ubuntu-1)
OS: Linux 5.8.0-7630-generic amd64
When i try to run flutter app from terminal using flutter run i get this massege
Launching lib/main.dart on Google Nexus 5 in debug mode...
Running Gradle task 'assembleDebug'...
and it will be stuck forever .
and as the emulator i'm using genymotion
and i'm using VPN because my country is banned from using google services , and the internet speed is unstable .
and also i tried to run the app from VS Code with no luck .
i've been trying to install flutter for 2 weeks with no luck , hope find the solution
things i tried :
flutter clean
I have changed the Gradle wrapper properties distribution URL version to: 6.8-all
Edit : afyer a while of waiting the flutter run command throw this error
Launching lib/main.dart on Google Nexus 5 in debug mode... Running
Gradle task 'assembleDebug'...
Exception in thread "main" java.util.zip.ZipException: error in
opening zip file Running Gradle task 'assembleDebug'...
at java.util.zip.ZipFile.open(Native Method) Running
Gradle task 'assembleDebug'...
at java.util.zip.ZipFile.(ZipFile.java:225) Running
Gradle task 'assembleDebug'...
at java.util.zip.ZipFile.(ZipFile.java:155) Running
Gradle task 'assembleDebug'...
at java.util.zip.ZipFile.(ZipFile.java:169) Running
Gradle task 'assembleDebug'...
at org.gradle.wrapper.Install.unzip(Install.java:214) Running
Gradle task 'assembleDebug'...
at org.gradle.wrapper.Install.access$600(Install.java:27) Running
Gradle task 'assembleDebug'...
at org.gradle.wrapper.Install$1.call(Install.java:74) Running
Gradle task 'assembleDebug'...
at org.gradle.wrapper.Install$1.call(Install.java:48) Running
Gradle task 'assembleDebug'...
at
org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
Running Gradle task 'assembleDebug'...
at org.gradle.wrapper.Install.createDist(Install.java:48) Running
Gradle task 'assembleDebug'...
at
org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
Running Gradle task 'assembleDebug'...
at
org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done
470.0s (!) [!] Gradle threw an error while downloading artifacts from the network. Retrying to download... Exception in thread "main"
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:225)
at java.util.zip.ZipFile.(ZipFile.java:155)
at java.util.zip.ZipFile.(ZipFile.java:169)
at org.gradle.wrapper.Install.unzip(Install.java:214)
at org.gradle.wrapper.Install.access$600(Install.java:27)
at org.gradle.wrapper.Install$1.call(Install.java:74)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done
0.2s [!] Gradle threw an error while downloading artifacts from the network. Retrying to download... Exception: Gradle task assembleDebug
failed with exit code 1
I have dealt with this exact issue in the past, what worked for me was I uninstalled flutter sdk, android studio and all the elements I installed related to flutter and repeated the process of installing flutter and all of the components it requires. If this does not work, I suggest not using the emulator but using a physical device to run your code.
Every time I run flutter run the build always crashes
And brings this out!
Using hardware rendering with device sdk gphone x86 arm. If you notice
graphics artifacts, consider enabling software rendering with
"--enable-software-rendering". Launching lib\main.dart on sdk gphone
x86 arm in debug mode... [Fatal Error]
kotlin-stdlib-jdk7-1.3.50.pom:2:1: Content is not allowed in prolog.
[Fatal Error] kotlin-stdlib-jdk7-1.3.50.pom:2:1: Content is not
allowed in prolog.
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:checkDebugAarMetadata'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50.
Required by:
project :app
> Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50.
> Could not parse POM https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.3.50/kotlin-stdlib-jdk7-1.3.50.pom
> Content is not allowed in prolog.
> Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50.
> Could not parse POM https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.3.50/kotlin-stdlib-jdk7-1.3.50.pom
> Content is not allowed in prolog.
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 2m 59s Running Gradle task 'assembleDebug'... Running
Gradle task 'assembleDebug'... Done 191.0s
Exception: Gradle task assembleDebug failed with exit code 1
[√] Flutter (Channel dev, 1.26.0-1.0.pre, on Microsoft Windows [Version 10.0.18363.1256], locale en-US)
• Flutter version 1.26.0-1.0.pre at C:\src\flutter
• Framework revision 63062a6443 (11 days ago), 2020-12-13 23:19:13 +0800
• Engine revision 4797b06652
• Dart version 2.12.0 (build 2.12.0-141.0.dev)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Users\HP\AppData\Local\Android\Sdk
• Platform android-30, build-tools 30.0.3
• ANDROID_HOME = C:\Users\HP\AppData\Local\Android\Sdk
• 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.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code (version 1.52.1)
• VS Code at C:\Users\HP\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.17.0
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
Type flutter doctor -v into terminal
If there are any errors that appear there, try to fix them first.
If there is no error in the installation, try to get the apk with the code flutter build apk --split-per-abi. If the error continues, you can write a comment.
I tried building my flutter app as an Android App Bundle, but the build fails for
flutter build appbundle --target-platform android-arm64
and
flutter build appbundle --target-platform android-x64
with exception an exception (same for both commands)
c:\b\s\w\ir\cache\builder\src\third_party\dart\runtime\vm\compiler\backend\il.h: 999: error: unreachable code
Dart snapshot generator failed with exit code -1073740791
Target android_aot_release_android-x64 failed: Exception: AOT snapshotter exited with code -1073740791
build failed.
FAILURE: Build failed with an exception.
* Where:
Script 'D:\Flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 882
* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command 'D:\Flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* 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 30s
Running Gradle task 'bundleRelease'...
Running Gradle task 'bundleRelease'... Done 31,1s
Gradle task bundleRelease failed with exit code 1
However, building for android-arm works just fine:
flutter build appbundle --target-platform android-arm
Running flutter doctor -v works just fine.
[√] Flutter (Channel stable, v1.17.5, on Microsoft Windows [Version 10.0.18363.959], locale de-DE)
• Flutter version 1.17.5 at D:\Flutter\flutter
• Framework revision 8af6b2f038 (4 weeks ago), 2020-06-30 12:53:55 -0700
• Engine revision ee76268252
• Dart version 2.8.4
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
• Android SDK at D:\Android\Android_Development_Requirements\Android\Sdk
• Platform android-29, build-tools 29.0.1
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
• All Android licenses accepted.
[√] Android Studio (version 3.6)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 46.0.1
• Dart plugin version 192.8052
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
I really can't figure out why, does anybody know what could be the reason for this?
It seems the problem was related to the moor_ffi library, though I couldn't figure out why exactly, however switching to moor_flutter fixed it.