Android Studio mixed codes of two different Applications - android

I was editing 2 apps at the same time. One is a new idea, where I am doing some tests and the other one that is a stable app, that eventually needs small edits.
I do not how it happened but Android Studio mixed then. In fact, AS is saying that for some activities of the second, the code is the same as the first. On the example below, even the second being java coded, it shows it as xml.
If I look at the same file outside AS, using Wordpad, for example, the code is correct, i.e. it is the original like I did (see the picture).
I tried many things like cleaning cache, closing and opening AS, so many times, so many ways, etc. but nothing works. For days I am stuck on this issue. I tried even the function ´Compare with´ but it shows the (wrong) xml code.
Was not only this Activity that appears ´corrupted´ but others of the stable one.
Any idea?
On Left is the beginning of the real code; on Right how AS shows it

Try deleting the caches folder in .AndrroidStudio and restart Android studio.
Path :
C:\Users\username\.AndroidStudio3.6\system\caches

Sometimes it does so. I met the same issue and fix it by:
On your android studio top bar, go: File -> Invalidate Caches/Restart -> Invalidate and Restart.
I'm using android studio mac.

Related

Android Studio Inspections doesn't work correctly

When I run inspect on my code it shows a warning like this:
Property "isLoading" is never used
Even though I am using that property. There are no problems with code, everything works fine, but this issue annoys me, what should I do?
You can see both warning and usage of that property in the photo below:
If the answer above doesn't work,
Go to your local drive -- Users -- Android Studio -- System
and delete the caches folder, then open android studio.
Go to file -> Invalidate Cache/Restart
Click on Invalidate Cache/Restart, a menu pops up
On the menu, click on Invalidate Cache and Restart
// Wait for android studio to restart.
I made an enormous mistake. I assumed Android Studio knew what it was doing when it said it found unused resources and I let it remove them all. It removed much needed XML id tags, it removed drawables, launcher icons.... what a mess. Has no one in Android studio land addressed this egregious set of errors? I spent a far too much time undoing all the things "Inspect code" said was wrong and I let fix only to find the app fails.
Lesson learned - never assume Android Studio knows what it is doing when it comes to inspections. Always check each before taking their often erroneous suggestion

eclipse does not read code

I am new in using Eclipse and I am facing many problems. The first is that if I write an instruction wrong - for instance: android:layout_height="wrap_contet" and not content - the IDE does not visualize any error and this is very annoying.
If I change the dimensions in the values resources the picture does not update in the render preview. I need to close the program an restart it, just then the picture gets updated.
It is like the IDE is just ignoring half of the things that I write down. I click on F5 many times to refresh but nothing gets refreshed.
First I used Android Studio and I did not have these problems.
Try This go to Project->Clean, it will provide an Updated version of your project.
First if you are using Windows then go to Window->Android Virtual Device. After you start your AVD you will get your first issue solved regarding wrong instruction it will show error on the left after saving the xml file.i need more info on your second issue.

Endless "Loading Configuration" in Design view

Every time I open an activity layout in order to view its design, I can't see anything, and there's a "Loading configuration" message. How to solve it?
Looks like this is related to the following issue: https://code.google.com/p/android/issues/detail?id=56691&q=%22Loading%20Configuration%22&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars
I had the same issue and it got solved by using the menu item: File->Invalidate Caches/Restart
Try to delete the build folder.
Here are the details:
Yesterday(2015/6/10) I faced to the same problem, and I solved it by using beyond compare:
This problem occured after a forced upgrade.
I have 2 projects, one worked(newly created) and one doesn't.
So I used beyond compare to compare the 2 projects' folders.
Luckily I found build folder of the not-worked never changed even though I clear cache, restart and rebuild it several times.
build folder deleted and everything worked fine now.
I've had this issue before, and it was usually not long after an error had come up.
Check the Event Log for errors. Usually a restart of the IDE fixed it for me though I appreciate that's not ideal. The errors weren't anything specific I think just teething issues with Android Studio - tis just preview software after all.

Eclipse hangs when trying to add menu.xml

