Flutter compile error inside Android Studio - android-studio

I had been developing a flutter mobile app for a couple of months and all was good. I just came back to the project and a few things (flutter, dart, android studio etc) upgraded. Now I can't compile my app. I created a new flutter app (the default example) and that won't compile either.
The error I'm getting is :
FAILURE: Build failed with an exception.
* What went wrong:
Could not open settings remapped class cache for bq3hllkgb26p0nrblf5gh8d37 (C:\Users\Paul\.gradle\caches\5.6.2\scripts-remapped\settings_cbd968glg60byp9f5t6vvdlee\bq3hllkgb26p0nrblf5gh8d37\settings8410a2d21ed2f87c8a0398566330ee52).
> Could not open settings generic class cache for settings file 'D:\Apps\Flutter\Examples\flutter_app\android\settings.gradle' (C:\Users\Paul\.gradle\caches\5.6.2\scripts\bq3hllkgb26p0nrblf5gh8d37\settings\settings8410a2d21ed2f87c8a0398566330ee52).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 57
I am running:
Flutter 1.20.2
Dart 2.9.1
Android Studio 4.1
Java 1.8.0_261
JVM 13.0.2
Gradle 6.7
Windows 10

Try running
flutter stable
flutter clean
flutter downgrade
cd <Your App Folder>
and then
flutter run
in command line

I ended up completely removing Flutter from my system and then re-installed it. This fixed everything.

Related

React Native Android No such property - logger for class DefaultProjectDescriptor

