2

I have the following problem:

As described at Android: install .apk programmatically, I install an APK file successfully on an Android device. Unfortunately I have the problem that when I try to install a second APK file, get the message: Package not installed.

In the debugger I see:

Asset path / sdcard / myAPK.apk

neither directory nor file

Community
  • 1
  • 1

2 Answers2

2

This may help you:

protected void installApkfile(String apkFileName) {
    // TODO Auto-generated method stub
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(
               new File(Environment.getExternalStorageDirectory() + "/download/"
               + apkFileName)), "application/vnd.android.package-archive");
    startActivityForResult(intent,0);
}

Here my .apk file is in sd card download folder.

rekire
  • 47,260
  • 30
  • 167
  • 264
Rajendra
  • 1,700
  • 14
  • 17
  • Thank you for your reply. However, I am already using this code and it works so well with a single APK file. Only when you install the second apk file I get the above error message. – user1694444 Sep 24 '12 at 13:02
  • are you installing more than 1 apk file at a time ?? – Rajendra Sep 24 '12 at 13:07
  • No, i'm waiting for the result that the first apk is successfully installed. After this i want to install the second apk. – user1694444 Sep 24 '12 at 13:14
1

If by "asset path" you really mean that the APK is packaged as an asset, that will not work. The APK must be an actual file on the filesystem, and an asset remains packaged inside of its hosting APK. See: Can We Install an APK From a ContentProvider?

Community
  • 1
  • 1
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • The file exists on the device. I can install a previous APK file successfully, but at the second APK file I get this error message. – user1694444 Sep 24 '12 at 12:56
  • @user1694444: Then presumably you are constructing the path wrong, such that the path you are trying to use does not exist. – CommonsWare Sep 24 '12 at 13:00
  • However, the path must exist because the Test1.APK can be successfully installed, but not the Test2.APK. This is in the same directory – user1694444 Sep 24 '12 at 13:13