linuxshellapktoolkali-linux

How to modify the apktool path


4.1 dirthy, but this version was not official of apktool, and I was having some problems, so I upgraded to version 2.5.0 and official, however I want my apktool folder to be in /usr/share but if I move my apktool folder to /usr/share when I run apktool the result is this:

apktool: can't find /usr/share/apktool.jar

In my apktool file I have this:

#!/bin/bash
prog="$0"                     
while [ -h "${prog}" ]; do        
 newProg=`/bin/ls -ld "${prog}"`                                                                           
 newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
 if expr "x${newProg}" : 'x/' >/dev/null; then
  prog="${newProg}"
 else                                                     
  progdir=`dirname "${prog}"`                          
  prog="${progdir}/${newProg}"                     
 fi
done
oldwd=`pwd`
progdir=`dirname "${prog}"`                          
cd "${progdir}"                                      
progdir=`pwd`                                        
prog="${progdir}"/`basename "${prog}"`               
cd "${oldwd}"
jarfile="/usr/share/apktool.jar"
libdir="$progdir"
if [ ! -r "$libdir/$jarfile" ] then
 echo `basename "$prog"`": can't find $jarfile"
 exit 1
fi                                                   
javaOpts=""
javaOpts="-Xmx512M -Dfile.encoding=utf-8"
while expr "x$1" : 'x-J' >/dev/null; do                  
 opt=`expr "$1" : '-J\(.*\)'`
 javaOpts="${javaOpts} -${opt}"                       
 shift
done

if [ "$OSTYPE" = "cygwin" ] ; then                           
 jarpathh=`cygpath -w  "$libdir/$jarfile"`     
else     
 jarpath="$libdir/$jarfile"
fi                                                   
# add current location to path for aapt             
PATH=$PATH:`pwd`;
export PATH;                                         
#exec java $javaOpts -jar "$jarpath" "$@"

Does anyone know how I can leave the apktool folder in usr/share/ and leave the script working? What should i change?


Solution

  • If you follow the steps to install apktool: https://ibotpeaches.github.io/Apktool/install/

    You will notice there are 2 files you need:

    1. a script (the one you posted), which you should name apktool and set to executable on linux chmod +x apktool
    2. a jar file: apktool.jar

    You need to have both files in the same directory for the script to work, so if you've moved the apktool file to /usr/share/apktool, you need to also move apktool.jar to /usr/share/apktool.jar