Android Studio is not detecting code changes when deploy - android

When I change the code, change is not reflected to the APK or to the debugged app.
What I did so far:
Deleted .gradle folder
Reinstalled Android Studio and also a new canary version
Invalidate cache and restart
Deleted the source code and fetched again from repo
Restarted laptop
Enabled Always install with package manager
Before launch is already Gradle-aware Make
I am on Macos 12.6.2.
There is a known issue with the MacOs:
Incremental updates are not applied due to an issue with Gradle file watching on projects saved under /System/Volumes/Data
But my project is not under this folder.
I suspect that this problem started after the Macos update.
It sometimes works for the first time but does not work after that.
Any idea how to fix it?

Nelson Osacky, Gradle Engineer helped me in identifying the issue. He pointed me to the plugins used in the project. Thanks to him!
'gradle.plugin.com.github.sgtsilvio.gradle:android-retrofix:0.4.1' plugin was the root cause for the issue. When I removed it, everything worked fine.

Related

android studio projects getting corrupted after a restart

After upgrading to arctic fox, I faced this issue. Opened a project I worked previously with older version of android studio was fine, but after restart its files became full with gibberish values. I thought its a hardware failure issue. But this happening again today with other projects, so I want a solution.
After working, closing and reopening the project the files contents became corrupted/changed:
File contents changed on previous project, showing difference with git:
ArcticFoxPatch2, Projects are built with gradle 7.0.2.
Solutions tried:
I have tried potential solution of invalidating cache and restart, but the files stays same.
Android studio warns and suggest wrong encoding but reloading with multiple other encoding did not resolve file contents.
What should be a solution?
Should I change hardware, eg ssd? or downgrade android studio?
Please run android studio like this.
Click Android Studio and click right button on mouse, then click "Run as Administrator".
Hope it helpful for you.

Android Studio overwritten a whole project [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 text is messed up (corrupted) after plugin installation

The problem is android studio suggested a plugin installation for README.md files and after that this is what happened
I don't know what happened with Android Studio font but it is all messed up like this.
however all project files are completely fine
Problem in detail :
Android Studio suggested a plugin installation for .md files which I accepted and then another prompt popped up which said other plugins need to be installed (as a dependency) so the suggested plugin work and I accepted it and then restart Android Studio for the changes to take effect. Before Android Studio started again, it prompted me with a message
That only one these two plugins could run at the same time
- MarkDown jetbrains
- MarkDown something else(I don't remember)
I chose the first one and after that Android Studio started again and here was the problem.
What I've tried
I tried to delete the said plugins but nothing changed
I deleted .AndroidStudio folder in C:\Users\myname which actually worked but then when I tried to import my settings.jar file which I made last month and the problem showed up again
How do I solve this?
I solved the problem by not importing below option

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

Eclipse and Android error 'parseSdkContent failed'

Having this issue since I upgraded the Android Tools to 21.1. When I start eclipse, even in a clean workspace, I get the error parseSdkContent failed and the details say:
com.android.sdklib.devices.DeviceManager.createInstance
(Ljava/lang/String;Lcom/android/utils/ILogger;)
Lcom/android/sdklib/devices/DeviceManager;
I have searched the internet and tried almost every solution but to no avail. When I go to Android preferences and try to set the path to the SDK , it says no target available. Is there anything else that I can try? I can't do any of my Android Development until it's fixed.
Step 1. Find the folder named: .android
This folder can be located in your Windows user directory, for example in Windows 7 or 8:
C:\Users\YOUR_WINDOWS_USERNAME\.android
Step 2. Delete this folder .android
Step 3. Restart Eclipse and your problem will be solved.
You DON'T have to delete ANYTHING
For me updating the DDMS from ADT plugin did the trick!
Before that, to save time I only updated ADT plugin, nothing else like Android DDMS, TraceView etc., so I ran into same issue.
After a couple of restarts and Google searches everyone was proposing different solutions. I updated my Android DDMS and restarted eclipse and it worked like a charm!
I didn't have to remove my workspace or update my .project file etc.
Ok I just deleted eclipse and reinstalled. Lost all of my settings etc. but it's all I could do. Something must have gotten corrupted in the upgrade of the ADT.
I had the same issue after installing 21.1 on a new machine. Solved it by deleting the default workspace I created during the first launch and then re-starting ADT as Administrator, recreating the workspace. After closing and re-running it as a normal user the problem disappeared.
Re-installing the new version of ADT (which at the time is ADT-23.0.3.zip(http://developer.android.com/sdk/installing/installing-adt.html)) helped me with the same problem you are described above. This message may be a little to late but hope this can also help others.
Uninstalling API 21 and installing API 19 worked for me.
In Eclipse, use the Check For Updates item in the Help menu to update the Eclipse-part of your Android tools (called ADT).
Try to go to your eclipse workspace and delete the .meta folder.
I was recently having the same problem and i figured it out that one must install/update other necessary software related to ADT.Suppose you are updating your ADT then you must also update DDMS with it.So,best option is to install the all software/plugin pack for the version you are updating.
When you uninstall the full thing and install it again,all of these related software get installed in same version so it always solves the problem.
According to me re installing should be final solution.
I got mine fixed by, before restarting your IDE, make your activity main layout as the current tab open, then restart your IDE. Hope it helps :)
This did it for me.
In Eclipse go to
Project Properties -> Java Compiler and set 'Compiler Compliance Level' to 1.7
For me I delete Android 5(API 21) installed software packages from SDK manager.
I am working on API 20 ( Android 4.4w.2). It only solved my problem completely.
Delete .android folder or others didnt help me out.
Deleting ".android" is temporarily fixing the problem with me as after sometime it begins to come again ..
Here is another cause and fix that might help .. This is happening because of existence of 2 versions of SDK in the same machine but in case you have only one version (probably it is 21) just download the SDK platform for API 20 (4.4W) as there is a problem in 21's "layoutlib.jar"). start applying the following:
Close Eclipse
Navigate to your sdk folder (something like C:\adt-bundle-windows-x86_64-20140321\sdk)
Go to platforms folder -> android-21 folder -> data folder and rename layoutlib.jar (for backup only)
Copy the same file (layoutlib.jar) from your android-20 folder to this folder "android-21"
Start Eclipse
maybe you have more than one android IDE installed, for example ,you installed android studio and adt+ eclipse all,just remove one can fix this problem

Categories

Resources