Im trying to decompile and recompile an APK using apktool by executing it using exec() function in PHP. im able to decompile it using this code:
exec('cd apk && export PATH=$PATH:/opt/homebrew/bin && apktool d appname.apk', $output, $result_code);
I have to do some directory change and PATH changes in order to use the apktool but the decompilation went fine and i can see all the output files and folder.
When it comes to recompiling the apk, the apktool kinda stop halfway and no output files were produced. this is the code
exec('export PATH=$PATH:/opt/homebrew/bin && cd uploads && apktool b appname.apk', $output, $result_code);
echo "<pre>";
var_dump($output);
echo "</pre>";
this is the output of var_dump:
array(4) {
[0]=>
string(22) "I: Using Apktool 2.7.0"
[1]=>
string(42) "I: Checking whether sources has changed..."
[2]=>
string(44) "I: Checking whether resources has changed..."
[3]=>
string(24) "I: Building resources..."
}
From the var_dump output, i can see that the process didn’t finish and got terminated halfway. expected output is something like this:
I: Using Apktool 2.7.0
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
I: Building apk file...
I: Copying unknown files/dir...
I: Built apk into: appname/dist/appname.apk
Im using PHP 7.4.9 on macOS Monterey. I think it might not have anything to do with permission and owner since i could decompile and during the decompilation the apktool able to generate files and folders. but i could be wrong though. Please help