[How to] XMLGenerator.jar + batch script v2.0 - Android General

I created this script to help me create redirection xml's using @nhnt11's XMLGenerator.jar found here. I may as well share it with people who use it.
You need
XMLGenerator.bat (link below).
Bulk rename utility Link.
Windows to run the .bat
Java in your environment variables path. How to
Usage of XMLGenerator.jar:
I'll break down how XMLGenerator.jar works by using the following command. If your not intersted then just scroll down.
java -jar XMLGenerator.jar framework_res -f Resources android.xml
framework res is the package/apk name added to your images to differentiate them from other images with the same name, example- "btn_check_on". This is found in the AndroidManifest.xml. You can use any name you want as long as it is consistent throughout. I'm using framework_res.
-f. This tells XMLGenerator to add redirection tags to the output.xml.
Resources is the directory containing your images/xmls to be used in the redirection.xml.
android.xml is the output name of the redirection list. Again you can name this what you choose but i advise sticking to the package name using "_" instead of "."
Running the above command would output an xml containing a list of resources from the "Resources" folder and remove the "framework_res" tag from the first drawable instance for correct redirection.
Correct output:
Code:
<item name="drawable/ab_bottom_solid_dark_holo">@drawable/framework_res_ab_bottom_solid_dark_holo</item>
Incorrect output:
Code:
<item name="drawable/framework_res_ab_bottom_solid_dark_holo">@drawable/framework_res_ab_bottom_solid_dark_holo</item>
Using the script:
The options presented in the script are:
1) Set package name.
2) Set xml output name.
3) Create redirection xml.
5) Quick create redirection xml. You can ignore options 1+2 but the output.xml will contain the package name at the first drawable instance and have to be removed manually.
9) About
0) Exit
Creating a correct output.xml
Extract the zip.
Place your resources to be redirected into the "Resources" folder with package/apk tags prefixed (replace the period " ." with an underscore " _ ").
Run the bat.
Choose option 1. Enter your package name.
Choose option 2. Enter your xml output name.
Choose option 3.You will be presented with a redirection xml to be added/modified for use with Theme engine and XTheme.
Add to created package.xml "redirections.xml"
Feel free to make improvement suggestions or leave feedback.
Credits:
@Daneshm90 and @Stericson for samples of various scripts.
@nhnt11 for XMLGenerator.jar.
The zip includes .bat, resources folder and XMLGenerator.jar
Tested and running perfect on my Windows 7 machine.
Changelog:
27/06/2013-
Fixed typo when using the package name as xml name in option 2.
08/06/2013-
Added quick create option.
Added "-f" to create command for complete xml.
Cleaned up some synatx.

Updated script and added a usage tutorial to OP.

Related

[How To] Remove Localized Resources from an apk to keep only the default english ones

