I tried running the hello_world flutter app from flutter create on my android virtual device but it throws me an error. What's wrong?
steps:
flutter create hello_world
cd hello_world
flutter run
> flutter run
Using hardware rendering with device AOSP on IA Emulator. If you get graphics artifacts, consider enabling software rendering with
"--enable-software-rendering".
Launching lib/main.dart on AOSP on IA Emulator in debug mode...
e: /Users/kernelpanic/Desktop/hello_world/android/app/src/main/kotlin/com/example/hello_world/MainActivity.kt: (4, 19): Unresolved reference: embedding
e: /Users/kernelpanic/Desktop/hello_world/android/app/src/main/kotlin/com/example/hello_world/MainActivity.kt: (5, 19): Unresolved reference: embedding
e: /Users/kernelpanic/Desktop/hello_world/android/app/src/main/kotlin/com/example/hello_world/MainActivity.kt: (8, 21): Unresolved reference: FlutterActivity
e: /Users/kernelpanic/Desktop/hello_world/android/app/src/main/kotlin/com/example/hello_world/MainActivity.kt: (9, 5): 'configureFlutterEngine' overrides nothing
e: /Users/kernelpanic/Desktop/hello_world/android/app/src/main/kotlin/com/example/hello_world/MainActivity.kt: (9, 65): Unresolved reference: FlutterEngine
e: /Users/kernelpanic/Desktop/hello_world/android/app/src/main/kotlin/com/example/hello_world/MainActivity.kt: (10, 35): Cannot access class 'FlutterEngine'. Check your module classpath for missing or conflicting dependencies
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app: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 1s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 2,4s
Gradle task assembleDebug failed with exit code 1
flutter doctor:
> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.14.6 18G103, locale it-IT)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[✓] Android Studio (version 3.5)
[✓] IntelliJ IDEA Community Edition (version 2019.3.1)
[✓] VS Code (version 1.43.0)
[✓] Connected device (1 available)
• No issues found!
Solution
clean gradle caches and everything starts to work
Related
I am trying to run my Android project on the emulator, but I am encountering the following error: "Gradle task assembleDebug failure." I have tried several solutions, but nothing seems to work. Can someone help me resolve this issue?
* Where:
Script '/Users/myname/FlutterDev/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1151
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/Users/myname/FlutterDev/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 2s
Exception: Gradle task assembleDebug failed with exit code 1
Also I check my flutter doctor everything its checked
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.1, on macOS 13.2 22D49 darwin-arm64, locale en-CA)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] VS Code (version 1.75.0)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
• No issues found!
I'm using Ubuntu 20.04. I've reinstalled flutter and android studio a few times but I can't make the below error go away. I've also tried the commands flutter clean and gradlew clean and tried to change compileSdkVersion, minSdkVersion and targetSdkVersion.
Launching lib/main.dart on sdk gphone x86 in debug mode...
lib/main.dart:1
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
Could not create service of type UserHomeScopedCompileCaches using UserHomeScopeServices.createCompileCaches().
Unexpected lock protocol found in lock file. Expected 3, found 0.
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 36s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
When I run flutter doctor:
$: flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.1, on Ubuntu 20.04.4 LTS 5.13.0-44-generic,
locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version
32.1.0-rc1)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2021.2)
[✓] Android Studio
[✓] VS Code
[✓] Connected device (3 available)
[✓] HTTP Host Availability
• No issues found!
Java and javac:
$: java --version
openjdk 11.0.15 2022-04-19
OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1)
OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1, mixed mode, sharing)
$: javac --version
javac 11.0.15
I'm getting this error message when trying to build my Flutter app on Android. It was running fine since I started this project a couple of days ago. After doing some testing on IOS simulator I had to try some stuff on Android again and couldn't build it anymore.
Launching lib/main.dart on AOSP on IA Emulator in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
> Android resource linking failed
ERROR:/Users/Antonio/Dropbox/Flutter/wader/build/app/intermediates/packaged_manifests/debug/AndroidManifest.xml:22: AAPT: error: 'orientation|keyboardHidden|keyboard|viewsize|smallestviewsize|locale|layoutDirection|fontScale|screenLayout|density|uiMode' is incompatible with attribute configChanges (attr) flags [colorMode=16384, density=4096, fontScale=1073741824, keyboard=16, keyboardHidden=32, layoutDirection=8192, locale=4, mcc=1, mnc=2, navigation=64, orientation=128, screenLayout=256, screenSize=1024, smallestScreenSize=2048, touchscreen=8, uiMode=512].
* 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 40s
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 connectivity...
FAILURE: Build failed with an exception.
* What went wrong:
Task 'assembleAarRelease' not found in root project 'connectivity'.
* Try:
Run gradlew tasks to get a list of available tasks. 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
Exception: The plugin connectivity could not be built due to the issue above.
Exited (sigterm)
This is my flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.2, on Mac OS X 10.15.7 19H1030 darwin-x64,
locale en-AE)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
[✓] VS Code (version 1.44.0)
[✓] VS Code (version 1.43.2)
[✓] Connected device (2 available)
• No issues found!
Any ideas?
With Android Studio, I created a new Flutter project and copied the following files:
I was trying to build my app but it always returns this weird error :-
Launching lib\main.dart on M2003J15SC in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':location:compileDebugJavaWithJavac'.
> File 'C:\Native\findhelpapp\findhelpapp\build\location\intermediates\annotation_processor_list\debug\annotationProcessors.json' specified for property 'processorListFile' does not exist.
* 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
Exited (sigterm)
I tried to run flutter clean and rebuild the project and it doesn't work too :"(
So what should I do to fix this error??
My flutter doctor logs :-
C:\Native\findhelpapp\findhelpapp>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.20.4, on Microsoft Windows [Version 10.0.18362.1082], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Android Studio (version 3.6)
[√] IntelliJ IDEA Community Edition (version 2019.3)
[√] VS Code (version 1.49.1)
[√] Connected device (1 available)
• No issues found!
C:\Native\findhelpapp\findhelpapp>
Check Android SDK and Jdk Location
2.Copy next lines at the end of gradle.properties
android.useAndroidX=true
android.enableJetifier=true
And set the latest version
on file app\build.gradle
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
}
4.And Run your app a
gain
My flutter app was working without any issue and it worked after I upgraded to flutter v1.12.13+hotfix.5 on debug mode but I get this error when I try to build an APK
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':shared_preferences:verifyReleaseResources'.
1 exception was raised by workers: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource
linking failed
D:\my-flutter-app\build\shared_preferences\intermediates\res\merged\release\values\values.xml:236:
error: resource android:attr/fontVaria tionSettings not found.
D:\my-flutter-app\build\shared_preferences\intermediates\res\merged\release\values\values.xml:237:
error: resource android:attr/ttcIndex not found. error: failed
linking references.
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 7s Running Gradle task 'assembleRelease'... Running
Gradle task 'assembleRelease'... Done 7.9s
Gradle task assembleRelease failed with exit code 1
My flutter doctor shows no issues
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows
[Version 10.0.18362.592], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK
version 29.0.2)
[√] Android Studio (version 3.5)
[√] VS Code (version 1.41.1)
[√] Connected device (1 available)
• No issues found!
I'm sure that my build.gradle contains compileSdkVersion 28 which is the typical solution for this issue and everything was working before I upgrade.
First of all, you have to find this line in your error log
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource
linking failed [your project path]\build`the package that has the
problem` \intermediates\res\merged\release\values\values.xml
To solve the issue
1- open android studio
2- open the android project of your app. (take care not NOT the app itself)
3- on the left make sure that you view in "project" or "android" view
4- You will find all your packages listed, open expand the package that has the problem\android
5- open the package that has the problem build.gradle
6- make sure that compileSdkVersion 28 not 27
In my case the package that has the problem was shared_preferences
For more information check this issue on flutter github repo
To solve this problem, the command flutter config --enable-build-plugin-as-aar helped me, from here