Convert APK to manifest in a loop - android

I have many APK (Android package) files in a folder and I want to extract the manifest files from each of them. I am using Android apktool to convert them and since there are many APK files I want to convert them in a loop, not one by one.
apktool d hello.apk ./hello is the command for extracting manifest files from hello.apk and produces the output folder named hello.
I tried the command in the command prompt using for loop in the current directory in which all APK files are stored:
for \r %v in (*.apk) do apktool d "%v" "./%v".
I want the output folder of same name for each APK file, i.e. if APK is hello.apk the output folder should be hello. The above command is producing an error: cannot generate the output folder. How can I extract manifest files from all such APK files at once from a loop?

Maybe you forgot -o parameter?
That command works fine for me:
for /r %v in (*.apk) do apktool.jar d "%v" -o "./%~Nv"

Related

Removing some files (.apk files) after installation but before packaging system folder to system.img

As the title suggests I want a list of .apk files to be removed from system.img before packaging so that those does not consume file system space on "/" (/system partition).
Basically I want it to be scalable solution so written a shell script to remove those .apks as below:
apk_removal.sh
*#!/bin/bash
REMOVAL_DIR=$1
rm ${REMOVAL_DIR}/system/system_ext/priv-app/xyz1.apk
rm ${REMOVAL_DIR}/system/priv-app/xyz2.apk
...*
How can I use this script to remove the .apk files from system.img just before packaging.

Running apktool in a bash script

I am trying to write a bash script that decompiles several .apk files using apktool. Each apk file is located in a subdirectory of the sample folder.
#!bin/bash
for item in $(ls samples);
do
for apk in $(ls "samples/$item");
do
echo ./apktool/apktool d "./samples/$item$apk"
$(./apktool/apktool d "./samples/$item$apk")
done
done
When I run the script I get the following output:
./apktool/apktool d ./samples/ADRD/53dc.apk*
Input file (./samples/ADRD/53dc.apk*) was not found or was not readable.
The input file error message is the standard for when apktool cannot find a file. However, if I run the following command in the terminal the apktool will work correctly.
./apktool/apktool d ./samples/ADRD/53dc.apk*
I have changed the permissions of all the files located in the samples folder to rw for all users. I also have tried using sudo with the shell script, but this causes the script to hang. However, when I use sudo with the apktool in the command line it also hangs. Therefore, I am not sure if using sudo with apktool is doable.
Any help is appreciated, thanks.
So it looks like this ls gives you an output with an asterisk * appended at the end of the apk filename, because the file is executable.
for apk in $(ls "samples/$item");
This is not the default behaviour of ls, you are getting this probably because you have aliased ls to ls -F or similar. To bypass the alias, rewrite the line this way:
for apk in $(\ls "samples/$item");
Notice the \ I added there.
BTW, is it normal that an apk file is executable? Perhaps you can remove the executable bit:
find samples -name '*.apk' -exec chmod -x {} \;
Also, possibly your script can be replaced with this one liner:
find samples -name '*.apk' -exec ./apktool/apktool d {} \;
Mind you, this is not exactly the same thing, because it may go deeper than two directories. If you need to limit the depth, that's possible too, see man find

Android apk decompilation from bat won't start

I'm trying apk tool, following the instruction I have create a folder with
Where
-myapp.apk is a sample app that I want to decompile
My bat Decompile.bat is
#echo off
pushd "%~dp0"
apktool if myapp.apk
apktool if framework-res.apk
apktool d myapp.apk
pause
When I start the bat the prompt autoclose after the first lines execution
#echo off
apktool if myapp.apk
apktool if framework-res.apk
the execution of these line is correctly but jump the latet line for some reason
If I try to use apktool from prompt works, so the problem is my bat file but I don't know how to fix it
You need to see how apktool.bat is referencing java. I downloaded the source from github and this is what's listed:
#echo off
set PATH=%CD%;%PATH%;
java -jar "%~dp0\apktool.jar" %1 %2 %3 %4 %5 %6 %7 %8 %9
If that's the case then it's assuming that java is in the PATH variable or in the current directory. Maybe add an echo for the path and see why it cannot find it. Alternatively, set the JAVA_HOME environment variable and put the full path to java inside of apktool.bat.

Unable to access jarfile SignApk

I'm trying to sign an APK with SignApk, but I keep getting this error:
Error: Unable to access jarfile signapk.jar
I have appended my JDK directory as well as my SignAPK directory to my system path variable. The java command works fine through the command-line, but I can't seem to get the -jar option to work correctly for signing APKs.
My SignApk folder is located on my C:\ drive, so it looks like this:
Here is what I am trying to do through the command-line:
Please ignore the blank space in between the variables as I was trying to cover up my details. The syntax that I am using is:
java -jar signapk.jar certificate.pem key.pk8 myapk.apk myapk-signed.apk
I have tried the commands from the SignApk directory as well as the bin directory inside of that directory. Can anyone help me troubleshoot how to resolve this issue? Thanks
As you might notice, there is no signapk.jar file there, there is only signapk without extension.
Download different SignApk from here:
http://www.mediafire.com/download/h5fob1afzt1p4ss/SignApk.rar
Password: SanketN8
just download Signapk.zip and unzip wherever you wish, paste your apk inside the signapk folder.
open cmd / terminal , change directory to signapk
java -jar signapk.jar testkey.x509.pem testkey.pk8 test.apk test-signed.apk
copy and replace with you existing file name (test.apk) and output file (test-signed.apk )
signapk.zip - https://drive.google.com/open?id=0ByAytNiwJoUaQ3NvVzlPX0xGUFU
image
In case one encounters this message when signing a LineageOS build:
Get rid of ./build/tools/releasetools/ prepended to (old) commands used for signing.
See https://wiki.lineageos.org/signing_builds#:~:text=For%20LineageOS%20versions-,older%20than,-18.1%20you%20will

XAPK File Validation Failed - APK Expansion Files

I am using the expansion files demo given in the sdks and am placing the obb file on the SD Card at the following location:
/Android/obb/package-name/package-name/main.versioncode.package-name.obb
But i get the following error:
XAPK File Validation Failed
For generating the .obb files this is the procedure i have followed :
1) copy all the images to a folder named main.versioncode.package-name.obb and then zip that file.
2) remove .zip file extension and place it in this /Android/obb/package-name/myobbfile.obb
Is this the correct way of doing it?
An OBB file is an uncompressed ZIP file, so make sure that you zip it without compression.
Every ZIP utility should have some sort of compression level option.
The following screenshot is the open source 7-ZIP gui for Add to Archive with a highlight i added to show where the Compression Level is set to Store.
Another way of doing it would be using jobb
Usage
The syntax for running jobb is as follows:
jobb [-d <directory>][-o <filename>][-pn <package>][-pv <version>] \
[-k <key>][-ov][-dump <filename>][-v][-about]
You can use the jobb tool to create an OBB file or extract the contents of an existing OBB. The following example command creates an OBB file from source files.
$ jobb -d /temp/assets/ -o my-app-assets.obb -k secret-key -pn com.my.app.package -pv 11
This example shows how to dump (extract) the contents of an existing OBB file:
$ jobb -d /temp/obb-output/ -o my-app-assets.obb -k secret-key
Here is how you need to get it done
1) You can put your images in any custom named folder you want. e.g myimages.
2) put all those images in a zip archive, once done adding rename that archive to main.versioncode.package-name.obb
3) Place that .obb file in directory sdcar/Android/obb/package-name/main.versioncode.package-name.obb
Hope it helps

Categories

Resources