Android Studio does not reflect my xml changes - java

When I do any changes in xml layout file, it doesn't reflect with new compilation build although R.java is generated but when I run the application changes doesn't reflect. I need to rebuild the whole project which is taking time. Any help on this?
I guess before it was working fine.

Yes Sometimes it also happens to me. If you are doing changes i right way in the Xml file then those must be appear when you run your app. But if it does not happen, then you need to rebult your application, or clean it several time. if it also does not work to you then do the follwoing :
Close and re-open (Restart) the android studio and try running app again.
If step 1 is also not helpful then Uninstall app from your device , Disconnect and connect device again and rebuilt/Run app directly in your device again.
I hope this will work for you.

Pleas check if you have enabled Power save mode (File -> Power Save Mode) which turn off auto compilation
Android Studio - Auto complete and other features not working

I "touch" AndroidManifest.xml and that forces a build. Does not take nearly as long as rebuilding project or restarting emulator. It's a hack, but hey, it's my hack.

This sounds similar to my situation. I had an extra quote character in my colors.xml file, which caused errors when I tried to run my app. What worked for me was to remove the extra quote in my colors.xml file. Then I saved the file. Then I restarted Android Studio.

You can simply switch to project view and remove the build of the app:

After a few days of fighting this issue, I solved it by deleting all "v26" directories inside the "res" directory, since the activity was using it instead of the usual "layout" directory for accessing the xml.
app/src/main/res/layout-v26/
had to be deleted and you should remain only with
app/src/main/res/layout/
Anyway, I am new to android development and am not sure if this can lead to other issues, so be careful.

Related

Eclipse: User Library Settings Not Saving

I'm working with Eclipse, and I've ran into this weird problem where my User Library settings won't save. Here's the peculiar part: they save for the current session, but when I close out of Eclipse and re-open it, the settings are reverted.
I'm trying to remove the follow parts from my library:
When I remove them, they're gone, but when I reboot Eclipse, they're basically right back here in the library again. It's causing issues because those parts aren't needed/even physically present anymore.
I've tried the following to remedy the issue:
Deleting my workspace
Deleting project Classpaths
Deleting the entire library and re-adding it
I have no idea where the hell this is coming from at this point. That's why I'm here. Pls send help.
I wasn't able to fix this problem, but the way to work around it is by simply making a new library and using it instead. It seems that it'll still update and save new libraries, just this one was locked for some reason.
The way I personally got around it was by putting the JARs into the classpath directly instead of using a user library.

Android - Create second instance of my app

I have created my first app using Eclipse and now wish to implement NFC into it. However I don't want to add it yet to my first app in case I encounter problems. I wish to copy and paste my app into Eclipse a second time so I can have 2 versions in my workspace (App1 & App1NFC).
Is copying and pasting and then renaming the NFC version a safe way to do this. I'm worried the Java source files may conflict each other. Will renaming the project name sufficient enough or will I have to change other things in the manifest/res folders etc?
Thanks
You might want to look into using a version control system such as git. You could create a branch with the NFC code and then be able to switch back and forth pretty easily.
If you want two apps to run on the same device then the package names should not be identical to each other so that they won't conflict with each other.or else installation of the existing app will be replaced by installing app.
i.e
If app1 has the package name as com.mycompanyname.myappname
then make sure the other app doesn't have the same package you could rename it into something like com.mycompanyname.myappname1
You can just copy the entire folder and rename it to whatever you like.Then you can open it as another project
Btw
Why don't you use Android Studio?

No known package error. Android 5.0

I've been developing using the Android L preview. Today I've spent all day trying to set up eclipse so that I can develop using the new APIs. I've run into so many problems, and have hashed most out by just making a new workspace.
A persisting problem is the one shown below. These resources are in the R.java file and are in the resource folder. I haven't moved anything or changed anything about the project other that the target build sdk. The error is occurring any time I try to access a resource using the format R.XXX.XXXX. What could the reason be? Any ideas?
EDIT: NEW ANSWER
Something was just bugging out. Not sure what, but after re-downloading the bundle, downloading API 21, restarting laptop etc etc my same project is running just fine. Hopefully this isn't temporary.
Bundle: https://developer.android.com/sdk/index.html?hl=i
PREVIOUS ANSWER: Some of my resources had digits in the filename.
This doesn't seem to be documented. I found this by first trying to start from scratch, building up my app in a new project. This worked until I had to make a big jump, adding lots of activities at the same time due to dependencies, and this caused the same error to occur. I then starting bit by bit stripping down my app. Found that upon deleting those resources, the errors subsided.
I thought that a-z and 0-9 were allowed. Files with these characters worked just fine in previous Android versions, but it seems that updates made when switching to Android 5.0 makes 0-9 invalid.
Can anyone else confirm this?

Save code before running android emulator?

Do I need to save before running the android emulator on eclipse.
I get the error MainActivity.java has been modified. Save changes?
Can I not save?
Thanks
If you were to run without saving, your new code would not be compiled and the emulator would not run the code you had just typed. If you are not sure about a change or want to keep older versions, just use the Save As command and keep multiple versions.
The answer to your question is Yes, as ADT would check up the changes in the code, else the previous non updated code would be executed. There will be also a case where you have rectified a problem in your project and you will be still be facing it in the execution if the project is not saved.
You're answer can be found here
The answer, is yes. Yes, you have to save it.

java files missing in scr folder in each Activity (eclipse)

Details: I have reinstalled eclipse 3 times, updated it & the ADT and DDMS, too.
I have found out that when I create a new android project the scr file is nearly empty. In each Activity there is only one java file and the rest is missing. I have attached a screenshot from the Maste/Detail flow activity so that you see where the problem is.
If you can help me please leave a response.
This is not a bug - it might generate additional files
depending on what starting activity you choose e.g. login activity it requires additional logic for working with Google+, however most will contain all the logic for a specific activity in a single source file, the source code included in the source files will often be minimal to make sure the activity works without the developer having to manually implement things they might otherwise not know about e.g. the fragment activity.
You might want to try out android studio instead if you are not dependent on eclipse as android seems to be moving towards using it and gradle.
(I do use android studios and am currently working on android apps and even though it's in beta it has not given me any problems)
This is a reported bug. Refer to https://code.google.com/p/android/issues/detail?id=72571
To solve the problem, look for ftl files in the tools\templates\activities subfolder of the SDK. In the files found, change <#if appCompat> to <#if appCompat?has_content>, and ${appCompat?string('Fragment','')} to ${(appCompat?has_content)?string('Fragment','')}.

Categories