1

I have the APK file for an application I want to install as a system application via SSH on rooted Android tablets. I'm able to install this application via ADB with a script but the installation fails when I do it through SSH. The SSH application installed is called QuickSSHd and I log in as root. With ADB I'm connected with the shell account that I raise as root with the su command.

Here is the installation script:

if [[ $EUID -ne 0 ]]; then
   echo ">> This script must be run as root."
   exit 1
fi

echo ">> Remounting /system in write mode..."
mount -o rw,remount /system

echo ">> Installing Manager..."
wget -P /system/app http://update.esmart.net/apk/Manager.apk
chmod 777 /system/app/Manager.apk
chown system:system /system/app/Manager.apk

echo ">> Removing smanager..."
rm /system/app/smanager*

echo ">> Remounting /system in read mode..."
mount -o ro,remount /system

echo ">> Starting Manager..."
sleep 2
am start -W -n ch.esmart.managerapp/.MainActivity

echo ">> Finished !"

The application icon is not displayed and am command does not work.

After checking in logcat:

$ logcat | grep Manager
W/zipro   ( 3308): Unable to open zip '/system/app/Manager.apk': Permission denied
D/asset   ( 3308): failed to open Zip archive '/system/app/Manager.apk'
W/PackageParser( 3308): Unable to read AndroidManifest.xml of /system/app/Manager.apk

I also tried the su command in SSH but it changes nothing.

The permissions look good:

$ stat /system/app/Manager.apk
  File: "/system/app/Manager.apk"
  Size: 370990      Blocks: 728        IO Block: 4096   regular file
Device: 13h/19d Inode: 1448        Links: 1    
Access: (0777/-rwxrwxrwx)  Uid: ( 1000/  system)   Gid: ( 1000/  system)
Access: 2014-10-24 12:10:05.000000000
Modify: 2014-10-24 12:10:05.000000000
Change: 2014-10-24 12:10:05.000000000

What does this error mean? Thanks a lot!

1 Answer 1

1

I found where the problem comes. When I want to change the rights on the file, the installation has already begun. I do not know exactly what happens during installation. So I downloaded the APK to the root file system, I change the permissions and copy the APK in /system/app with the -p argument to the cp command to keep the file permissions on the target.

if [[ $EUID -ne 0 ]]; then
   echo ">> This script must be run as root."
   exit 1
fi

echo ">> Remounting /system in write mode..."
mount -o rw,remount /system

echo ">> Installing Manager..."
wget -P / http://update.esmart.net/apk/Manager.apk
chmod 777 /Manager.apk
chown system:system /Manager.apk
cp -p -f /Manager.apk /system/app

echo ">> Removing smanager..."
rm /system/app/smanager*

echo ">> Remounting /system in read mode..."
mount -o ro,remount /system

echo ">> Starting Manager..."
sleep 2
am start -W -n ch.esmart.managerapp/.MainActivity

echo ">> Finished !"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .