Everything was good. Today, I opened Android Studio, and every kotlin class code and even layout and value files turned into another format like XML. I don't know what kind of strange reason it is.
I have been trying to fix this for 2 days now. even though I opened my files into some other editors(sublime, notepad)but the problem is still there.
I am attaching some screenshots MainActivity.kt.
I also tried these couple of things below
File > Sync project with Gradle files. Result: didn't solve my problem.
File > Invalidated cache/restart. Result: didn't solve my problem.
Try this.
Right-click on the file (e.g.: MainActivity.kt),
then click on "Open In", it will open your explorer window.
At this point open that file, which now you see in your explorer window, in a notepad, make a change (e.g.: adding a space where there is already a blank space)
and save the file.
Now Android Studio should see it correctly or, if not, try to restart Android Studio.
If that works, do the same for all suddenly-changed files.
I've been reversing an app, but came across a problem. The AndroidManifest.xml file is not writable.
I made sure that the file is not 'read-only' in file explorer, but it still doesn't work. And I can't find 'merged text tab(?)' sort of thing which is supposed to solve this.
Hey there can be multiple ways you can try to solve this issue:
The simplest one is to Clean and Rebuild the project.
You can go to your File -> Invalidate Caches and Restart.
Try running Android Studio in Administrator mode.
You can try this : https://stackoverflow.com/a/34705198/9062752
Let me know if any of these fixed your error.
Also note : Not sure about this library but I read a comment which says ".jar files cannot be edited", so yeah if you are trying to edit a .jar file it is not possible (I am not sure of the reason though)
dear please check your menifest file that you can show build version name and build version code in application class please remove it and check any error in your menifest file and than you can run or rebuild your project .
I changed the name of the Android Studio project folder in the Windows Explorer before I started Android Studio. Bad idea.
Now I get the error:
Gradle sync failed: No toolchains found in the NDK toolchains folder for ABI with prefix: mipsel-linux-android
And all my Activity files are replaced with one MainActivty that doesn't contains the things I've made.
Unfortunately I can't get a previous version with "show history" in Android Studio and i can,t get an older version via windows explorer "restore previous version"
I also tried to decompile it from the .apk on my phone. I got the layout and xml files but can't find my java classes.
I worked since weeks on this project and don't want to lose it.
Can anyone help me either fix the error or restore the .apk?
Thanks so much for all suggestions and ideas
First close the broken project this can be done with File > Close project
Then you have to reopen the project from the new location ie. the renamed folder.
File > Open... browse in your filesystem for the project, select the folder and press OK
Wait for the gradle to sync and hopefully you won't have any problems!
I have the same problem when updating ndk-18. You updated the NDK to version 18 and it is missing the folders/files. You can download ndk-v17 manually and extract the search folder "toolchains" to copy the missing folders/files to your folder android-sdk/ndk-bundle.
From github.
my android studio gone crazy like this please help??
file was loaded in the wrong encoding: 'UTF-8' in android studio
An encoding issue can be solved by deleting all files contained in the Android Studio "caches" folder, which can be found in "C:\Users<username>.AndroidStudioX.Y\system\caches".
Make sure that to close Android Studio before deleting.
For people in future:
I had the same problem.
I was able to solve it simply by making a copy of the project and opened the copied project.
Copied project worked perfectly fine.
Note: I got this problem because of improper shutdown of my PC.
In my case it happend after Windows died with the blue screen, here's how I fixed it:
Close Android Studio
Find a directory named .AndroidStudioX.X in C:Users/YourUsername and rename it to old.AndroidStudioX.X
Restart Android Studio and choose the renamed old.AndroidStudioX.X to import settings from.
My answer is taken from here https://stackoverflow.com/a/53476487/4277741
On Windows close Android Studio and delete its cache directory:
c:\Users\[user name]\AppData\Local\Google\AndroidStudio[XXXX.X]\caches
you have to just delete the catches folder in C:/users/"your PC name"/AndroidStudio(version code).
Sometimes it gets disturbed because of some reasons like you have shut down the PC in improper way so it won't get enough time to shutDown all stuff So all that errors occurs.
I think it would definitely work for you.
Have a nice day!!!!
:)
All you need is to remove the Android Studio settings directory, which can be found:
on Windows
C:/Users/yourusername/.AndroidStudioX.Y
on Linux:
/home/yourusername/.AndroidStudioX.Y
Close Android Studio, delete the directory, then reopen Android-Studio and open your project.
Also if it happens on a different IDE, it is the same approach.
If the issue persists, try to copy the content of your project directory into a new directory, then open the project from the new directory.
This is an old one but I just click Invalidate Cache / Restart on file option in IDE and after restart, it works.
Version Android Studio v4.1
I had to replace unknown characters(which I had in a comment) into known ones. The issue happened after resolving merge conflicts.
This is an old issue, but if anyone comes across this, what isn't mentioned above, but happening for me is that the original file on disk is intact java code. Android Studio is reading it like this for some reason.
I had the same problem and how I fixed it is that I just went to the directory where the java files for my project are located, which in my case is users/user name/AndroidStudioProjects/Project name/app/src/main/java/com/example/android/project name, and here you will find all java codes you wrote for your project just open the one making the problem with notepad and you will find your code here in the right format and perfect just copy all of it and get back to Android Studio window and delete the wrong formatted code and paste this one and wait for it to sync and that's it. If you face the same issue with XML codes just do the same thing find the directory where XML files are located.
This worked for me, I clicked on utf-8 and code is displayed in proper format.
Just rename the project folder and reopen it in Android Studio, worked like a charm!
Invalidate Cache & Restart / Clean & Rebuild doesn't work for me. The project cache corrupted after improper s/m shutdown. Just change the project dir path renaming the project, it'll work.
That's not an encoding issue. That's compiled bytecode, the content of a .class file. You cannot simply rename it into .java and expect it to work.
In android studio's (Version 1.1.0) I'm having issues getting it to highlight .java syntax properly. It is currently only highlighting Keywords, Comma, Semicolon, and comments. Other files types such as .xml are highlighting properly.
I've tried the following things...
Reinstalling Android Studio
Removing any personal settings
In "Settings -> Editor" Changed the colors to anything to see if it
worked, under General and Java
File -> Invalidate Caches
Under File Types I've declared my file as a Java source file.
Made sure Power Save Mode was turned OFF.
I ran into this problem today. In my case it was caused by Android Studio changing my "MainActivity.java" file from a Class to a Singleton.
If the file is a Class its icon in the editor or project listing will have a "c" in a light blue circle. If it is a Singleton it has a "j" in a grey rectangle.
To resolve it I did the following:
copied the file's contents into notepad
deleted the singleton file BUT I did not select "safe delete" since I don't want Android Studio to do anything clever
created a new Java Class file with the same name as the original file
replaced the contents of the new file with what I put into notepad in step 1
Then everything started working again.
Before this I'd tried the invalidation/restart and disabling power save mode but they did not work for me. I even tried rebooting my computer several times.
The .java file was located in the root directory. I moved the file to "src/main/java/org.we/" and it the syntax started working.
You should do invalidate caches and restart. It will work.