I am developing my app using React Native and now when I open the android project in Android Studio, during gradle sync it is throwing this error:
A problem occurred evaluating settings 'MyApp'.
No such property: logger for class: org.gradle.initialization.DefaultProjectDescriptor
Caused by: groovy.lang.MissingPropertyException: No such property: logger for class: org.gradle.initialization.DefaultProjectDescriptor
I tried installing yarn add react-native-unimodules but this won't resolve.
I am using NVM to used node version 14.17.3
Android gradle plugin version: 4.1.0
Gradle version: 6.8
Please help me resolving this as I am stuck on this since 2 days now.
I had the same problem I tried different node versions with nvm and also downgrade android studio but none worked for me. also, I tried installing node via homebrew. What I did was to start android studio using
open -a /Applications/Android\ Studio.app
The problem was that android studio couldn't find node so in this case starting with the above command fixed the problem for me and I used nvm
I was able to resolve this issue by fully shutting down my MacBook Pro and starting it up again. Once started I loaded my project in Android Studio once again and let the gradle build finish.
Fixed this by downgrading Android studio to version 4.1.3.
Before that I installed Node through NVM but it didn`t help
I encountered this exact error on a new MacBook M1 where I formerly used Java 8 with Rosetta (from the migration). After installing Zulu Java 8/11 with ARM-64bit support, I could not build the React Native App anymore.
I simply deleted the .gradle folder (e.g. in ~/.gradle) and executed the build command again. It downloaded Gradle from scratch and the build worked.
The real fix is stackoverflow.com/a/70891538/9878385
Run chmod +x /Applications/Android\ Studio.app/Contents/bin/printenv and this actually fixes the problem, rather than just working around the problem.
Check Android Studio for available updates
Android Studio -> Check For Updates
I have updated Android Studio and Tools to the latest version and this solved the problem. Currently I have Android Studio Chipmunk | 2021.2.1 (Build on April 28, 2022)
I was facing the same issue. It could be some problem with permissions on Android Studio installation.
This might help you to open the project without this error, but it doesn't definitively solve the problem. (Ubuntu linux)
cd App_Name/android/
android-studio .
I had same error using ReactNative and NVM. Installing NodeJS through package manager solved the problem. I guess NVM environment wasn't loaded in Android Studio environment.

Android studio is giving the following error when I am trying to build a ionic project "Gradle sync failed: Sync failed: reason unknown"

I am trying to build a ionic project in Android studio on Ubuntu 20.04 . I am using the command ionic capacitor build then android studio opens up as expected then it shows this error Gradle sync failed: Sync failed: reason unknown. I am unable find a solution for this particular gradle sync error. I have reinstalled Ubuntu and other things but still the problem persists.
In my case, a fresh install of Android Studio resulted in Android 31 being the only SDK available but the project was targeting Android 30. I went to Tools > SDK Manager and made sure the appropriate version of Android SDK was installed and available. After restarting, and allowing the gradle sync to complete I was able to build/run the app on a virtual device, etc.
Here is what I found
This is the screenshot thanks for helping.
Capacitor lets you manage your own Android project. Like any IDE-backed project, sometimes things get so out of sync that the only solution is to rebuild the project.
To do this, follow these steps:
Copy any source code you created (such as Java files in app/android/src, manifest files, or resource files) into a safe location outside of app/android.
Next, make sure you are running an updated version of the Capacitor CLI:
npm install #capacitor/cli#latest
Remove the android directory:
rm -rf android/
Re-create the Android app from Capacitor:
npx cap add android
Copy your saved source files back into the project.
Check the error log. You should find something like "Module: 'mobile' platform 'android-30' not found" or something similar. Click Tools > SDK Manager and download the appropriate Android SDK Platform package.
on top right you will see option to view log file upon clicking there you will redirect to file manager and open idea file there
example :
open idea file and scroll down you will see actual issue.
In my case android sdk 31 was not installed.
I installed android sdk 31 from File>Settings>Apprearance and behaviour>system settings>android sdk and install required android sdk and rebuild the project.
accord to my observation in most cases you get this error because you have not required sdk installed in your system.

Flutter Integration in android Studio issue

While integrating Flutter in Android studio getting error as * Error running Gradle: Unable to download needed Android SDK components, as the following licenses have not been accepted: Android SDK Build-Tools 26.0.2, Android SDK Platform 27 To resolve this, please run the following command in a Terminal: flutter doctor --android-licenses
Problem was with sdk path in local.properties. By default its pointing to different location. It works for me when change android sdk home dir in sdk.dir

How to solve the issue of mixing version of support libraries in Android Studio?

I received an update to android SDK. After the update, when I open a project, Android Studio recommends to update Android Gradle to v 2.3.0 and Gradle to v 3.3. I updated the project as recommended. After that I found an ugly red line under the appcompat-v7:25.2.0' (see pic).
The error, according to android studio, is that I am mixing versions of support libraries (v 25 and 24), but I didn’t find any support library of v24. I tried to build a signed apk, but app build failed (using V2 / full apk signature), so I searched the web and I found one solution to this problem by adding this line to the build.gradle: multiDexEnabled true. Adding that line fixed the problem of generating signed apk, although the red line of error was still there, it didn’t get rid of it.
Then I installed the signed apk on two phones, one running Android 6.0 and the other one is running Android 4.4.2. The app runs smoothly on Android 6.0 and crashes on start on Android 4.4.2 (I set minSdkVersion to 19).
My questions are: how can fix that error in the gradle permanently? Is adding the line “multiDexEnabled” to gradle really needed? How can I run my app on android 4.4.2 without crashing?
I'm had the same issue, just add these lines:
compile "com.android.support:animated-vector-drawable:${supportLibVersion}"
compile "com.android.support:mediarouter-v7:${supportLibVersion}"
In your case supportLibVersion is 25.2.0.

Gradle 'TestApp' project refresh failed

I am new to android studio. I have installed android studio 2.1 and imported an eClipse project into it as my first project. After finishing import job, an error occurred with this title:
Gradle 'TestApp' project refresh failed
►Error:A problem occurred configuring project ':app'.
I notice that in Tools > Android > SDK manager > System Settings > Android SDK > SDK Update Sites there are errors with Android Repository and Legacy Android Repository.
Android Repository https://dl.google.com/android/repository/repository2-1.xml
Legacy Android Repository https://dl.google.com/android/repository/repository-12.xml
I have reinstalled Android studio and then installed and updated all extra fields in SDK manager. I have Android 4.4.2 and 5.0.1 SDK platforms. I Have all tools items installed in SDK manager.
There are no errors in Standalone SDK Manager.
I tried creating a new project. But same error appears.
How can I resolve the issue and run this app?
I restarted the Android SDK Manager and at this time I noticed that I got Android SDK Platform-tools (upgrade) and Android SDK Build-tools (new).
After installing those, I was finally able to fully compile my project.
Note: The latest ADT (Version 23) should be installed.

Resources