I planned to change the package name through smali(reverse)
when I open up apktool.yml, I saw this
forced-package-id: '127'
I have tried to change it but it crash
why should i do?
Assuming your goal is to rename the package name of the apk, the package names used for the classes are irrelevant. The package name of the apk is mostly unrelated to the package names of any classes in the apk. And there's no reason you need to touch the package id.
I would recommend unpacking the apk with apktool, and then edit the apktool.yml, setting renameManifestPackage to the new package name. Then when you rebuild the apk with apktool, it should use aapt's --rename-manifest-package functionality to change the package name.
After that, just resign the new apk and you should be good to go.
apktool d app.apk
// change "renameManifestPackage: null" in app/apktool.yml
// to "renameManifestPackage: my.new.package"
apktool b app -o new_app.apk
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ~/my.keystore new_app.apk mykeyname
And just to reiterate, you don't need to modify the package names of any classes.
To my knowledge there are no fast ways to change the package name.
You have to change the package="com.mycompany.myapp" in Manifest.xml and then manually replace all the package name occurrences in smali files (and folders). Finally edit apktool.yml replacing the old package name, with your new package name.
A full detailed tutorial can be found here: http://forum.xda-developers.com/showthread.php?t=2760965
I've tried different approaches but the most reliable for me has been the method described here:
https://forum.xda-developers.com/t/how-to-guide-mod-change-package-names-of-apks.2760965/
These are the steps:
Decode APK (using apktool)
Edit apktool.yml
Edit AndroidManifest.xml
Rename smali subfolders
Search & Replace *.smali (using Notepad++)
Build APK (using apktool)
Sign APK (using apksigner)
Tools needed:
Apktool - https://ibotpeaches.github.io/Apktool/
Notepad++ - https://notepad-plus-plus.org/downloads/
apksigner - https://developer.android.com/studio/command-line/apksigner
Download apktool and wrapper script to C:\apktool.
Let's assume you want to modify from/to as specified here:
From: XVipreSettings.apk (Package name: com.xvipre.settings)
To: ModdedApp.apk (Package name: com.modded.app)
1. Decode APK (using apktool)
apktool.bat d XVipreSettings.apk
2. Edit apktool.yml
apkFileName: XVipreSettings.apk
...
renameManifestPackage: null
is changed to:
apkFileName: ModdedApp.apk
...
renameManifestPackage: 'com.modded.app'
3. Edit AndroidManifest.xml
package="com.xvipre.settings"
is changed to:
package="com.modded.app"
4. Rename smali subfolders
move .\XVipreSettings\smali\com\xvipre\settings .\XVipreSettings\smali\com\xvipre\app
move .\XVipreSettings\smali\com\xvipre .\XVipreSettings\smali\com\modded
5. Search & Replace *.smali
Start Notepad++
Menu > Search > Find in Files... (Ctrl+Shift+F)
Find what : "Lcom/xvipre/settings"
Replace with : "Lcom/modded/app"
Filters : "*.smali"
Directory : "C:\apktool\XVipreSettings\smali\com"
Press Replace in Files (may take a few minutes)
6. Build APK
apktool.bat b XVipreSettings -o ModdedApp.apk
7. Sign APK
(I'm assuming 31.0.0 here yours may be different, also if you don't want to sign using debug certificate you need to modify this step accordingly)
%homedrive%%homepath%\AppData\Local\Android\Sdk\build-tools\31.0.0\apksigner.bat sign --ks %homedrive%%homepath%\.android\debug.keystore --ks-pass pass:android --key-pass pass:android C:\apktool\ModdedApp.apk
Related
it's my first time using bitbucket pipelines, I want to build an signed apk, I have the script, it generates the apk already, however, it seems there is something wrong on the signature, I've been trying to figure out why but I have had any success.
As you see on the script above, I'm generating the apk, I've created some repository variables to pass the signature data, so once the apk is ready, I use the following command to verify the apk signature :
keytool -printcert -jarfile app-debug.apk
then I see the signature data does not match with the apk signed by the ide (using the same certificate,jks, passwords and alias)
I hope any of you can help me, thanks.
I had a similar issue, be sure you are correctly encoding/decoding your .jks file...
encode:
base64 -w 0 my_keystore_file_name.jks > envout.txt
copy the contents of envout.txt to $DEBUG_STORE_FILE_BASE64 repository variable. Meaning you open envout.txt (in notepad or something) select all ctrl+a and copy ctrl+c
decode:
echo $DEBUG_STORE_FILE_BASE64 | base64 -d > my_keystore_file_name.jks
it may not matter, but $DEBUG_STORE_FILE should just be filename, and if you still have issues you could try to not use a secured repository variable, or move the file after its created:
mv $DEBUG_STORE_FILE keys/$DEBUG_STORE_FILE
or
cp $DEBUG_STORE_FILE keys/$DEBUG_STORE_FILE
I'm working on Ionic project now whereby I want to zipalign the android-release-unsigned.apk file. I followed this guide by Ionic.
When I run zipalign -v 4 /Users/zulhilmizainudin/Desktop/kl-parking/platforms/android/build/outputs/apk/android-release-unsigned.apk android-release.apk command, I get -bash: zipalign: command not found error.
This is where zipalign sit in my system:
/Users/zulhilmizainudin/Library/Android/sdk/build-tools/21.1.2
I tried to copy zipalign inside it and put it inside my Ionic project folder and run the zipalign command again. But still get the same command not found.
What should I do now?
Solved!
I copied zipalign file from my Library/Android/sdk/build-tools/21.1.2 into my Ionic project folder
I add ./ in front of the zipalign command like this - ./zipalign -v 4 /Users/zulhilmizainudin/Desktop/kl-parking/platforms/android/build/outputs/apk/android-release-unsigned.apk android-release.apk
Done. Now I get android-release.apk inside my Ionic project folder.
Thanks to Michael for the solution!
If you're using Windows, the right way is to add path to zipalign.exe as PATH environment variable.
Finding where zipalign.exe is located in your PC, in my case this was
C:\Users\random-username\AppData\Local\Android\sdk1\build-tools\24.0.1
Then add this location as one of the entries in your PATH environment variable.
To avoid specifying or navigating to your sdk/build-tools/* directories each time you intend to build release version, you can simply add the path to your environment variable.
$ sudo nano ~/.bash_profile
copy and paste the below:
export PATH=${PATH}:/Library/Android/sdk/build-tools/21.1.2
You can then save and exit:
control + o // to save to file
control + x // to close the file
$ source ~/.bash_profile
You can then run your zipalign command from your project CLI directory.
This worked for me on Mac. Install and run Android Studio (important to start it one time).
Then find zipalign:
find ~/Library/Android/sdk/build-tools -name "zipalign"
Windows
the right way is to add path to zipalign.exe as PATH environment variable.
Finding where zipalign.exe is located in your PC, in my case this was
C:\Users\username\AppData\Local\Android\sdk1\build-tools\29.0.2
Then add this location as one of the entries in your PATH environment variable.
MAC
To avoid specifying or navigating to your SDK/build-tools/* directories each time you intend to build a release version, you can simply add the path to your environment variable.
$ sudo nano ~/.bash_profile
copy and paste the below:
export PATH=${PATH}:/Library/Android/sdk/build-tools/21.1.2
You can then save and exit:
control + o // to save to file
control + x // to close the file
$ source ~/.bash_profile
You can then run your zipalign command from your project CLI directory.
if you are making ionic release build then you can make build.json file on your app's root folder with these information given below
{
"android": {
"release": {
"keystore": "Your keystore",
"storePassword": "password",
"alias": "alias name",
"password" : "password",
"keystoreType": ""
}
} }
make sure that you can place your keystore on your app's root folder or provide full path of your keystore at keystore object
now just you can run this command as below
ionic cordova build android --release
this command automatically find your build.json and make signed release build.
Solved!
I copied zipalign file as Michael Said
( from my Library/Android/SDK/build-tools/28.0.3 into my Ionic project folder)
BUT when I run
./zipalign -v 4 app-release-unsigned.apk botellamovil.apk
I got
./zipalign: ERROR while loading shared libraries: libc++.so: cannot open shared object file: **No such file or directory**
So, I also copied lib & lib64 files, and then it Works!!
I hope it will be helpful :) (and sorry for my English)
You should do (align, sign, and verify)for APK.
In mac, you should do the following steps:
A - Aligning APK:
1- you should locate zipalign your build tools inside android SDK:
/Users/mina/Downloads/sdk/build-tools/29.0.3/zipalign
2- you should locate your unsigned apk:
/Users/mina/Desktop/apks/app_unsigned.apk
3- you should run command contains:
zipalign_path + -v -p 4 + unsigned_apk_path + output_aligned_apk_name
/Users/mina/Downloads/sdk/build-tools/29.0.3/zipalign -v -p 4
/Users/mina/Desktop/apks/app-unsigned.apk app_aligned.apk
4- output is Verification successful
B - Signing APK:
1- you should locate apksigner your build tools inside android SDK:
/Users/mina/Downloads/sdk/build-tools/29.0.3/apksigner
2- you should locate your release-Keystore in your pc:
/Users/mina/Desktop/keys/release-Keystore.jks
3- you should run command contains:
apksigner_path + sign --ks + release-Keystore_path + --out + output_signed_apk_name + from_aligned_apk_name
/Users/mina/Downloads/sdk/build-tools/29.0.3/apksigner sign --ks
/Users/mina/Desktop/keys/release-keystore.jks
--out app_signed.apk app_aligned.apk
4- enter your key store password
C- Verifying APK:
1- run the following command : apksigner_path + verify + app_signed.apk
/Users/mina/Downloads/sdk/build-tools/29.0.3/apksigner verify
app_signed.apk
Notes: you may find some warnings:
WARNING: META-INF/....
Here is some description about that:
Apk Metainfo Warning
In practice, these files are not important, they're mostly versions of libraries you depend on, so even if someone modified those, it wouldn't have any impact on your app. That's why it's only a warning: those files in your APK can be modified by someone else while still pretending that the APK is signed by you, but those files don't really matter.
D- find your signed APK:
/Users/mina/app_signed.apk
I solved this problem by making the zipalign path an environment variable:
export ZIPALIGN_PATH=~/Library/Android/sdk/build-tools/30.0.3/zipalign
Then I replaced zipalign with $ZIPALIGN_PATH in the script I was trying to run
I'm running into several problems since I installed Kali from the USB live installer.
I found out that I needed to add this into my sources.list file in /etc/apt folder.
Just replace the content of sources.list with:
deb http://http.kali.org/kali kali-rolling main contrib non-free
deb-src http://http.kali.org/kali kali-rolling main contrib non-free
deb http://old.kali.org/kali sana main non-free contrib
deb http://ftp.de.debian.org/debian wheezy main
How do you easily compile and deploy your APK packages to the Google Play Store? i have been searching around for the easiest way i could find for my setup and ended up doing the following below? Would you suggest a better way for this?
"Can you sign and zip align your APK file from within Android Studio using a GUI, not by using the terminal?"
Two Batch Files to assist with your deployment process
The following batch file i created to speed up the testing of my APK files across various devices as i also develop a few person Android to Arudino communications.. So i may need a APK ready after a single change of code/syntax. Anyway... What do they do?
Compile, Sign, ZipAlign (Android Studio Version)
Uses Gradle (Included with Android Studio) to compile your project as a release version
Copies the release APK from the project folder to a relese folder of your own
Uses jarsigner to sign the APK file with your KeyStore file
Uses ZipAlign to create a new copy of the APK ready for google Play Store.
Deletes the original file that ZipAlign leaves behind
complile_release.bat
#echo off
REM Modify the variables between the lines to match your installation and project
REM ----------------------------------------------------
set sKeyAlias=MyProjectNameAlias
set sStorePass=MyPassword
set sPathKeyStore=C:\Projects\Android\Key_Stores.keystore
set sFileTmp=igetdeleted.apk
set sFileOutput=MyProjectName.apk
set sPathOrigAPK=C:\Projects\MyProjectFolder\MyProjectName\build\apk\MyProjectName-release-unsigned.apk
set sPathOutput=C:\Projects\Releases
set sPathJavaBin=C:\Program Files\Java\jdk1.7.0_10\bin
set sPathAnTools=C:\Program Files\Android\android-studio\sdk\tools
set sPathGradle=C:\Projects\MyProjectFolder\
set sDriveGradle=%sPathGradle:~0,2%
REM ----------------------------------------------------
REM -- Navigate to gradlew.bat folder and execute with "aR" for a release version
%sDriveGradle%
cd %sPathGradle%
call "gradlew.bat" aR
REM -- Copy the compiled APK to our output/release folder
copy "%sPathOrigAPK%" "%sPathOutput%\%sFileTmp%" /Y >nul
REM -- Sign the APK package
"%sPathJavaBin%\jarsigner.exe" -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore "%sPathKeyStore%" -storepass "%sStorePass%" "%sPathOutput%\%sFileTmp%" %sKeyAlias%
REM -- Zipalign the APK package (This creates a copy)
"%sPathAnTools%\zipalign.exe" -f -v 4 "%sPathOutput%\%sFileTmp%" "%sPathOutput%\%sFileOutput%"
REM -- Delete the original from the zipalign output the APK package
del "%sPathOutput%\%sFileTmp%"
REM -- Awaiting user input before closing the window
pause
Viewing APK SHA1 Value
The following batch file with simply let you view the SHA1 key or other details as you need
view_sha1.bat
#echo off
REM Modify the variables between the lines to match your installation and project
REM ----------------------------------------------------
set sKeyAlias=MyProjectNameAlias
set sStorePass=MyPassword
set sPathJavaBin=C:\Program Files\Java\jdk1.7.0_10\bin
set sPathKeyStore=C:\Projects\Android\Key_Stores.keystore
REM ----------------------------------------------------
REM -- This will use the Java keytool to display the some information about the APK including the SHA1 key as required for google
"%sPathJavaBin%\keytool" -list -v -keystore "%sPathKeyStore%" -storepass "%sStorePass%" -alias "%sKeyAlias%"
REM -- Awaiting user input before closing the window
pause
I hope these two can be of some help / use to people
Is it possible to specify the package path for R.class ?
The R class package is using the package path specified in the AndroidManifest.xml
The reason I ask that because I am trying to deploy the same codebase to different application.
The difference between the apps will be the image and text. while code logic remain the same.
To deploy the same code to multiple apps require unique package name for each app in the AndroidManifest.xml.
The problem is when the package name change, R is regenerated. All java file import for R is invalid with the outdated package. And I have to modify each java file for the R.class import. If I can specify a common path for R. This problem will be solved.
You no need to go every screen to change import com.packagename.R.
1) press ctrl+h
2) Select "File Search" tab and enter your old packagename to search
3) Press "Replace" button
4) Give your new package name to replace with.
5) Clean build and enjoy.
If your using Linux machine single command do a trick
find yourprojectpath -type f -exec sed -i 's/com.oldpackage.name/com.new.packagename/g' {} \\;
According to the 'help' target documentation:
debug: builds the applications and
signs it with a debug key
release; builds the application: the
generated APK file must be signed
before it is published
Here is what I found, which is a bit different than what I expected:
debug: ignores keystore definitions in build.properties whether you specify them or not. Which kesystore file is it using? The same as Eclipse: the default debug.keystore file in your Documents and Settings?
It creates two files:
-debug-unaligned.apk (signed, unaligned)
-debug.apk (signed, aligned)
release: 'help' says it doesn't sign it. It creates these files:
-unsigned.apk (unsigned, unaligned)
The next two are only if you have the values specified in build.properties:
-unaligned.apk (signed, unaligned)
-release.apk (signed, aligned)
Any helpful comments / verifications will be greatly appreciated.
Which kesystore file is it using? The same as Eclipse: the default debug.keystore file in your Documents and Settings?
Yes.
As far as the release target goes, you will get behaviour like this:
If you have lines like:
key.store=c:/users/me/my-release-key.keystore
key.alias=release_alias
key.store.password=myStorePassword
key.alias.password=myAliasPassword
in your build.properties, it will automatically build and sign your apk with no prompting for anything.
If you comment out the last two lines, then it will prompt you for the passwords, then complete a signed build if the passwords are OK.
If you don't have any of the above lines, then it will just build you an unsigned apk with no prompting for anything and end with:
-release-nosign:
[echo] No key.store and key.alias properties found in build.properties.
[echo] Please sign C:\dev\projects\AntBuilds\MyProject\bin\MyProject-unsigned.apk manually
[echo] and run zipalign from the Android SDK tools.
.
This answer works for me, I am using ant to auto-compile android app, it prompts and need password, I wrote one file named password, and using the command ---ant release < passwd,
However, it also prompts that I need input password.
Using the tips here
key.store=c:/users/me/my-release-key.keystore
key.alias=release_alias
key.store.password=myStorePassword
key.alias.password=myAliasPassword
I solved this problem.