Search code examples
androidbashadbecho

How to solve does not existte object error in bash


Using a bash script to automatically pull and install an android app via ADB. However, I get an error ' does not existte object [apk path]`. Here is the script:

#! /bin/bash

APK_PATH="$(adb shell pm path $1)"
echo "${APK_PATH#*:}"
APK_PATH=${APK_PATH#*:}
adb pull $APK_PATH
mv base.apk $1.apk


if [ "$2" == "--jadx" ] || [ "$2" == "-j" ]
    then jadx $1
fi

How do I solve this.

NOTE: I used an alias to the script location so I just need to run autoapk.

For the specific error, I ran autoapk b3nac.injuredandroid and got the error message

/data/app/b3nac.injuredandroid-1/base.apk
' does not existte object '/data/app/b3nac.injuredandroid-1/base.apk
mv: cannot stat 'base.apk': No such file or directory

Solution

  • Start by checking the file is where it is expected as

    ...
    adb pull $(tr -d '\r' <<< "$APK_PATH") "$1.apk"
    if [[ -r  "$1.apk" ]]
    then
        printf 'OK\n'
    else
        printf 'ERROR: %s not found\n' "$base"
        exit 1
    fi
    ...
    

    Do the same for all of your other expectations.

    edit

    I guess this is what you are expecting, to rename the apk.

    edit 2

    It seems you have a '\r`