Hi,
I've been facing this use case with no obvious answer in forums so here are the bits and pieces gathered around and that make up for a working way to proceed.
Required softwares:
apktool v1.4.3 (apktool web site)
Auto APK Tool v3.0.1 (Auto APK Tool topic in this forum)
7zip
WinRAR (portable edition) (for instance) or any zip manager that allows seamlessly to remove files/folders and replace files within a zip archive
Goal:
I'll illustrate this method with the Hello Expense application.
This application French translation is very very bad (as of Hello Expense v4.0.0),
and there is no way to choose the UI language within the application settings.
I wanted to find an easy method to force the application to US English instead of French.
On the under the cover side, the strings resources are compiled within a 'resources.arsc' file.
And when decompiling this file, we can see that the string resources are structured like this:
Code:
res
|-- values --> en_US resources (default)
|-- values-de
|-- values-es
|-- values-fr --> fr_FR resources
|-- values-ko
|-- values-zh
The idea is then to modify this 'resources.arsc' file to keep only the 'values' tree.
This way, the application will systematically default to en_US resources.
Steps:
Let's suppose that:
apktool is installed in the 'D:\apktool' folder
Auto APK Tool is installed in the 'D:\AutoAPKTool3.0.1' folder
Copy 'Hello_Expense_4.0.0.FREE.apk' to 'D:\apktool\original.apk'
Run the following command:
Code:
apktool -v decode original.apk original_apktool
Copy the 'D:\apktool\original_apktool' folder to 'D:\apktool\modified_apktool'
Browse to the 'D:\apktool\modified_apktool\res' folder
Delete all the 'values-xx' folders in order to keep the 'values' folder only
Run the following command:
Code:
apktool -v b modified_apktool modified.apk
Unzip with 7zip the 'modified.apk' file to 'D:\apktool\modified\'
Copy the 'original.apk' file to 'original_with_modified_arsc_unsigned.apk'
Open 'original_with_modified_arsc_unsigned.apk' with WinRAR
Inside WinRAR, remove the 'META-INF' folder
Inside WinRAR, replace (drag and drop) the 'resources.arsc' file by this one: 'D:\apktool\modified\resources.arsc'
Close WinRAR
Go to 'D:\AutoAPKTool3.0.1'
Copy 'original_with_modified_arsc_unsigned.apk' to 'D:\AutoAPKTool3.0.1\_INPUT_APK\'
Run 'D:\AutoAPKTool3.0.1\AutoAPKToolMain.bat'
Choose Task 10 (Sign Update ZIPs / APKs)
Drag and drop the 'D:\AutoAPKTool3.0.1\_INPUT_APK\original_with_modified_arsc_unsigned.apk' file
Browse to 'D:\AutoAPKTool3.0.1\_SIGN_ZIP'
Copy the 'original_with_modified_arsc_unsigned_Signed.apk' to 'D:\apktool\original_with_modified_arsc_signed.apk'
--> 'original_with_modified_arsc_signed.apk' is the file we want
--> you can copy/rename it to 'Hello_Expense_4.0.0.FREE_enUS_signed.apk'
--> whatever language your device is in, this new apk will always display the en_US (english) interface
--> no more issues with a (really) bad translation
Then you can backup the data / uninstall the multilanguage version from your device
and then install this en_US ONLY version and restore the data.
You're done
spoutnik
To keep English values, or any other language, it isn't?
RoberGalarga said:
To keep English values, or any other language, it isn't?
Click to expand...
Click to collapse
Hi,
Yes of course.
As I said, the structure in the 'resources.arsc' file is:
Code:
res
|-- values --> default resources (most of the time english resources)
|-- values-de --> german resources
|-- values-es --> spanish resources
|-- values-fr --> french resources
|-- values-ko
|-- values-zh
A French-language android will first look at a 'values-fr' folder, and then fall back to the default 'values' folder.
So if you want to keep only a specific language (let's call it XX), then the better way is probably to add the following step just before the "Delete all the 'values-xx' folders in order to keep the 'values' folder only" step:
- Copy the content of the 'values-xx' folder into the 'values' folder. Overwrite if asked to.
This way, the 'values' default folder will contain the resources for your specific language and will be used by any language version of android.
spoutnik

Sign Your APK for the PLAY Store

Hey Guys,
I found it very hard to find this method on the net. I looked for around 12 hours (over a period of 2 days). But here it is!
This method is very helpful if you need to increase the length of your signature on your apk. As Google Play has a minimum length of validity for signatures.
This tutorial contains some knowledge from other websites and some from my own self. Please feel free to use my hard work below. But try to reference me if you can. Thanks!
First of all,
jarsigner and keytool are .exe files that help create your "signed" application for release to the market to prevent fraud.
1.
Make a folder somewhere called "keytools" and make a folder in that called "key"
2. Now move your apk file to the folder keytools.
(Not inside any other folders)
3. Check
"C:\Program Files\Java\jdk1.7.0_11\bin" for jarsigner and keytools..
... or whatever jdk version you have
If you DONT have it install the following: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
4. open cmd.exe,
5. cd your way to where you have your keytools folder...
I had to do.. cd desktop, and to keytools to get to C:\Users\Matt\Desktop\keytools\
In this directory is you apk file which we will manipulate.
Now add the directory C:\"Program Files"\Java\jdk1.7.0_11\bin\ or something like that to PATH in Environment Variables.
Directions on how to do this can be found here: http://www.computerhope.com/issues/ch000549.htm
type the following now (or something similar to my example)
keytool -genkey -alias xda.keystore -keyalg RSA -validity 20000 -keystore keys/xda.keystore
Then you will have be presented with:
Enter keystore password: (type in a password you will use)
Re-enter new password: (type in same password here)
What is your first and last name? Matt <LAST NAME HERE>
What is the name of your Organization unit? (You dont NEED to type anything)
What is the name of your city or locality? <What it says>
What is the name of your state or providence? <What it says>
what is the two-letter country code for this unit? AU
is CN=Matt C=AU.....etc. correct?
[no]: yes (type yes there)
Enter key password for <xda.keystore>
<RETURN if same as keystore password>: (push enter)
6.
To add the directory of jarsigner to the PATH variable just do the steps from here: http://www.computerhope.com/issues/ch000549.htm but with the path of jarsigner. Which should be something like this: echo "PATH=/cygdrive/c/Program\ Files/Java/jdk1.7.0.11/bin:\${PATH}" >> .bash_profile
Now, type the following now (or something similar to my example) NOTE: This is all in cmd.
jarsigner -verbose -keystore key/donate.keystore -signedjar Donate_signed.apk xda.apk xda.keystore
Enter Passphase for keystore: (your password you made earlier)
DO NOT TYPE --> adding: META-INF/MINFEST.MF ....
.......
.....
...Signing: classes.dex <--DO NOT TYPE
and you're all set! you signed your apk file or whatever you wanted to create!
Congratulations.
NOW STOP BEING FRUSTRATED LIKE I WAS FOR HOURS!
Come on guys! Post what you think AKA I just bumped this thread.
I did this but the file gets signed , but when trying to install on device the signed file, it says its not signed .
LOL
Thanks but I can not do this

Auto APK/ZIP Signer in Windows

Hi XDA.
I have created automatic version of this One Click Signer:
(Click to thanx here FIRST! ->) http://forum.xda-developers.com/showthread.php?t=822388 (<- Click to thanx here FIRST!)
This version Works for Quantum of files at same time.
There are two DIRs:
Input - move here all APK and ZIP files to sign.
Output - here comes Signed APKs and ZIPs.
How to use?
1. Download auto-sign.zip from this thread.
2. Unzip it.
3. Run once autosign.bat.
4. Now, Input and Output folders was created.
5. Move all your Unsigned APK and ZIP files into Input folder.
6. Run autosign.bat again.
7. Wait until CMD windows closes.
8. Now you have Signed Your APKs and ZIPs in Output folder.
Click to expand...
Click to collapse
If you think, that is virus, or any harmful file,
you can right click on any .bat or .cmd file, and use EDIT option.
Here you can see all code, that files do.
Thanx to ASimmons, and dont forget to hit "Thanks!" button on his thread too! (link above)
Sorry for my BAD English.
//ANY PROBLEMS?
1. Output DIR is empty.
- move your auto-sign folder to root of C: drive, maybe run it as administrator.
2. Files are in output folder, but not signed
- check if you have Java Runtime SE Library, try to reinstall it.
if you have 64 bit system, and 64 bit Java, try to install 32 bit java too.
Thanks, gouster3.
Very easy to use Signer. However, using it to create an 'update.zip' package for my tablet was unsuccessful due to the 'zipalign' step at the end. So I reversed the steps as follows in "do2.cmd", then it was accepted (although this way the ZIP isn't fully aligned) :
Code:
setlocal EnableDelayedExpansion
@ECHO off
SET rom=%1
copy !rom! x!rom!
cd lib
rem zip align
zipalign -f 4 ..\x!rom! ..\signed-!rom!
rem sign the rom
java -Xmx512m -jar signapk.jar -w testkey.x509.pem testkey.pk8 ..\signed-!rom! ..\signed-!rom!
cd ..\
del x!rom!
Joe.

On device c# compiling (Revisited) with scripts and download

I revisited the work which had previously been done on the csbox thread by ssaaxx for windows 8, and created new scripts and utilities to support our current 8.1 testsigning environment.
I have created a zip file full of batch scripts, a command line signing utility (based on eisbaer82's source), and a few samples which enables compiling console and winforms apps.
You can download the attached zip, unblock it file properties, extract it to a new directory, and then you have several options :
There are four compile scripts :
compile.bat filename.cs (compile filename.cs as a console app)
compilerun.bat filename.cs (compile filename.cs as a console app and run it)
compile-winforms.bat filename.cs (compile filename.cs as a winforms app)
compulerun-winforms.bat filename.cs (compile filename.cs as a winforms app and run it)
For starters you can open command prompt, cd into the extracted files directory and compile the examples with the following commands :
Code:
compilerun helloconsole.cs
compilerun-winforms hellowinforms.cs
You can use notepad++ to set up 'run' commands such as this console 'compilerun' alias:
Code:
c:\cs-compiler\compilerun.bat "$(FULL_CURRENT_PATH)"
or a 'compilerun-winforms' alias might look like :
Code:
c:\cs-compiler\compilerun-winforms.bat "$(FULL_CURRENT_PATH)"
You can add aliases for all four scripts or just the ones you need in notepad++ and either update the directory in my examples to your actual locations or just use the file picker to browse for it and add "$(FULL_CURRENT_PATH)" after it.
If you frequently run into compiler errors and use notepad++ to launch compile scripts, you might want to add a 'pause' statement at the end of the batch file so that you can read the errors before the window closes.

[SUBSTRATUM][FULL guide] Change accent colors of non-system apps

FULL GUIDE TO CHANGE ACCENT COLORS
Hello everybody, This is my first post on xda. This guide is for those who want to change accent colors of non-system apps manually using substratum.
PREREQUISITIES
1.Rooted Android Phone
2.substratum theme engine(download from playstore)
3.Android Studio
4.Git installed on PC
5.APK tool (You can find easily on google)
6.Notepad++
STEPS
1.First of all, clone Substratum Theme Project from git into your Android Studio project
https:github.com/substratum/template (Add //)
2. Then change Theme Name,Email that is used for queries and other details in theme_configurations.xml
3.Then connect your device with the PC. Make sure ADB is installed in your computer and your phone has USB Debugging enabled.( Device Drivers should be installed too)
4.Go to the folder where ADB is installed(where adb.exe is located) and open a cmd window there(shift+right click)
5. Confirm that your device is connected properly by typing "adb devices"(without double quotes)
6.Once your device has been connected properly,you will see your device in List Of Devices
8. Then open root browser on your mobile and navigate to data/app/
9.Locate the android app folder you want to theme.(App must be installed on your phone)
Then type adb pull /data/app/com.android.yourapp/base.apk (Here change the app folder and app name accordingly.Copy the base.apk to apktool folder
7.Then open an another cmd window in to folder where apktool(jar) is located.
10.Then go to the cmd you opened in apktool folder,Type apktool_2.3.0.jar d base.apk
11.Then a folder will be created in that directory.
12.Then open the app in your phone with the device connected to pc and leave the phone with screen open(idle)
13.Go to tools->Android->Android Device Monitor->Dump View Hierarchy for UI Automator
14.Then a screenshot will get opened.
15.Moving the mouse will create a certain red boundary
16.Point it to any element you want to theme and check its resource-id
17.Then go to the folder which you created while decompiling the apk using apktool
18. Copy the path to that directory
19.Open Notepad++ and press Ctrl+Shift+F
20. Enter the resource-id you saw in "Find what" and directory in "Directory"
21.Notepad++ will search for this name in all the files of all the folders.
22. Then you will get some search results
23.Open the search result wherever you see background color code
24. Copy the line you want to change
(YOU CAN ALSO CHANGE THE COLORS USING COLORS.XML PRESENT IN res/values/colors.xml)
25.Then open Android studio and delete all the folders INSIDE the OVERLAYS FOLDER
26.In overlays folder,create a folder named com.android.(yourapp) and inside that folder create the whole directory of the file you edited) For example-> If you edited colors.xml,then create res folder and inside it create values then create a xml file named colors.xml
27. Inside that XML file inside the resources tag, paste the line you copied (The one you want to edit).
28. Compile and run the project on your phone(You will see the substratum theme installed on your phone with your app as a option)
29. Apply it and see the difference
(TIP: If you want to interchange white and black colors of the app, edit colors.xml and change all the white colors to black.After doing this,check whether all the colors are as desired. If not,change the color of a specific element manually as in this tutorial)
30. VOILA.!! You just made your first Substratum Theme. Good luck Themer...!!
(This method works on most apps)
Do ask if u have any query
Dosen't work
rohan_asthana said:
FULL GUIDE TO CHANGE ACCENT COLORS
Hello everybody, This is my first post on xda. This guide is for those who want to change accent colors of non-system apps manually using substratum.
PREREQUISITIES
1.Rooted Android Phone
2.substratum theme engine(download from playstore)
3.Android Studio
4.Git installed on PC
5.APK tool (You can find easily on google)
6.Notepad++
STEPS
1.First of all, clone Substratum Theme Project from git into your Android Studio project
https:github.com/substratum/template (Add //)
2. Then change Theme Name,Email that is used for queries and other details in theme_configurations.xml
3.Then connect your device with the PC. Make sure ADB is installed in your computer and your phone has USB Debugging enabled.( Device Drivers should be installed too)
4.Go to the folder where ADB is installed(where adb.exe is located) and open a cmd window there(shift+right click)
5. Confirm that your device is connected properly by typing "adb devices"(without double quotes)
6.Once your device has been connected properly,you will see your device in List Of Devices
8. Then open root browser on your mobile and navigate to data/app/
9.Locate the android app folder you want to theme.(App must be installed on your phone)
Then type adb pull /data/app/com.android.yourapp/base.apk (Here change the app folder and app name accordingly.Copy the base.apk to apktool folder
7.Then open an another cmd window in to folder where apktool(jar) is located.
10.Then go to the cmd you opened in apktool folder,Type apktool_2.3.0.jar d base.apk
11.Then a folder will be created in that directory.
12.Then open the app in your phone with the device connected to pc and leave the phone with screen open(idle)
13.Go to tools->Android->Android Device Monitor->Dump View Hierarchy for UI Automator
14.Then a screenshot will get opened.
15.Moving the mouse will create a certain red boundary
16.Point it to any element you want to theme and check its resource-id
17.Then go to the folder which you created while decompiling the apk using apktool
18. Copy the path to that directory
19.Open Notepad++ and press Ctrl+Shift+F
20. Enter the resource-id you saw in "Find what" and directory in "Directory"
21.Notepad++ will search for this name in all the files of all the folders.
22. Then you will get some search results
23.Open the search result wherever you see background color code
24. Copy the line you want to change
(YOU CAN ALSO CHANGE THE COLORS USING COLORS.XML PRESENT IN res/values/colors.xml)
25.Then open Android studio and delete all the folders INSIDE the OVERLAYS FOLDER
26.In overlays folder,create a folder named com.android.(yourapp) and inside that folder create the whole directory of the file you edited) For example-> If you edited colors.xml,then create res folder and inside it create values then create a xml file named colors.xml
27. Inside that XML file inside the resources tag, paste the line you copied (The one you want to edit).
28. Compile and run the project on your phone(You will see the substratum theme installed on your phone with your app as a option)
29. Apply it and see the difference
(TIP: If you want to interchange white and black colors of the app, edit colors.xml and change all the white colors to black.After doing this,check whether all the colors are as desired. If not,change the color of a specific element manually as in this tutorial)
30. VOILA.!! You just made your first Substratum Theme. Good luck Themer...!!
(This method works on most apps)
Do ask if u have any query
Click to expand...
Click to collapse
It doesn't work on xposed installer .
substratum isn't showing xposed installer in it's overlays.
Thanks for the post.

Categories

Resources