How to fix android studio gradle errors from unexpected shutdown - android

I am developing android applications in android studio 2.1. My system was shut down unexpectedly due to the power failure.Then after power comes i restarted my system open the android studio all my API components are showing error but my gradle file showing that it was successfully build what was the problem here i am getting don't know This screen shot will explain you more
It was showing gradle successfully build but still error remains same can anyone help me

Try to clean the project using the gradle task clean then invalidate the cache of android studio and restart (File/invalidate cache and restart).
after that synchronise your project with grade and build it again. I think it would solve your issue.
Let me know if it works.

First, Close your IDE and Follow these two simple steps to solve this problem.
Delete caches folder of the path
C:\Users\user\.AndroidStudio4.0\system\caches.
Delete specific project's caches folder too
E:\AndroidProjects\SampleApp\.idea\caches

Related

Android Studio freezes on indexing

my project was working well but suddenly when I ran it on my phone, Android Studio freezes and I should stop it from task manager.
before this happens I installed "Geny motion" & "Virtual Box", but when the error occurred I uninstalled them. but the problem insisted.
Solutions I've tried
I uninstalled it and installed it again
I unplugged and plugged in my device
I disabled android indexing from setting
None of the above solutions worked.
I had today this exact problem. None of the above helped me until I found simple solution here
Just run File -> Invalidate Cache and Restart
That simple and it works!!!
Delete all Android Studio data - .gradle .android .androidstudio folders from your home folder. And all project build folders gradle and iml files.
This worked for me.
1.Close the project
2.Remove the project
3.Close Android Studio
4.Open it again
5.Open the project
Enjoy Coding!
I checked my java file and I saw somehow all the code in one of my java files was replaced with "NULL NULL NULL NULL....."
I deleted the file and the application runs without a problem.
Android Studio (3.1.3) froze on me while editing a source file. I waited and finally killed the process in Task Manager (Windows). Twice I tried to start up again and both times it got stuck with the "indexing..." message in the lower right. Both times I ended the process in Task Manager.
I looked in the source folder of the project I was working on. The source file I had been editing when it froze was "Receipt.java". There was another file in the src folder "Receipt.java__jb_tmp__". I deleted that file and Android Studio started up fine. It looks like I lost some edits, though.
When I did start up, it detected there had been some error and offered to submit a report.
If the project is large & has a lot of modules, you might need to increase the Allocated Heap Size for Android Studio.
Go to Edit Custom VM Options from Help menu and increase the value for -Xms and -Xmx
This is what I'm using
-Xms2048m
-Xmx8192m
-XX:MaxPermSize=2048m
-XX:ReservedCodeCacheSize=1024m
-XX:+UseCompressedOops
In my case color was declared as invalid, Android Studio ignored that and during building it froze. I had to remove the file, let it index, paste it back and fix the color string (it gave me error when I entered the pasted file)
just rename project folder then open IDE, it will show
now rename back to origin folder name, click open project
it work on my case
I have older project with sdk version 22, when I open it in android studio 3.1.2 on macOS. It keep indexing forever, everything was installed and configured properly but indexing loop never stopped.
Following worked for me
File > Invalidate caches/restart… > Invalidate caches/restart
Go to the File menu and click the option Invalidate Caches / Restart This will solve the problem ! Enjoy ;)

Unable to clean or rebuild project in Android Studio 2

I have a problem with my Android studio 2. That's whenever I want to clean or rebuild my android project, I always get this message
Error:Execution failed for task ':app:clean'.
Unable to delete directory: C:\Users\MyPC\Desktop\SharePlace\app\build\intermediates
and can not fix it. what I only can do is go to File explorer and delete it.
then come back android studio and rebuild again. Sometime, that way also does not work.
I need some help to fix that Android studio. Please.
Thank inadvance!
Solution 1 :
you are using Android Studio 2.0 Beta, this issue might appear (more likely if you are working on NTFS filesystem) and it seems like the "Instant Run" is the culprit. Search for "Instant Run" in settings and uncheck the box.
I have filed an issue on the bug tracker.
Solution 2 :
You need to go to the source file directly. Close the studio and go to the path the issue is located at and delete the folder there.
I got a lot of faults like this.
Try to refresh all gradle projects: in Android Studio click on the "Gradle" tab on the right side of the window. When the gradle menu is shown, click on two blue mixed arrows icon. Then wait a moment until gradle completes refreshing and try cleaning or rebuilding again.
For me it was fixed by running Android Studio as administrator.
Manually deleted folder( build\generated and build\intermediates) after closing android studio works for me.
Found the solution. For windows, goto Task Manager and find your Android Studio. Expand it and end task for OpenJDK Platform Binary as depicted below
screenshot.
Then re-run your app in Android Studio again. It should work, and you don't have to restart your Android Studio all the time. More productivity~

