I'm having trouble using the refactor feature in eclipse (Indigo on Win7 64) to move my hard coded strings to the string.xml file.
Automatic Code Generation for Strings.xml from Eclipse
It creates the entry in string.xml ok but when it builds the appropriate code, part of the code can be duplicated and the resulting code is nonsense. For example:
...setText("Inbox")
becomes:
...setText(R.string.inboxg.inbox)
instead of
...setText(R.string.inbox)
This behavior varies depending on the length of the line and what is being replaced.
Anyone seen this before, know of a fix?
I've had a very similar occurrence happen to me when refactoring the package name. I can't really see a way to fix this (besides a global find and replace), perhaps an issue needs to be submitted:
Android google code issue repository:
http://code.google.com/p/android/issues/list
I've done a quick search through the issues and couldn't find anything related.
Related
I actually don't remember what I did/installed precisely, but it should be something along the line of "installing Java Debugger". This is giving me a lot of(more than one thousand) .project untracked files, even if I delete them, they pop back up again.
Edit: Just found this link: What project files does Visual Studio Code create via its Java extensions? , it seems like the question is the situation I'm in right now, but the answer is still very confusing. So what should I do?
Thank you!
I have an android project with a package name like com.example.alexander.app and I want to change this to a name containing only three parts, like com.alexapps.firstapp. However, after searching several sites, I still have no idea how to do that in AndroidStudio (2.1.3).
I found the following answer, which do not fully answer my question:
Answer 1 requires the file R.java which I cannot find
Answer 2 looked very good by using methods in AndroidStudio. Unfortunately, even after cleaning and rebuilding the project, the package name was not changed on my single activity.
Answer 3: I searched for the string, and found more than 1000 hints!! Therefore I have not continued with this solution to replace more than 1000 hits, as this does not sound right. I have only 1 (one!) single activity in this test app...
Answer 4: Very good answer, but only useful if you want to change each of the package name parts (and neither increasing nor decreasing the number of parts in the package name).
So is there a way to remove a part of a package name with AndroidStudio?
The easiest thing to do is right click the folder/package, and refactor.
This however i think is limited to the final folder, and does not remove a hierarchy.
So the solution in this scenario, is to
create a new folder
move all the folders/files into it. (this should initate a refactor on each file)
Rename any references to your activities etc in the manifest to the correct package names (it should have done this for you)
Clean and rebuild (to fix the R file)
I'm trying to set up a simple helloworld demo with Sphinx 4.0 (which is apparently a beta?) I downloaded the source and added it as source to Eclipse, but the problem is, it doesn't recognize a lot of the classes. I've been looking, and as far as I can tell, the classes it wants just aren't there! For example, the line:
import javax.speech.Central;
throws a compiler error, saying something about how the import couldn't be resolved. Is this a part of a bigger API I was supposed to download before trying to do Sphinx4? It didn't say anything about any other API but I'm open to the possibility.
If you want, I can post a list of all the imports that can't be resolved, I will, but that means looking through all the code which is kind of a pain. I have a hunch that I need to download the JSAPI, but I don't know which implementation would be good for Sphinx4.
Links to Sphinx4 downloads:
http://sourceforge.net/projects/cmusphinx/files/sphinx4/1.0%20beta6/
http://cmusphinx.sourceforge.net/
EDIT: In addition, I've found a few lines that I think might mean I need to download JUnit? Again, I'm not totally sure how to set this up.
The great thing about this site is that the simple act of typing out a question and nervously analyzing it before finalizing any revisions (because, after all, someone WILL read this!) 95% of the time I answer my own question within 5 minutes of posting it.
Anyways, the solution was simple, I downloaded junit4-10.jar and jsapi.jar and added them to my Java build path. Then, I got more errors, and I said TO HECK with building from the source (which I was doing with sphinx4 here) and I just downloaded the already-built library and it works great. Got the HelloWorld I wanted!
I'm at my wits end with this Java Bridge, after trying to force it to do what I want in C# I've abandoned the idea and started to stagger my way through Visual C++, however I'm running into constant problems which I'm slowly resolving. Except this one!
I'm missing an include file called AccessBridgeDebug.h. << TL:DR read here.
I can't even compile ANYTHING that uses the includes for AccessBridge because they all reference the debug file, and it just flat out does not come with the package I downloaded, or the one prior to it on the website. Google yields 0 results for the search term "AccessBridgeDebug.h" which has caused me to realise I rely on google far too much.
Please, someone, help.
For those who have the same problem, the solution was fairly simple. The Java Access Bridge 2.0.2 only contains updated files, not the entire package. Furthermore, there is no readily available download link to the 2.0.2 full installer.
To fix it, go here: https://www.oracle.com/java/technologies/java-archive-downloads-java-client-downloads.html#accessbridge-2.0.1-oth-JPR (Located accessbridge-2_0_1-manual_install\src\bridge\src\AccessBridgeDebug.h)
And download the 2.0.1 full source. All the missing header/c++ files can be found in here.
I'm new to Eclipse/Android development so I'm hoping this is something basic that I'm just doing wrong. Basically I've been playing around with developing Android apps and I was editing one earlier. I changed my main.xml file and when I went back to my class that runs the app all references to the "R" class were broken. I looked in the "gen" folder (Generated Java Files) and saw that the class was completely gone from the solution.
I had been debugging not 5 minutes before and didn't have any problems doing so. The only things I had done since debugging were moving 2 files from the "drawable-hdpi" folder to the assets folder and I had edited the "main.xml" file.
I've tried cleaning the project and restarting Eclipse but neither of those ideas worked. Any suggestions?
Check your main.xml file. If there is a fault in it (invalid XML, wrong element name, etc), then the R.java file may not be generated properly and you will have broken references.
Also make sure that the XML file itself does not have broken references (to strings, colors, and other kinds of assets).
Re-examine properly all that has changed since the last time your application was working.
I have been in your situation before. I dont have direct answer.
I assume you still learning Android (Like me) ...
The best thing is redo or rewrite the code from the beginning.
It sharpen your skill, and sometimes in the middle you find the answer.
It more quicker, Rather than staring the code and try to fix it.
It work for me, but need patient (which sometimes, I dont have it ...)
;)
I have had this problem also.
By typing an error in one of the xml files, R Class couldn't be generated.
Eclipse then is so friendly of adding an import to Android.R automagically.
This is often overlooked.
Fixing the xml-file errors will regenerate the R class. But your code is not linked anymore to your.own.namespace.R But to Android.R and there it will not find your items.
Removing the Import Android.R from the top of your file fixes this problem.
To be sure if the R class is generated, but wrongly imported, you can look under the folder "gen", there should be R.java file.
You could also try by typing your.own.namespace.R. and see if the intellisense shows your items then.