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.
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
my app was running normally , after running flutter upgrade it gives me this error . I didn't change anything in my code.
note: I am using visual studio code
I tried flutter clean, flutter upgrade but it gives the same error .
I checked JAVA_HOME path and it is okay
../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.18.1/lib/src/picture_provider.dart:50:59: Error: No named parameter with the name
'nullOk'.
context != null ? Localizations.localeOf(context, nullOk: true) : null,
^^^^^^
../../flutter/packages/flutter/lib/src/widgets/localizations.dart:413:17: Context: Found this candidate, but the arguments don't match.
static Locale localeOf(BuildContext context) {
^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'D:\mobileapps\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\mobileapps\flutter\bin\flutter.bat'' finished with non-zero exit value 1
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 49s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 50.5s
Exception: Gradle task assembleDebug failed with exit code 1
this is the result of run doctor -v
[√] Flutter (Channel stable, 2.0.1, on Microsoft Windows [Version 10.0.18362.30], locale en-US)
• Flutter version 2.0.1 at D:\mobileapps\flutter
• Framework revision c5a4b4029c (7 days ago), 2021-03-04 09:47:48 -0800
• Engine revision 40441def69
• Dart version 2.12.0
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
• Android SDK at C:\Users\hit-ham\AppData\Local\Android\sdk
• Platform android-29, build-tools 30.0.1
• 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.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 47.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
rosoft VS Code
• Flutter extension version 3.20.0
[√] Connected device (2 available)
• GM1910 (mobile) • bb671501 • android-arm64 • Android 10 (API 29)
• Chrome (web) • chrome • web-javascript • Google Chrome 88.0.4324.190
• No issues found!
You should update the package 'flutter_svg' from 0.18.1 to 0.19.3 and it should solve your issue,
it happens because of the 'nullOk' parameter that was removed in Flutter 2. You can read about it here:
https://flutter.dev/docs/release/breaking-changes/eliminating-nullok-parameters
I found this solution and it worked for me
After updating my flutter project when I was going to run the application in the android studio, I got the following error.
e: C:\Users\user\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\fluttertoast-7.1.5\android\src\main\kotlin\io\github\ponnamkarthik\toast\fluttertoast\MethodCallHandlerImpl.kt: (16, 16): Redeclaration: MethodCallHandlerImpl
e: C:\Users\user\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\fluttertoast-7.1.6\android\src\main\kotlin\io\github\ponnamkarthik\toast\fluttertoast\MethodCallHandlerImpl.kt: (17, 16): Redeclaration: MethodCallHandlerImpl
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':fluttertoast:compileDebugKotlin'.
> Compilation error. See log for more details
* 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 52s
Exception: Gradle task assembleDebug failed with exit code 1
I tried following steps but I was not able to fix this.
pub get, pub upgrade
And here's my flutter doctor result
"C:\Program Files\flutter\bin\flutter.bat" doctor --verbose
[√] Flutter (Channel stable, 1.22.4, on Microsoft Windows [Version 10.0.19042.804], locale en-US)
• Flutter version 1.22.4 at C:\Program Files\flutter
• Framework revision 1aafb3a8b9 (3 months 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/user/AppData/Local/Android/Sdk
• Platform android-30, build-tools 30.0.2
• ANDROID_HOME = C:/Users/user/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)
X Android license status unknown.
Run flutter doctor --android-licenses to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[!] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
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.53.0)
• VS Code at C:\Users\user\AppData\Local\Programs\Microsoft VS Code
X Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected device (1 available)
• sdk gphone x86 arm (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
! Doctor found issues in 3 categories.
Process finished with exit code 0
How can I fix this issue?
This was happened due to a pub cache conflict. The problem was fixed after executing the following command in the terminal.
dart pub cache repair
dart pub get
dart pub upgrade
I tried your solution but it does not work for me. My solution is update compileSdkVersion to 30 in my app/build.gradle.
Update the flutter toast version to latest fluttertoast version in dependencies in pubspec.yaml . It worked for me.
I got the same error. Tried updating compileSdkVersion. Didn't work for me. This solved my problem.
pubspec.yaml -->> pub upgrade
Change fluttertoast version to latest
Pub get
Run...
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.
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.