I'm trying to modify strings inside an apk, I could find almost all strings at the strings.xml file, but there are still strings I can't find as shown in the image
enter image description here
I tried to use the Ctrl + Shift + F to search in the entire proyect but no results, I even tried to search for harcoded strings but same result, are they stored at somewhere else? are they added with java code inside files? does anyone has any clue?
Clean the project and restart once check it.
Related
I have got lots of XML files in which margin and padding dimensions are hardcode I have to replace all of them in format #denem/margin_20 ....etc
I have made dimens and saved all the values I need. But I have lots of XML files it will take a lot of time for me to go and change one by one file manually
SO I want to ask is there any trick to change all the values at once in Android Studio.
Thanks a lot for Helping.
Press Ctrl + Shift + R to replace and write "50dp" with inverted commas in find field . Then in replace field write #dimen/_50dp. Replace one occurrence and if it worked as expected and replace all other occurrences.
NOTE: if you want to change this in just res folder then you can select this folder only in find and replace dialog.
The approved answer is good but then you will have to do it one by one for each dimension so you can do the following:
Press Ctrl+Shift+R to replace all.
Select layout Directory by selecting "Directory" Option
Select Regrex ".*" from right side of find text input
in find first write (?!")\d\d(?=dp")
in replace write #dimen/_$0
Then click replace all
do similar thing for (?!")\d(?=dp")
It will replace all 2 digits and 1 digit dp values to dimension. You will manually need to edit negative and floating dp values.
This issue started happening when I copied a layout into another and tried to refactor the ID in the new file. It tends to refactor the ID in the source file also.
This is quite frustrating as the layout I've designed for a particular activity gets change everytime I try to update several IDs of its views.
I'm a super beginner in Android Studio and any kinda help/guidance would be really appreciated! Thanks!!
every time you refactor something, it will change everything related to that particular item or field, if you want to refactor an ID of an item it will change it in everywhere this ID is being used.
in order to change the name you can right click and choose refactor and rename or you can press SHIFT+F6 for a shortcut, it will ask you if you want t search it in comments and strings also check that box in order to really change it everywhere that this item is being used.
If you want to rename only the ID in the xml without it being changed in the java file, you'll have to change it by hand 1 by 1 b/c the refactor option will change it everywhere it is being used in your current project.
How to find all hardcoded dimensions both in xml layout files and in code in Android Studio? I want to move them over to dimens.xml.
Basically, I want something like https://stackoverflow.com/a/39130143, but for dimensions instead of strings.
This should work -
Press Ctrl + Shift + F or Cmd + Shift + F (in mac) to search in project.
Go to Options and choose Regular Expression.
Now search "((\d)+)dp" in search bar which should give you all the hardcoded dimensions.
If you have dimensions as decimal values you can change the regex pattern accordingly. This one worked in my case.
Also, if you want to search in specific area, you can do that too with this method. Thanks.
You can search all the hard coded dimension in Android studio using Find in path.
Go to
Edit > Find > Find in path
In option tab ->
General -> select Regular expression
Scope -> You can select the sope of the search
File name filter - > you can select FileMasks as *.xml
And you can start the search now, add \ddp or [0-9]dp in Text to find.
Done you can see all the usage.
I think you have to create the custom lint for that, since currently it can check for 0dp in code and use of pixel instead of dimension.
As a user of Android Studio, I'd like to know where a string in strings.xml is used because I want to remove the strings which aren't in use.
Right click on a string in your strings.xml-> click "Find Usages" to see where it's used.
If it's not used anywhere then a little dialog will pop up in the corner saying so.
Easier way to find unused strings in Strings.xml is to launch an inspection code from top menu of Android Studio (Analyse/Inspect code) on whole project.
In the inspection window, go to "Android Lint/Unused ressources", there you will find all the unused strings.
It will avoid you to make "find Usages" for lot of strings !
I cannot figure out how to search for text inside an individual XML file from Eclipse. Basically if I am editing one of my xml layout files, and I hit CTL + H -> file search -> Selected resources radio button checked, I always get '0 results in empty scope' as my results. Google hasn`t given me any help on this.
My workaround is to choose 'Workspace' instead of 'Selected resources' and then navigate to the file I want in my search results which is time-consuming. Why doesn't eclipse recognize my current XML file as a selected resource like it does with java files? Has anyone else had this issue? I`m using Eclipse ADT 23.0.2.129578
Go to the Source tab of the layout file editor, then use Ctrl+F to open the Find/Replace dialog. You can also use Ctrl+K to traverse through matches of the last search, even when the Find/Replace dialog is closed.
You can use Ctrl + Shift + R for searching the XML file quickly in eclipse.