Android studio 3.4 taking too much time to build the project - android-studio

After updating the android studio to android 3.4 it's taking too much time to build the project before that it's taking only a few minutes but now it's taking too much time
EDIT
even after one hour it keeps building the project.

#VirendraVarma Your solution worked for me, Appreciate it, but just to make it clear for everyone else.
1. Close the current Android Studio project
2. Go to your project's directory and delete all build, .gradle, .idea folders. Also any unfamiliar files as stated by Varma.
3. Now at the Android Studio welcome screen, click on open an existing Android Studio project and the rest should be quite straightforward.

Related

Android studio messed up every xml file. How to resolve it? [duplicate]

I have an odd problem with Android Studio.
Here is how my class file looks like on Android Studio
And here is what it looks like on a text editor.
Any ideas why it is happening? I have tried closing then reimporting the project, invalidate caches and restart, clean project, build project, delete .idea folder and .iml files. All of my files are broken when opening in AS but looks fine on text editors.
UPDATE: Quicker solution by the user Hong given below:
Delete the caches folder: C:\Users\my_user_name\.AndroidStudio3.3\system\caches
=====================
Here's what worked for me.
Close Android Studio
Go to C:\Users*your username*
Locate the Android Studio settings directory named .AndroidStudioX.X (X.X being the version)
Rename it to something like old.AndroidStudioX.X
Start Android Studio, and when it asks if you want to import settings, choose the old directory
This should fix the issue.
Thanks to the Answer of Asim, I found deleting folder caches fixed the problem for my case (all gradle files in Android Studio show contents that have nothing to do with the actual contents of these files):
C:\Users\my_user_name\.AndroidStudio3.3\system\caches
Edit[2020-07-17]:
This is still happening with Android Studio 4.0, so I have to delete the following folder to fix this problem:
C:\Users\my_user_name\.AndroidStudio4.0\system\caches
Edit[2021-11-08]:
This solution no longer works for Android Studio Arctic Fox. Please see the new answer by Nikunj Paradva. I have used the new solution and it works.
Solution for Android studio Arctic Fox and Higher Versions
Steps
Exit Android Studio
Delete caches folder from
C:\Users\{username}\AppData\Local\Google\AndroidStudio2020.3 // For Arctic Fox
Open Android Studio and your code has being Perfect
Check your Android studio version and Target that version folder at below location
C:\Users\{username}\AppData\Local\Google
Note : AppData folder is Hidden in Windows
Does this situation warrant a bug report?
Yes! In fact this problem has been reported to the Android Studio team, and anyone willing to help us investigate is welcome to contribute there. Thanks!
You can also try the workaround in Hong's answer.
Close Android studio and then delete the caches folder: C:\Users\user_name\.AndroidStudio3.4\system\caches
Try to delete the Android Studio IDE cache data listed below per your platform:
Windows:
%USER%\.AndroidStudio[Preview]_X.Y_
Mac:
~/Library/Preferences/AndroidStudio[Preview]_X.Y_
~/Library/Caches/AndroidStudio[Preview]_X.Y_
~/Library/Logs/AndroidStudio[Preview]_X.Y_
~/Library/Application Support/AndroidStudio[Preview]_X.Y_
Linux:
~/.AndroidStudio[Preview]_X.Y_
See: https://developer.android.com/studio/releases#delete-unused
Updated my android studio days ago and was faced with the same problem. Solved it by uninstalling android studio and reinstalling the previous version set up I had left the SDK intact so I didn't have to re-download them working perfectly guess I won't be updating again soon.
Thanks to #Henry for confirming, by several similarly observed whacko problems the past two days, that my problem is indeed caused by a bug in AS. Follow his links to become convinced yourself. I'll let Henry file the bug report.
So there's no fixing my problem in situ without great effort--wait for bug fix.... which could take awhile.
So here's what I did to work around it and get back to work (it took less than 10 minutes):
create new project with no activity
(Do the rest inside the IDE, not using Windows or DOS.)
copy all .java files into the java folder in the IDE (it's ...\app\src\main\java\)
copy all res folders into the res folder (...\app\src\main\res\)
copy all asset files into main folder (...\app\src\main\assets\)
copy androidmanifest.xml into main folder (...\app\src\main)
do a global replace of old project name to new project name
I didn't change any of the files in the new project's ...\app\ folder because compilation was normal.
(I'll tell you this: when I saw what I THOUGHT were mangled FILES and looked at the History and saw nothing resembling what should have been there, I got a sick feeling, but I immediately opened Windows Explorer, selected all of the project's java files, and opened them, en masse, with Notepad++. Whew. No problems seen. (I didn't really think AS could actually mangle the files and I doubt it ever could. But it did wake me up at 5am!))
copy your android project to another location then open it from android studio
I changed my projects location and it solved my problem. This happened when my system was accidently shut down due to power failure.

Android Studio broken .studio instead of classes shows incomprehensible pieces – xml

I started the studio and see such a picture, considering that all the classes are broken and everything is lit in red - the project is going and working. Help me fix it. Invalidate does not help. Instead of classes in general pieces of markup ...
Close Project
Try Removing .idea folder from your project.
Restart your project again in android studio
I have delete caches folder from C: Drive. after open project in an Android studio.
C:\Users\admin.AndroidStudio3.3\system\caches
link here

Android Studio shows wrong file contents

I have an odd problem with Android Studio.
Here is how my class file looks like on Android Studio
And here is what it looks like on a text editor.
Any ideas why it is happening? I have tried closing then reimporting the project, invalidate caches and restart, clean project, build project, delete .idea folder and .iml files. All of my files are broken when opening in AS but looks fine on text editors.
UPDATE: Quicker solution by the user Hong given below:
Delete the caches folder: C:\Users\my_user_name\.AndroidStudio3.3\system\caches
=====================
Here's what worked for me.
Close Android Studio
Go to C:\Users*your username*
Locate the Android Studio settings directory named .AndroidStudioX.X (X.X being the version)
Rename it to something like old.AndroidStudioX.X
Start Android Studio, and when it asks if you want to import settings, choose the old directory
This should fix the issue.
Thanks to the Answer of Asim, I found deleting folder caches fixed the problem for my case (all gradle files in Android Studio show contents that have nothing to do with the actual contents of these files):
C:\Users\my_user_name\.AndroidStudio3.3\system\caches
Edit[2020-07-17]:
This is still happening with Android Studio 4.0, so I have to delete the following folder to fix this problem:
C:\Users\my_user_name\.AndroidStudio4.0\system\caches
Edit[2021-11-08]:
This solution no longer works for Android Studio Arctic Fox. Please see the new answer by Nikunj Paradva. I have used the new solution and it works.
Solution for Android studio Arctic Fox and Higher Versions
Steps
Exit Android Studio
Delete caches folder from
C:\Users\{username}\AppData\Local\Google\AndroidStudio2020.3 // For Arctic Fox
Open Android Studio and your code has being Perfect
Check your Android studio version and Target that version folder at below location
C:\Users\{username}\AppData\Local\Google
Note : AppData folder is Hidden in Windows
Does this situation warrant a bug report?
Yes! In fact this problem has been reported to the Android Studio team, and anyone willing to help us investigate is welcome to contribute there. Thanks!
You can also try the workaround in Hong's answer.
Close Android studio and then delete the caches folder: C:\Users\user_name\.AndroidStudio3.4\system\caches
Try to delete the Android Studio IDE cache data listed below per your platform:
Windows:
%USER%\.AndroidStudio[Preview]_X.Y_
Mac:
~/Library/Preferences/AndroidStudio[Preview]_X.Y_
~/Library/Caches/AndroidStudio[Preview]_X.Y_
~/Library/Logs/AndroidStudio[Preview]_X.Y_
~/Library/Application Support/AndroidStudio[Preview]_X.Y_
Linux:
~/.AndroidStudio[Preview]_X.Y_
See: https://developer.android.com/studio/releases#delete-unused
Updated my android studio days ago and was faced with the same problem. Solved it by uninstalling android studio and reinstalling the previous version set up I had left the SDK intact so I didn't have to re-download them working perfectly guess I won't be updating again soon.
Thanks to #Henry for confirming, by several similarly observed whacko problems the past two days, that my problem is indeed caused by a bug in AS. Follow his links to become convinced yourself. I'll let Henry file the bug report.
So there's no fixing my problem in situ without great effort--wait for bug fix.... which could take awhile.
So here's what I did to work around it and get back to work (it took less than 10 minutes):
create new project with no activity
(Do the rest inside the IDE, not using Windows or DOS.)
copy all .java files into the java folder in the IDE (it's ...\app\src\main\java\)
copy all res folders into the res folder (...\app\src\main\res\)
copy all asset files into main folder (...\app\src\main\assets\)
copy androidmanifest.xml into main folder (...\app\src\main)
do a global replace of old project name to new project name
I didn't change any of the files in the new project's ...\app\ folder because compilation was normal.
(I'll tell you this: when I saw what I THOUGHT were mangled FILES and looked at the History and saw nothing resembling what should have been there, I got a sick feeling, but I immediately opened Windows Explorer, selected all of the project's java files, and opened them, en masse, with Notepad++. Whew. No problems seen. (I didn't really think AS could actually mangle the files and I doubt it ever could. But it did wake me up at 5am!))
copy your android project to another location then open it from android studio
I changed my projects location and it solved my problem. This happened when my system was accidently shut down due to power failure.

Why does Android Studio show errors in my code but app still runs

I have recently upgraded my laptop and re-installed Android Studio to the latest version and imported my app. The problem I am facing now is that when Android Studio start it finishes the gradle build etc, but shows errors all over my code. I can still debug the app on my phone and all is working.
How can I get this resolved?
Thanks
I finally resolved this when it happened to me. The steps I did to resolve my problem
Build -> clean
File -> invalidate caches / restart
Delete .idea folder, close and reopen project
Normally one of the first two first steps is enough but today I actually had to delete the entire .idea folder and reopen the project to get rid of the "errors" (only IDE errors, project still ran for me).
If Methods named (A) (B) (C) (D), do not help you, then the following 4 steps are AGNI ASTRA.
Step 1 : Go To App Folder In Android Studio.
Step 2 : Locate Build Folder.
Step 3 : Delete Build Folder.
Step 4 : Sync File.
I will advise to use AGNI ASTRA, after trying, Methods named (A) (B) (C) (D) .
The Methods Are :
Method (A)
CLICK ON FILE IN ANDROID STUDIO
CLICK ON SYNC PROJECT WITH GRADLE FILES
Method (B)
CLICK ON FILE IN ANDROID STUDIO
CLICK ON INVALIDATE CACHES
Method (C)
CLICK ON BUILD IN ANDROID STUDIO
CLICK ON CLEAN PROJECT
Method (D)
CLICK ON BUILD IN ANDROID STUDIO
CLICK ON REBUILD PROJECT
In my case (Windows), I have faced the same issue with 2 version of Android Studio,
1. Android Studio Arctic Fox | 2020.3.1 Patch 4 (My previous/normal IDE used)
2. Android Studio Dolphin | 2021.3.1 Patch 1 (My updated/current IDE used)
First, I thought this problem can be solve by Build>Clean Project, or Build>Rebuild Project, or File>Invalidate Caches..., but sadly won't work. So, I decided to update my IDE Arctic Fox to Dolphin.
Download from official site, installed with different folder (C:\Program Files\Android\Android Studio1), but project folder still same. During opening project, it won't run unless change Java version to Java 11 (File>Settings>Build, Exectuion, Deployment>Build Tools>Gradle>Gradle JDK>11 version).
Try opening several projects, however the IDE sometime still show the redline code, but the app can still debug/run as usual. Latest method I used, File>Invalidate Caches... And IDE haven't show any redline code.
*Remark: Don't know how long the latest method I used will work.

Android Studio Artifacts

After developing in Eclipse for several years I have switched to Android Studio since two days. Although I have read as much as possible about it I still have one big problem: I can not find the place to add, change, configure or whatever about the so called artifacts.
I have tried several ways from creating a new project from scratch to importing a complete Eclipse projects.
Although the IntelliJ documentation is clear about it, I can not find it.
The project structure in all cases only shows three parts in the structure:
SDK location, Project and app. I have searched them all but no artifacts.
Who can help me?
The artifact description is in the IntelliJ IDEA manual that is reached by selecting menu item 'Help, Help Topics' in Android Studio.
However, according to JetBrains Support the Android Studio documentation topics need to be updated and the Artifacts page should not be available in Android Studio.
See also: https://intellij-support.jetbrains.com/requests/58563

Resources