Yesterday everything on my app was working flawlessly but today when I opened Android Studio all the xml files were corrupt(?-not sure if this is the right term)
Every one looks like this
I had face same issue today and below are few steps which i had done and i got success to resolve this issue.
Just copy your project into another directory or change project location. and open your project again this simple step works for me.
Few more steps which i had tried may be this one works for you.
Delete all cache file from below location
C:\Users{your pc name}.gradle\caches
C:\Users{your pc name}.AndroidStudio3.2\system\caches
Sync you project gradle.
Hope this will help you. This kind of error is really frustrating.
Related
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.
Okay so Im starting work on android application development. Ive downloaded the newest sdk's. But there seems to be a problem. Whenever i create a project or save a project or edit a project a command prompt pops up
(aapt.exe)
Ive experienced some stuff with android development before and this didnt happen before. Is there a way i can put android development into "Silent" mode while working as it gets somewhat annyoing.
Thanks
AAPT is a tool that processes the ressources of your app:
The Android Asset Packaging Tool (aapt) takes your application resource files, such as the AndroidManifest.xml file and the XML files for your Activities, and compiles them. An R.java is also produced so you can reference your resources from your Java code.
So I think that you did some errors in your ressources or xml files. Eclipse has problems to detect and show these kind of errors. You should check your xml files.
There are also some links on StackOverflow:
link1 link2 link3
Hope that helps you.
Ok so I want to chisbanes PhotoView.. I'm pulling my hair out now, Been staring at the screen for over an hour and for the life of me, I cannot figure out how to get this to even import into eclipse.
I've downloaded the git so I have my PhotoView-master folder with plenty of things in there (Looks like a project tbh). But no jar?
I came across this question which was marked as answered but I simply could not figure this one out.
Android : import libraries Like PhotoView
I went through this
http://developer.android.com/tools/projects/projects-eclipse.html#ReferencingLibraryProject
But once again, there's nothing even available for me to add.
Anyone know what I need to do to actually get this loaded into eclipse and ready to reference?
Cheers in advance
Ok so I managed to get it working after hours slaving away at the screen.
First you need to move everything under the java/uk folder to the src/ folder in Eclipse. Once you do it the src/uk/... should look as normal. Next you need to go the project properties, click on Android and then change the Target Build Path to match the project you will be importing the library into.
Then just follow the instructions on the android dev webpage and then you should be able to reference the required files.
Working with library is a pain in android.
Photo view is not a jar library it is a referenced library. so you have to download the zip and import it inot ecllipse. Also if the library is built using Android Studio then you have to change folders to make it work. For eg the source code in Android Studio is in java folder while in ecllipse it is in src.
So I have a project that works totally fine in one workspace on my machine. I push it to the repository so everyone else can work on it. I go to pull it down making sure all the changes are good. I import the project into a new workspace and using eclipse with autobuild on it produces no errors.
I go to the command line and run ant clean release on the project and right before it gets to run crunch on the assets the build fails with a mulitple dex files define error. Ive checked the project high and low and compared to the other copy of it in the original workspace but for what ever reason I cant get it to build. I erase the bin and gen folders and remove all the imports and basically leave just the project, run clean in eclipse, and still get a dex define error related to one of the lib projects classes. Ive tried to find where extra copies could be but I dont find anything.
googling around for the past few days hasnt helped as the normal solutions to such a problem havent worked for me. So what is the best way to figure out where the extra class definitions are coming from so I can get rid of them and fix the repository so I can use it correctly. I have a feeling its related to one of the files in the project that I should be excluding in my gitignore but Im not sure which that would be. Any help on the matter would be greatly appreciated cause this has eaten quite a bit of time of just messing around.
When you have more than one class with the same package name this error would raise.
One of the common source of this issue is when you have for example different version on the same library.
For example your add ActionbarSherlock which in 'libs forder has it's own support library and also your project has another version of support library in it's libs folder. In such a cases you should put one version of support library.jar to all different libraries that you using it.
I hope this could help you.
I didnt find the root of the problem but I figured out a fix. I moved all the support libraries to a new root folder completely away from the android project. Once I did that and cleaned everything I then ran ant clean release and the project built fine.
I'm on Eclipse for hours now and I didn't found a solution yet for my problem even after many searches on internet: I have no more R.java file on my projects.
On just created or on my old projects, i don't have R file anymore and I tried so many solutions (uninstall, re-install Eclipse, clean my project, check all my XMLs, fix problem with android tool and so on ...)
Please someone can tell me what to do in this case?
Hey If you just updated to ADT Rev 22 :
I had the problem too. There is a new component in the Tools folder called "Android SDK Build-tools" that needs to be installed.
Step 1
Open the Android SDK Manager
Step 2
Select the newly added Build Tools and install. (If problem stays then go to Project Properties => Java Build Path => Order and Export and check Android Private Libraries, then clean and build project.
It may be necessary to repeat the process, restart the SDK Manager after the update and make sure it looks like this (all tools installed):
More info:https://groups.google.com/forum/?fromgroups=#!topic/android-developers/rCaeT3qckoE%5B1-25-false%5D
Perhaps in Project Properties -> Java Build Path -> Libraries you don't have:
Android 4.2.2 (or other version)
Android Dependencies ?
If so, then right click project - > Android tools -> fix android properties
and see if this library showed up.
Thank you all for saving me! I've spent the whole afternoon on search this error.
Finally, my project works.
By the way, I also encountered one problem which i wanna share with you:
After upgrading, even if my project has not errors anymore. During runtime, it seems it couldn't find the classes from the jars placed in \libs.
Go into Project=>properties => Java build path= > Order and Export.
Please make sure all your jars are checked.
If this problem occurs suddenly in a well working project,
the first step is to find whether the problem occurs only in the current project or in all other projects.
if all other projects in the current workspace are working then 90% problem is with XML / mainfestfile/resourse file that you edited recently.
This error is not shown as red mark we have to find out what we have done recently in these files.
try this
sudo apt-get install lib32stdc++6 lib32z1 lib32z1-dev
it solved my problem
Close your eclipse and after refreshing system, try to open Eclipse again. I think you are using Emulator along with the eclipse. It may be because of the low Memory problem (RAM) of your system. I used to face the same problem when I use Emulator
whenever there is any mistakes in any of the xmls the R goes missing when a build or clean happens so check for any xml errors in your project unless you fix it you cant get back your R on clean or build. fix the xml files and perform a clean you will have the R generated. Also check in File->properties->Builders and see if everything is checked
I was using Eclipse Indigo and nothing I tried worked. I ended up downloading Juno SR2, reinstalling the ADT, and now everything works again.
Reinstall everything and it'll work.. i.e. go back to Google SDK or w.e. you're using and download it.
Update it to latest in SDK Manager.
Go into Eclipse-Project-Prefs-Java build path-order/export TICK EVERYTHING.
problem: No R file get generated.
guess: Try cleaning project if it is old one. Else create new project with no R get generated and with no compile errors but this: no project.apk
In this case you have to check your SDK for the built-tools. May not be installed after updating SDK.
Thus download them if not download here, then put them under directory: SDK/built-tools folder. Lastly, and most important, is to Run the SDK As Administrator. This guarantees refreshing SDK with all packages appearing in it.
Install the SDK-Built-Tools or any missing packages according to the above link and you're done.
hope this helps.
Try one thing, create a new Android Project and transfer all those files which are in the previous project. That worked for me.
In my case there is error due to "&" inside strings.xml file(but error not shown) for declaring string for a array type. Now the problem has been solved as I changed "&" to "and".
So, please make sure that you do not have such silly use of symbols, and clean the project.
I have had the same kind of problem, however Rechecking all XML files in the Resources folder was helpful in my case. I found syntax error in my XML files. Cleaning and building the project again can be helpful sometimes too.
I had the dreaded not more R.java.
Some of the things I've used in the past:
Clean / rebuild (the first thing we all try)
Restart eclipse (optionally reboot pc/mac)
Update both SDK/ADT eclipse plugin to latest version
Create new eclipse workspace and import project
Enable Verbose AAPT build output Eclipse menu>Preferences>Android>Build
Port project to Android Studio / Gradle (this helped my actually see the AAPT error i was getting Error Code:138)
Delete recent XML changes - Ultimately I found deleting recent menu.xml files I'd added and commenting out where they were referenced fixed the issue and I finally got R.java.
I got the error recently and had found no fault in any layout or value file. After a lot of tries I add another Activity and the R.java was build and the error disappeared. I don't know why this occur, but it takes me hours.