I am currently trying to find out the values of $HOME and $ANDROID_AVD_HOME as I am having difficulties running an emulator.
I have searched through various posts to try and find an answer, people simply suggest "changing this variable", however I have no inkling how to find the value or location of these variables.
I would, ideally, like to know how to display their values then, if I need to, change them.
Related
I'm not sure if my question is worded correctly, but it's easier to show an image to explain my question.
In the XML editor, some values are replaced with the actual values that was defined for that entry. However, I don't want Android Studio showing me the actual values. Instead, I still prefer that it showed the reference names. So, how do you disable the editor from previewing in this manner?
In the image below, android:text="#string/sign_up", but the editor is showing it as android:text="Sign up...", as well as other attributes, and the reference name only shows up when I mouseover the attribute.
How to disable this feature permanently via Android Studio setting/configuration?
Update: Same thing is happening in .java files. Enums or R.string constants are being replaced by their actual values.
For Java files you can go to Preferences->Editor->General->Code Folding and uncheck "Android string references" but this only applies to code not to xml layouts
– Oleg Bogdanov
I fought with this for hours! Having the values show up instead of the references is great, in most cases, but I was working with a project imported from AIDE and its layouts were a mess. I need to see the references, not the values. I found the "possible duplicate" link above, mentioned by zombie, but it didn't work (or so I thought).
Finally, after reading this post, I tried unchecking the "Android string references" again, but this time I restarted Studio after (even though I wasn't prompted). If you have the same problem, the solution above should work, but save yourself (possibly) hours of aggravation and:
Restart Studio after unchecking the "Android string references" setting!
BTW, I would have added this as a simple comment, but SO wouldn't let me!
I would like to rename all of my java classes and layouts that starts with the prefix tranp_ to event_. I can do that one by one using the combination Shift+F6 but it is taking too much time (there are more than 20 files). Is there a quicker way to do that in bulk?
Although is an old question, I feel it's worth answering as there is a valid solution.
Open the project with AndroidStudio, then right click on the main project's folder, select "replace in path" and enjoy it. I just replaced 400 occurrences in less than 40 seconds, just make sure you really need to replace all statements!
There seems to be no feature implemented to rename multiple files at once through refactoring provided within the Android Studio.
I also feel the need to have such feature as I keep changing my decision to name elements of certain category to some specific manner and thus have to tediously do it one by one. Which in many cases causes the bug.
I hope the future version will have it but till then what I am doing best at the moment is use the 'ctrl+r' feature to search all the occurrences of the item and replace it with what I want to rename to. And then do it again on all places where the element has been referenced. And then at last to make sure that there are no errors caused by the recent renaming I just run it. If any errors like "resources not found" then the Android Studio does point me to the location of the error, which generally is the place I left to rename.
Although this is not a sure way but it has helped me quite a lot when you have to rename lots of elements instead of 'shift+f6'.
So since I have tried the reply before me and it didn't help, I actually did find useful to open the direct path of the files I want to change, selected all of them and just pressed on rename(On MAC). It gave me the option to replace specific letters in all of the files. Made my life much easier after changing about 30 files, and noticing I have another 250 to change at least.
TLDR: firefox for android does not show expected about:config screen.
Firefox: 39.0
Phone: Nexus 5
I am trying to install and configure an extension on firefox for Android.
I've been following these instructions, which work fine until I have to alter the filepath in about:config.
At this stage, I need to modify the settings to show firefox where a certain .txt file is. I can easily find the setting I wish to modify, but cannot find a way modify it.
The expected menu (with Modify) never shows up, and instead the only options I can get are "copy name" and "copy value".
Images of the expected interface, and actual interface:
Expected interface (from walk-through):
Actual interface (screenshot):
After searching, trying to find the modify option:
Eventually, with a lot of trial and error, got it fixed. The about:config interface has changed since the guide I was following was pasted, but it ended up being a very good step by step anyway.
Solution:
The new interface has an area where there is nothing written, which you need to over-write with the desired path (in my case it ended up being /storage/sdcard0/silent_block_directory).
Two pieces of advice to avoid making the same mistakes as I did:
1. Don't point the path at the .txt file, but rather at the parent directory
2. Don't look for the modify button, it does not exist any more.
I have no idea what's going on. I have been following some tutorials, and have properly set up my project with the NDK. I did mess around with things a bit last week, but my project still seems to work correctly. I am trying to find the NDK path but the tab is no longer there...
The Native Development tab should be where the red bar is. I know it was there sometime last week. Is it possible I deleted something from eclipse that would remove this tab?
There could be a problem with loading the NDK plugin. One thing you can do is open the Error Log view (menu Window > Show View > Error Log.)
This lists all errors internal to Eclipse. I recommend erasing the whole log and restarting Eclipse. Then you will see the errors related to loading plugins. I bet the problem is listed there.
Problem solved. The address to where I unzipped my NDK folder wasn't added to my computer's PATH variable. Strange, as I distinctly remember doing that at one point, but until that address is added to the PATH variable the option just doesn't show up in Eclipse.
If anyone knows of anyway that the PATH variable is changed other than through the users doing, please let me know. I don't remember editing the PATH variable and have no idea why I would have.
For Windows 7 Professional :
Start->Right Click On Computer->Properties->Advanced System Settings->Environment Variables
I had already had a Path variable under System variables, and a PATH variable under User variables...
In both variables, I added the address to my NDK folder. Separate the new address from the one already existing inside with a semi-colon.
The tutorial that helped me figure this out is here at step #5
My question:
How can I add or remove the language entries in the "Settings" -> "Language & keyboard settings" -> "Select Locale"(or "Select Language") in the Android phone from the source code level?
I'll provide more details on what I want and what I have done. Please excuse me if I present any silly understanding or information. I'm pretty new to Android development, starting to learn it several days ago. There is still a lot that I don't know.
More info on what I want:
I'm recently working on a task to localize the entire phone product with new languages(I mean, I'm not working on a specific application. This is why I need to add a new locale in the Settings). When I got the development phone, I found there are only several language entries available in the "Select Locale", such as "English", "French" and "Spain". So first of all, I need to add and display some new language entries to this list, such as "Japanese", "Chinese", "Korean".
I have all the source code of Android platform and my own code, so I think this task can be done by modifying the source code or the resource files somewhere. Unfortunately, I don't know where the code and files are.
The "Hello, L10N" tutorial shows a way to add a new locale from "Custom Locale" at run-time. But what I want is to add the new locales at build time so when the phone is started up, the new locales will be displayed in the "Select Locale" directly without any other actions.
What I have done:
I did a lot of research on the internet before I come here. Here is what I found:
Sinkiru in Stackoverflow asked a question about what I am exactly looking for. See it here. However, nobody else replied him. His own reply only tells where to query the CURRENT language setting, which is not what I want. I personally sent him an email for this question but haven't got his reply.
I searched a lot in Stackoverflow, with the keywords "android locale", "android language", "android new locale" and something similar. Most of the questions in this site are asking how to change the locale of an app, how to add multi-language support for an app, etc.. They are NOT what I want.
I searched a lot in the android-platform Google group(http://groups.google.com/group/android-platform). Some people are asking my question, but after reading through the messages I still don't get my answer.. :-( Here is a list of the posts I read in the group(and I do not get what I want from them):
"OS localization" - I'll talk more below.
"How to add new locale and it's associated font in android source"
"How to add new L0cale"
"Addition and Removal of language from Android Phone"
"Localization, committing new language"
"Additional languages support"
"Localization - new locale - HELP"
Back to the entry "(a)" listed above. In the "OS localization" message thread, Dianne Hackborn, an Android framework engineer, said the following:
"The settings app just shows you all of
the locales that are available in the
platform resources. Adding strings
for a new locale should automatically
have those shown in settings. You
tell the build system which locale
resources to include when it does the
build... unfortunately I can't help
you on that part, but maybe someone
else can."
His words in bold suggest that my task might be done automatically by adding new locale resource to the source code, and by setting up or changing something in the build system. I'm wondering if someone here has ever done the similar thing before? I'm going to give a try tomorrow.
Last but not least, I searched in the official Android developer site. In the "Run and Test the Localized Application" of the "Hello, L10N" tutorial it says something about the available locales in the "Settings" application, but that is basically talking about what to do in the emulator and this shouldn't be what I need. I want it done on a real phone.
I had also dived into the Android platform source code trying to discover something. I started at the $(ANDR_SRC_ROOT)/Packages/app/Settings/src/.../LocalePicker.java. In the LocalePicker::onCreate() method, I noticed this line of code:
String[] locales = getAssets().getLocales();
The code below this line tries to set all the obtained locale names to an ArrayAdapter and then set the adapter to the list view to show. Thus I think the "getLocales()" method is the key to the solution.
I then looked into the getLocales() code. getLocales() is a member method of AssetManager and is declared as native, hence I stepped into the $(ANDR_SRC_ROOT)/frameworks/base/libs/utils/AssetManager.cpp which I GUESS should be the actual implementation of the java getLocales() method. The C++ AssetManager::getLocales() finally leads me to the C++ ResTable::getConfigurations() method in which a member variable "mPackageGroups" is scanned through to retrieve all the available ResTable_config items. Thus I think all the available locales should be added into this mPackageGroups during the system started up. However, I lost in the code at last and couldn't find where the locales are added to the mPackageGroups.
you have to create "values" folder in "res" folder of android's framework-res package. Name of that new folder have to contain country code of your need ie. values-pl-rPL (the rPL part is required) for polish language (for british english: en-rGB, etc), that should be enough - if not - create strings.xml file in that folder, and add there empty "resources" node.
on HTC phones you must also modify /system/customize/CID/default.xml ... That is the file they use to specify locales on their stock roms. If the rom is a WWE, supposedly editing CID is all one need do, but this doesn't always hold true.
I think that a normal application should not add locations to the phone. There are special packages like MoreLocale 2 for that purpose. If you'd add a locale, you'd be responsible not only to provide localisation for your own application but for the whole system!
To create or add multiple languages to your application, first you have to define all you string values in the string.xml in the values folder rather than hard coding them in you program. Then you also have to have different Value folders for different languages, e.g. Value-es for Spanish and Value-fr for french. This should do the job. I dont think the application can change locale by default.
I think you have to edit the
PRODUCT_LOCALES
Present in build/target/product/languages_full.mk , and add and remove the strings assigned to this.
You can define your custom string like zz_zz and add folder values_zz_zz in each of your res folders.
Have not tried this but this might work.
Note: PRODUCT_LOCALES might be overridden somewhere else depending on your build system
For removing languages, if we remove the locale string from PRODUCT_LOCALES, it will work.
I am also looking for a way to add new languages, but just adding to this doesn't help. I think we need to update some low level files or libraries in order to add new languages.