EDIT: ** The approach below might not work if you are using Corona plugins as they might not survive the unpacking/packing process performed by apktool.**
I was bored and decided to take a break and have some fun with this Android stuff (…I know… I’m a nerd…)
I managed to get the app title localized more easily than I had thought on Android (it took me longer to write this post than it did to localize the app title :P ). Tested on Android 2.3.6 and Android 4.3.
Prerequisites:
-
Android SDK installed and configured (to be able to sign and verify the APK)
-
apktool (To unpack/pack the APKs https://code.google.com/p/android-apktool available for Mac/Win/Linux)
Step 1: Compile your app with Corona.
Step 2: Unpack the APK created by Corona. From the command line run:
apktool d your-app-name.apk
Replace ‘your-app-name’ above with the name of your APK. This will create a folder named ‘your-app-name’ in the current folder.
Step 3: Go to the /res/values folder within the folder created in step 2 (this is the folder for the default language)
Step 4: Edit strings.xml. It will contain a lot of facebook stuff, but you just need to add a line below the <resources> tag:
<string name=“apptitle”>My App Title</string>
Since this is the default language, I enter the name I want to see under my app icon in English.
Step 5: Create new folders in the /res folder for every language you want to support.
For Japanese it would be values-ja and for French the folder name would be values-fr.
In each of these folders above create a file named strings.xml with the following content:
\<?xml version="1.0" encoding="utf-8"?\> \<resources\> \<string name="apptitle"\>My Localized App Title\</string\> \</resources\>
Replace ‘My localized App Title’ with the app name written in the desired language.
Step 6: Modify the manifest.
The manifest created by Corona needs to be modified. Open AndroidManifest.xml and search for ‘android:label’.
There are two places that need to updated. Both should be modified to read: android:label="@string/apptitle".
You might need to modify the FileContentProvider’s authorities string as well.
Search for FileContentProvider and check the authorities string on the same line. It should read “com.ansca.corona.files”. If it’s anything else, change it.
Step 7: Create a new APK.
Make sure you’re in the top-level folder (the same folder as when you ran step 2)
From the command line run:
apktool b your-app-name new.apk
IMPORTANT: Do not type ‘.apk’ after your-app-name as you want apktool to read from your modified folder.
Step 8: Sign and verify your new APK
I have a small script that does this for me (see below. I’m on Mac OSX)
WARNING: This is a bare-bones script with minimal validation. You’ll need to replace three things for it to work
-
/path/to/your/keystore is the path to your own Android keystore file.
-
your-password is the password for your keystore.
-
your-alias is the alias for your keystore.
I call my script ‘signapp’ so I run the following from the command line:
signapp new.apk
#!/bin/bash if [-z "$1"]; then echo "Please specify a file to sign" exit 1; fi jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore /path/to/your/keystore -storepass your-password $1 your-alias zipalign -v 4 $1 zip-$1 rm $1 mv zip-$1 $1
Step 9: Delete your old APK and rename ‘new.apk’ to your original app name APK.
Done! Install and test on your device
Hope this helps…