Build Fail after Android Studio Electric Eel | 2022.1.1 update - android

Gradle build failed after android studio update. It typically does after updates, but this time invalidating caches and restarting didn't help. It's not giving me much, just says 'myprojectname' failed in build log. It shows my main activity in red in manifest as an unresolved class, also google imports are unresolved.

If this happens to you, try (tab)Build/Rebuild Project. It created a gradle sync error message on the bottom, suggesting upgrading,and clicking this eventually leads you to prompts for downloading and resyncing upgraded gradles (took about half an hour). Would have been nice to have gotten a prompt from the start with the failed after studio upgrade build attempt.

Related

Cannot build my project after updating to Android Studio 4.2

I have recently upgraded to Android Studio 4.2. I can no longer build my project.
Android Studio non-stop trying to start Gradle Daemon, but cannot do so:
Starting Gradle Daemon...
Gradle Daemon started in 5 s 92 ms
Starting Gradle Daemon...
Gradle Daemon started in 4 s 406 ms
Starting Gradle Daemon...
Gradle Daemon started in 2 s 968 ms
Starting Gradle Daemon...
Gradle Daemon started in 2 s 937 ms
Starting Gradle Daemon...
I think as a result of this, dozens of OpenJDK Platform binaries are being generated in my TaskManager. This processes never stops until my machine runs out of memory. In such cases, very frequently, Android Studio is crashing.
When I do get to point where Android Studio stops building, it shows me an error: (I am sorry I am posting error image. My laptop is frozen that it is not possible to copy the error message.)
Studio tries to import previous .vmoptions and sanitize them to work
with the garbage collector used by JDK 11. If that process fails, the
IDE may not start for certain users who set custom VM options in the
.vmoptions file.
In order to resolve this problem, try:
We recommend commenting out custom options in .vmoptions (using the
“#” character). The .vmoptions file can be found in the following
locations:
Windows
C:\Users\YourUserName\AppData[Local|Roaming]\Google\AndroidStudio4.2\studio64.exe.vmoptions
Check out the docs for more known issues of Android Studio 4.2 https://developer.android.com/studio/known-issues
Try opening build.gradle and there at the top you will see JDK not recognized dialog click on it and choose your JDK. It will work.
Potential solutions:
Solution 1.
Restart your machine. Then re-open your project. It should fix the issues.
Solution 2.
It is possible that Android Studio 4.2 is having issues due to an invalid Android Studio configuration imported from a previous version of Android Studio or an incompatible plugin
Go to these folders:
C:\Users\YourUserName\AppData\Local\Google
C:\Users\YourUserName\AppData\Roaming\Google
Find Android Studio 4.1 or similar directory of previous version of Android Studio. Delete (or rename, for backup purposes) the directory, depending on the Android Studio version, and start Android Studio again.

Gradle stuck syncing for project [duplicate]

I am trying to move some business logic from my iOS apps to KMM. I have already made some job when suddenly started having problems with studio. It was not building, there were weird metaspace errors, etc. I was beating around my project for several hours and days to be honest - no result. I decided to completely uninstall studio and all its dependent files.
After that I'm not even able to properly build an empty KMM project. Simple Android projects work just fine. Problems occur only with KMM. When I have created a project for the first time, it has loaded successfully, downloaded all the dependencies and synced. I was able to see "Android" project structure. I tried to build it via ./gradlew build - error. There was no complete description, only the name of the failed task - compile kotlin to ios arm64. An error in a completely new project. I tried rebuilding project - no luck. So I restarted studio and here the second part of magic begins.
From this moment whenever I open a new or existing KMM project, it starts syncing and stucks. I can't open project structure for example, because sync is in progress, I can't add dependencies, because sync is in progress. But I can build it via ./gradlew build and it builds! Well, I tried some more commands, like ./gradlew -refresh-dependencies etc. It was building successfully. And then at some point all the code became red. Below you can see all the colors of Android Studio at the same time:
In the terminal you can see that it was built successfully. In the lower right corner you can see that it doesn't allow to go to the project structure because of sync in progress. And the most beautiful are all that unresolved symbols.
I believe I have tried the most of these Android Studio things:
Invalidate cache & restart
Just restart
Rebuild project
./gradlew clean build
Deleting ~/.gradle and ./gradle and rebuild
Restarting the laptop
Updating all plugins
etc.
Guys, do you have any ideas how can I make studio just work with KMM? And then how should I make it keep working? As I've already said, the problem is not studio specific, it is KMM specific, because regular android projects build just fine.
Android Studio 4.1.2
Mac OS Big Sur 11.2
Kotlin 1.4.30-release-Studio4.1-1
I guess you have encounterd this issue.
Actually I didn't figure how to fix it out, but you can try AS 4.2-beta as this issue seems not be present in this AS build.
The same happend to me and I switch to AS 4.2 beta.
The only difference between you and me is Kotlin version: I have 1.4.21
UPDATE
It turned out that I had a misconfiguration between KMM plugin e Kolin version.
AS 4.1 should work correctly only with KMM plugin 0.2.0 and Kotlin 1.4.20, I had Kotlin 1.4.30 instead. Switching back to Kotlin 1.4.20 fixed this.

Empty KMM project is stuck with gradle sync

I am trying to move some business logic from my iOS apps to KMM. I have already made some job when suddenly started having problems with studio. It was not building, there were weird metaspace errors, etc. I was beating around my project for several hours and days to be honest - no result. I decided to completely uninstall studio and all its dependent files.
After that I'm not even able to properly build an empty KMM project. Simple Android projects work just fine. Problems occur only with KMM. When I have created a project for the first time, it has loaded successfully, downloaded all the dependencies and synced. I was able to see "Android" project structure. I tried to build it via ./gradlew build - error. There was no complete description, only the name of the failed task - compile kotlin to ios arm64. An error in a completely new project. I tried rebuilding project - no luck. So I restarted studio and here the second part of magic begins.
From this moment whenever I open a new or existing KMM project, it starts syncing and stucks. I can't open project structure for example, because sync is in progress, I can't add dependencies, because sync is in progress. But I can build it via ./gradlew build and it builds! Well, I tried some more commands, like ./gradlew -refresh-dependencies etc. It was building successfully. And then at some point all the code became red. Below you can see all the colors of Android Studio at the same time:
In the terminal you can see that it was built successfully. In the lower right corner you can see that it doesn't allow to go to the project structure because of sync in progress. And the most beautiful are all that unresolved symbols.
I believe I have tried the most of these Android Studio things:
Invalidate cache & restart
Just restart
Rebuild project
./gradlew clean build
Deleting ~/.gradle and ./gradle and rebuild
Restarting the laptop
Updating all plugins
etc.
Guys, do you have any ideas how can I make studio just work with KMM? And then how should I make it keep working? As I've already said, the problem is not studio specific, it is KMM specific, because regular android projects build just fine.
Android Studio 4.1.2
Mac OS Big Sur 11.2
Kotlin 1.4.30-release-Studio4.1-1
I guess you have encounterd this issue.
Actually I didn't figure how to fix it out, but you can try AS 4.2-beta as this issue seems not be present in this AS build.
The same happend to me and I switch to AS 4.2 beta.
The only difference between you and me is Kotlin version: I have 1.4.21
UPDATE
It turned out that I had a misconfiguration between KMM plugin e Kolin version.
AS 4.1 should work correctly only with KMM plugin 0.2.0 and Kotlin 1.4.20, I had Kotlin 1.4.30 instead. Switching back to Kotlin 1.4.20 fixed this.

Gradle sync failed: com.android.builder.model.AndroidProject.getProjectType()I

My Gradle sync fails with the following error message in the log:
Gradle sync failed: java.lang.NoSuchMethodError: com.android.builder.model.AndroidProject.getProjectType()I
or sometimes I get this error instead:
Gradle sync failed: com.android.builder.model.AndroidProject.getProjectType()I
And this error pop up (The yellowish box that pops up at top of the gradle file in android studio):
Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly.
I had the same issue a few days earlier, but I just clicked file/Invalid Caches/restart and the Gradle sync succeded.However, the gradle fail has returned again today.
I have tried everything suggested here in this post and other SO posts but nothing seem to work, the error is still there.
Is there any suggestions on other things I can try to fix this error?
Delete after backup folder C:\Program Files\Android\Android Studio
and unzip Beta Android Studio zip file into that folder. Hope it help!
I have managed to get rid of this problem now. It seems it had something to do with the latest Android Studio.
I downloaded 2.3 Beta 1 from the Canary Channel, and that's where the problem was.
I went back to using 2.3 Canary 3 from the Canary Channel, and now it works fine.

Android Studio update broke Gradle

I just updated my Android Studio 135.14 etc to 135.15.
First, I get an SDK not found error, since now the SDK cannot be in the Android Studio folder any more due to checksum problems. I fixed this as instructed, but now when I try to run my app I get the following message.
Failed to complete Gradle execution.
Cause: tried to access method
com.google.common.base.Stopwatch.()V from class
com.android.tools.idea.gradle.invoker.GradleTasksExecutor$3
I've already tried a clean and to delete .gradle from home. I don't see anything in build.gradle that has anything remotely to do with this and I am unsure on how to proceed.
I am not familiar with gradle at all since it just worked for months until the update.

Categories

Resources