Android Studio Gradle not Building Project

I was using my android Studio very well. I don't know what happened and now I am getting only Building "xxxx" Gradle project info whenever I want to create my new project. I am unable to open any new project. Please help. I don't have even 10 reputations to upload the screenshot.
I think my Gradle is not working. How can I reset or restart my Gradle ?
I think you have updated your gradle build tool.
Go to file>setting>build,execution deployment> gradle> check your gradle tool version
I had many hours trying to figure this out.
I have followed just about every Stack-overflow article on the issue.
The cause for me was my Anti-virus and Firewall settings. I turned these off, and restarted my Android Studio opened my application I was trying to build it all downloaded what it needed and sync'd nicely. Problem solved, relief as I have been literally days on this.
Add this line
File -> Settings -> Compiler -> Gradle -> VM Options:
-Xmx256m
I was failing a class because of this issue. I solved it by
1) Do not delete the Android Studio Version You Downloaded, Leave it intact
2) Google search an older version of Android Studio, in my case, 2.1.1
3) Download it and install, CHOOSE CUSTOM INSTALL
4) A message should appear saying approximately "Another version of Android Studio has been discovered, the installer will only download the missing files"
5) Confirm by starting a new project
I faced the same problem. Had to wait for 30 minutes for the project to built. But then it was working properly again. So maybe waiting is a solution.

Cannot load project: Android Studio

My laptop crashed while Android Studio was running.
Now, When I tried to open project in Android Studio it gives me weird error and no project is opening.
Cannot load project: java.lang.RuntimeException: java.io.IOException: java.lang.AssertionError: Unexpected content storage modification"**
Edit: Also I'm in the welcome screen of Android Studio and have no access to Menu options to Invalidate Caches and restart Android Studio.
I had really big issue as I was not able to open project in Android Studio. Every time I start Android Studio dialog box appear that says:
Cannot load project: java.lang.RuntimeException: java.io.IOException: java.lang.AssertionError: Unexpected content storage modification
I solved it by doing following steps:
Close Android Studio
Go to the directory home_dir/.AndroidStudio/system/cache
Remove all the files in the cache directory.
Then restart IntelliJ
No guarantee this will work, but I have previously fixed a problem which is similar to this by invalidating the cache.
In Android Studio this is under File -> Invalidate Caches / Restart
For Android Studio 2.O follow these steps:
Close Android studio
Go to ~/.android/cache
Delete content
Restart android studio
Hope this will help
In C\users\.Androidstudio delete gradle.jar and try
Backup the jar before proceeding.
I got the same issue and this is related to IDE .
Android Studio has to do a fix.
I found the same issue but I found a fix, and all it took was renaming/deleting the .AndroidStudio hidden folder in Windows, under your home directory.
C:\Users\YOURUSERNAME.AndroidStudio
I renamed mine and I'm back up and running.
I could solve this issue in android studio by selecting File-> Invalidate caches/Restart .
Start Android Studio, close any open project.
On the right side, click on Configure -> Settings.
On the left side, in Compiler->Gradle set VM Options to -Xmx512m
Press OK, then create a project. Worked for me.
also because of that
It turns out it's a Windows 8 issue with the available virtual memory. It seems like a few new processes (like Superfetch) eat up a ton of processing power to constantly scan your drive for changes, so searching is faster.
The solution is to change the min and max virtual memory values. Here's how to do that:
http://windows.microsoft.com/en-us/windows/change-virtual-memory-size#1TC=windows-7

android studio rendering timeout

I have a problem with Android Studio. Since this morning I can't edit my layouts through the Design interface. It's stuck on "Initializing Rendering Library" and the IDE freezes. All my layouts were working well yesterday and I haven't changed anything since then.
I have tried to invalidate the cache and restart but without any result.
Try that steps :
1.Update Android SDK and Android Developer Tools.
2.If that will not help, reinstall Android Studio using the newest available version (remember to do a backup of your data and projects).
3.If that will not help, install other IDE for example Eclipse and import all your projects to it.
Good luck !
For me helped such steps:
Remove .gradle folder from the project folder, all *.iml files and
.idea
Remove C:\Users\username.AndroidStudioPreview1.2
Run Android Studio without importing settings. This will allow to see a dialog where you can open your project from scratch. If you
import settings then Android Studio will open previously opened
*.xml files which caused the problem (hanging "Initializing Rendering Library") and the situation will happen again
Run Gradle cleanup
Sync project
Invalidate cache and Restart
Build the project from command line. If use Build from AndroidStudio I got hanging "scanning files to index..."
I reinstalled my android studio without success,
Then, I downloaded the sdk again, and change my old sdk-path to the new one
After I restarted my studio, it works.
The most mysterious thing is, I rechange my sdk-path back to my older one, then every thing is ok,I don't know why,but it solved the problem

Categories

Resources