Cannot build or run in android studio - android

I was using android studio 4.1.1, I updated to the 4.1.3 version and after that I had some problems.
Gradle sync never finished.
the android view (top right) is not showing properly. it appears just like the project view
The buttons for build, make project and run are not working
I have errors all around the code.
What I have tried:
I tried to upgrade the Gradle to the latest version. but nothing worked
I went to File>Invalidate Caches/Restart. but it did not work
I wanted to Sync project with Gradle files. but that options is not even available (I guess it is due to the Gradle sync still in progress)
I cannot acces the project structure in File>Project Structure (it shows me the error in the snapshot below)
I have been stuck for two days now, and cannot proceed with coding. If anyone can help, I will gladly provide any further information you will need.

Related

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.

Android Studio shows continuous error with plugins and androidAnnotations.jar

I don't know why, but Android Studio 3.2.1 display a plugin error continuosly. The error is always related to androidAnnotations.jar, like this:
Android Studio/plugins/android/lib/androidAnnotations.jar!/android/content/annotations.xml: Content is not allowed in prolog.
I've updated to latest version of IDE and SDK but the error hasn't been solved. I tried to invalidate caches, reload the project from repository and resync gradle, disable and enable plugins, etc., but without success.
Any suggestion?
After some test and searchs on internet I've found how to solve this issue. Deleting some cache folders from .android, AS recreates it and problems are gone. I followed the steps from the answer posted by #Levi Rizki Saputra.

Design editor can not show anything in android studio 3.3

After updating 'Android studio' to version 3.4 , design editor can't display UI and displays this message as you can see in image below.
Design editor is unavailable until a successful build
What can I do to solve this problem?
Your Gradle build failed, so Android Studio blocks access to the editor until the build is successful. No I don't know why it works like that, it just does.
So rebuild your project by going to the Build tab (in the bar at the top where you see "File", "View", etc) and press "Make project". Fix any errors from the build and you can use it again.
Alternatively, if the build did succeed but still shows like that, invalidate the caches and restart. Clean and rebuild is also a good option, though your problem will most likely be solved by building the project.
In my case, updating buildToolsVersion to latest version fixed my problem.
P.S: cache invalidating and restarting, clean and rebuild, and other typical solutions for android studio not worked for me.

After gradle update to 2.10, can't run app

I'm running on Android Studio 2.1.1 and was recently asked to update the gradle plugin to 2.10 (form 2.2.1) to have the ability of instant runs, which needles to say I did.
Right after that only one particular project can't build and I've tried everything that's available on the subject as question on stackoverflow.
Here are my settings
project build.gradle:
gradle/gradle-wrapper.properties:
After I try to run I get the following:
via terminal
gradle clean --stacktrace
The last thing is pretty strange since I've set the version to 2.10
Any ideas?
I did my search too on this.Some said to delete the file manually but it gave me a new file everytime i did that.Try reimporting your project and rebuilding it.

Categories

Resources