I've recently starting developing with the android sdk. Currently, I am trying to add code to use a menu, however, when I try to add a menu.xml under res/menu, Eclipse hangs and freezes every time. When I reopen the Eclipse, menu.xml is there, but every time I try to open it, Eclipse hangs and freezes again.
I am running on OS X Snow Leopard, Eclipse 3.6.2 and the latest android sdk and adt plugin.
Any help, insight, thoughts?? I am thoroughly stuck.
Thanks.
Dustin
Thanks for the input guys. What ended up working for me was instead of trying to manually create a new menu.xml file, I find the add android .xml wizard and using it instead allowed me to add whatever I needed with out any hang ups.
Same problem happens for me even under the latest version of Eclipse (Helios). If I wait long enough, Eclipse reports a stack overflow exception and then this shows up in the Output window:
W/ResourceType( 5124): Bad XML block: header size 0 or total size 9949440 is larger than data size 0
menu.xml:1: error: Error parsing XML: no element found
This indicates that the XML parser isn't handling empty documents and the Android menu editor is barfing on the newly created file while trying to open it. I'm sure there is some "standard" way of creating a new menu that doesn't break the IDE but I have no idea what that method is. I'm too used to editing my files by hand but this crash/hang bug is a serious nuisance.
Dustin,
I think what has happened is, your settings have become corrupt. I highly recommend resetting all your settings. Keep in mind, you will have to re-import all your projects so this can be quite a pain, but I really think this will fix your problem.
To start, find your workspace folder and rename it to something like "workspace-bad"
Then, create an empty workspace folder to replace the one you just renamed.
Lastly, open eclipse and it will act just like a brand-new installation.
You will need to re-import your projects, which can be done by going to eclipse, hitting File>Import...
Then select under General
"Existing Projects into Workspace"
then hit "Next" and then hit "Browse" to find the root directory
also make sure "Copy project into workspace" is checked
I also recommend doing your "problem project" first, that way you don't waste your time doing the rest and then find out you have to re-create it.
I'm hoping that fixes it for you, good luck! :-)
-Jared
I ran into the same issue with the same setup. Right clicking menu.xml, selecting 'Open With', and selecting Xml Editor seemed to be a viable workaround for me.

Android Emulator Debugging, Code will not Update

I'm having a troubling problem testing some code for and Android app. My app has two parts, and activity where the user changes some settings, and a broadcast receiver that responds to SMS messages, both in the same package.
Here's the problem, I first implemented some simple code to test out the broadcast receiver and the activity, and both worked fine. But then as I tried to refine the code, I noticed the emulator wasn't picking up any of my changes. Event went so far as to uninstall the app from the emulator and try again, no luck. Then I added some extra Toast popups to my receiver, nothing, still running the old code. I know its running the old code because its sending out an SMS using a string constant that is no longer in the current code, so it should be impossible that it respond with that value.
Here's the kicker that has me confused. For fun I made a change to my activity. Ran the project from Eclipse and that change showed up! Tried to test the receiver code again, runs the old code that doesn't even exist anymore!!
How in the world can half the package update, and the other half not?
Can anyone help me out 'cause I'm about ready to lose my mind.
I had a similar problem. Changes made to classes imported from another project didn't get picked up by eclipse, but those made to classes in the current android project were.
Making a change to the current android project (inserting a blank line and deleting it) seemed to make eclipse pick up all the changes made and upload the app to the emulator.
I had this problem too, Now I found a working solution. Just follow these steps:
Run your project normally.
When emulator started, run your project again (DO NOT close the first emulator)
Then the updated application will be uploaded into emulator
I can't really be sure what happened but creating an new emulator image appeared to solve the issue.
I don't know why it happens but it's a problem I have all the time.
What I typically do is
Close the emulator
Close Eclipse
Reopen Eclipse
Clean the projects (in Eclipse, select Project -> Clean... -> Clean all projects)
Rerun the emulator
Annoying as hell but seems to work for me.
I'm having this problem too. It mostly happens when errors are entered into the code. The strange thing is if I go back to the original code, Eclipse doesn't revert to the original code. One thing that seems to help is to temporary delete the contents of a file, save, and rebuild, and then enter the contents back into the file, save, and rebuild.
How is one supposed to debug in such an environment?

Categories

Resources