Compiler error in Flutter - .AAR .Metadata - flutter

I'm trying to compile my Flutter app but I get the following problem:
`Execution failed for task ':app:checkDebugAarMetadata'.
Multiple task action failures occurred:
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.media2:media2-session:1.2.0.
When I update the compile SDK to 31, I get this message:
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
I have made changes to some of the gradle files and the warning messages have been removed but now the message below appears:
Running Gradle task 'assembleDebug'...
WARNING: [Processor] Library 'C:\.gradle\caches\modules-2\files-2.1\androidx.media2\media2-session\1.2.0\e110e7db678fbfc107af48fe6110e3cc713f4564\media2-session-1.2.0.aar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.
Example of androidX reference: 'androidx/media2/session/MediaBrowser$Builder'
Example of support library reference: 'android/support/v4/media/session/MediaSessionCompat$Token'
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
W/FlutterActivityAndFragmentDelegate(13937): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.
Debug service listening on ws://127.0.0.1:54956/S_ZxDICL0Ic=/ws
Syncing files to device AOSP on IA Emulator...
The Notes within the message are highlighted in red so I think this could possibly lead to the root cause/solution.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

Related

Error "ERROR: build failed with an exception." when starting the application

Here is the error on normal startup:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugResources'.
java.nio.file.FileSystemException: C:\Flutter_Projects\hazyaeva\build\app\intermediates\compile_and_runtime_not_namespaced_r_class_jar\debug\R.jar: ������� �� ����� �������� ������ � �����, ��� ��� ���� ���� ����� ������ ���������.
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 17s
Exception: Gradle task assembleDebug failed with exit code 1
Here is the error when run with --scan:
Task :app:mergeDebugAssets
WARNING: [Processor] Library 'C:\Users\knyzs.gradle\caches\modules-2\files-2.1\com.adcolony\sdk\4.6.5\818fbdf875a91af407c3faa9bfea044f05101168\sdk-4.6.5.aar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.
Example of androidX reference: 'androidx/annotation/NonNull'
Example of support library reference: 'android/support/annotation/NonNull'
WARNING: [Processor] Library 'C:\Users\knyzs.gradle\caches\modules-2\files-2.1\co.ogury.module\ogury-ads\4.0.8\94966c91ef3621776c9d9120756adb9dee98043f\ogury-ads-4.0.8.aar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.
Example of androidX reference: 'androidx/fragment/app/FragmentManager'
Example of support library reference: 'android/support/annotation/VisibleForTesting'
Task :app:processDebugMainManifest
C:\Flutter_Projects\hazyaeva\android\app\src\debug\AndroidManifest.xml:18:5-81 Warning:
uses-permission#android.permission.WRITE_EXTERNAL_STORAGE was tagged at AndroidManifest.xml:18 to replace another declaration but no other declaration present
Task :appodeal_flutter:generateDebugRFile
WARNING: [Processor] Library 'C:\Users\knyzs.gradle\caches\modules-2\files-2.1\com.smaato.android.sdk\module-core\21.6.3\b33ec464a5b19d1333070ffce35630f249e2f621\module-core-21.6.3.aar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.
Example of androidX reference: 'androidx/annotation/NonNull'
Example of support library reference: 'android/support/annotation/Nullable'
WARNING: [Processor] Library 'C:\Users\knyzs.gradle\caches\modules-2\files-2.1\com.adcolony\sdk\4.6.4\372a410fc325e819baf2817320b5bd369754d2a9\sdk-4.6.4.aar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.
Example of androidX reference: 'androidx/annotation/NonNull'
Example of support library reference: 'android/support/annotation/Nullable'
WARNING: [Processor] Library 'C:\Users\knyzs.gradle\caches\modules-2\files-2.1\co.ogury.module\ogury-ads\4.0.7\ecb17275d328f6bf1f62b9d15a462c20ca76877b\ogury-ads-4.0.7.aar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.
Example of androidX reference: 'androidx/fragment/app/FragmentManager'
Example of support library reference: 'android/support/annotation/VisibleForTesting'
WARNING: [Processor] Library 'C:\Users\knyzs.gradle\caches\modules-2\files-2.1\com.startapp\inapp-sdk\4.8.11\86a5ddbbdb68c26f2913d7a5d073e653abbe5e1b\inapp-sdk-4.8.11.aar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.
Example of androidX reference: 'androidx/annotation/Nullable'
Example of support library reference: 'android/support/annotation/Nullable'
Task :app:processDebugResources FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugResources'.
java.nio.file.FileSystemException: C:\Flutter_Projects\hazyaeva\build\app\intermediates\compile_and_runtime_not_namespaced_r_class_jar\debug\R.jar: ╨Я╤А╨╛╤Ж╨╡╤Б╤Б ╨╜╨╡ ╨╝╨╛╨╢╨╡╤В ╨┐╨╛╨╗╤Г╤З╨╕╤В╤М ╨┤╨╛╤Б╤В╤Г╨┐ ╨║ ╤Д╨░╨╣╨╗╤Г, ╤В╨░╨║ ╨║╨░╨║ ╤Н╤В╨╛╤В ╤Д╨░╨╣╨╗ ╨╖╨░╨╜╤П╤В ╨┤╤А╤Г╨│╨╕╨╝ ╨┐╤А╨╛╤Ж╨╡╤Б╤Б╨╛╨╝
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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.4/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 2m 35s
128 actionable tasks: 127 executed, 1 up-to-date
How to fix it?
#Alexandr
It's failing because you have integrated some package in your application that is not compatible with the gradle version you have been using.
On Android studio, you can check your gradle version by : Open the project (If you are using Flutter, my suggestion would be to Click Open Existing project and then just choose the android directory inside your project's root) > File > Project Structure
You can either make that package compatible with your version of gradle (Probably be editing its MainActivity.kt file)
OR
Use a lower version of gradle (You can change this by going to andoid/build.gradle..Look for a line like this : classpath 'com.android.tools.build:gradle:4.1.0' Here 4.1.0 means gradle v6.7
Try a few values and If you are lucky everything would work just fine! :)

Could not GET 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-ads-identifier/maven-metadata.xml' status code 502 from serve

I updated to latest flutter version 2.10.8 but not able to run the app tried so many solutions but not working
The plugins `flurry, flutter_absolute_path` use a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if these plugins support the Android V2 embedding. Otherwise, consider removing them since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
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 com.google.android.gms:play-services-ads-identifier:16+.
Required by:
project :app > project :flutter_branch_sdk
> Failed to list versions for com.google.android.gms:play-services-ads-identifier.
> Unable to load Maven meta-data from https://google.bintray.com/exoplayer/com/google/android/gms/play-services-ads-identifier/maven-metadata.xml.
> Could not get resource 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-ads-identifier/maven-metadata.xml'.
> Could not GET 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-ads-identifier/maven-metadata.xml'. Received status code 502 from server: Bad Gateway
* 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 35s
[!] Gradle threw an error while downloading artifacts from the network. Retrying to download...
Running Gradle task 'assembleDebug'...

running flutter in vs code shows Running with sound null safety

This is my first app in flutter using VS Code.
While I try to run my program via terminal using command flutter run shows:
Using hardware rendering with device Android SDK built for x86. If you notice graphics artifacts, consider enabling software rendering with"--enable-software-rendering".
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Running Gradle task 'assembleDebug'... 12.3s
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Syncing files to device Android SDK built for x86... 9.4s
Flutter run key commands.
r Hot reload.
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).
Running with sound null safety
An Observatory debugger and profiler on Android SDK built for x86 is available at: http://127.0.0.1:63186/_rjqXM3bogc=/
The Flutter DevTools debugger and profiler on Android SDK built for x86 is available at:
http://127.0.0.1:9101?uri=http://127.0.0.1:63186/_rjqXM3bogc=/
After this nothing happens in terminal neither virtual device opens up. What is happening?
When running flutter doctor shows everything ok.
This error happens because of gradle version this is an error like this question just update your gradle in Your_Flutter_App > android > build.gradle, dependencies block to new versions like:
classpath 'com.android.tools.build:gradle:7.0.2'
check buildToolsVersion and compileSdkVersion in /android/app/build.gradle if didnt work.

Questions about updating Gradle in Android Studio

I am working through the Net Ninja YouTube tutorial for Flutter. I just updated Flutter (or maybe Android Studio, whichever is arctic fox?) and now I am getting this error message whenever I try to run any basic app.
Launching lib/main.dart on sdk gphone64 arm64 in debug mode...
Running Gradle task 'assembleDebug'...
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app.apk...
Error: ADB exited with exit code 1
Performing Streamed Install
adb: failed to install /Users/dillonbond/AndroidStudioProjects/testapp3/build/app/outputs/flutter-apk/app.apk: Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]
Error launching application on sdk gphone64 arm64.
A google search led me to
when I try to "sync project with gradle files" a warning pops up
People are saying I need to update Gradle. The click through solutions from this page are outdated or gone for me. Where do I input
codecompileSdkVersion(30)
buildToolsVersion("30.0.3")
solutions like this at? Do I put them somewhere in Android Studio in a dart file? Do I enter them into my command terminal? (I'm on a Mac).
All I know about Android Studio is the basic stuff from YouTube, I am very lost here. My programming skills are rudimentary. I'm not completely sure that the linked article even applies to my situation. I installed AS through the home brew pub thing if that makes any difference.
Thanks a million in advance to anyone that can help! I seriously appreciate it!
It is already mentioned in your error that it is due to insufficient storage, delete some files from your real device and it will work.

Flutter error Execution failed for task ':app:processDebugResources'

Edit: solved, I went to Android Studio, File -> Invalidate Caches/Restart -> Invalidate and Restart, also did flutter clean for the projects. Now both run as expected. Finally.
I created a sample flutter app doing flutter create and then ran with flutter run. This is odd because a week ago I did the same thing and had no problems. And another weird thing, I created an hour ago another sample app and doing flutter run on that works perfectly fine. Same sample app, same code, but one has errors.
I am using Android API 31, no change since last week. I found 5 posts on this site, some were saying to change gradle build version or something but I wasn't sure what it meant exactly. Both sample apps were created in the same night, no edits. I have restarted my computer but no luck.
Here is the output of flutter run:
Running Gradle task 'assembleDebug'...
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
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.tasks.Workers$ActionFacade
> Android resource linking failed
AAPT: error: failed writing to 'C:\Users\Bob\Documents\coding\recipe\build\app\intermediates\runtime_symbol_list\debug\R.txt': The data is invalid. (13).
* 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 19s
Exception: Gradle task assembleDebug failed with exit code 1```
This is the result.
I went to Android Studio, File -> Invalidate Caches/Restart -> Invalidate and Restart, also did flutter clean for the projects. Now both run as expected. Finally.