0

I'm trying to launch an update for my app using intent and file provider

this is my code

File path = new File(context.getFilesDir(), "apk");
File file = new File(path, fileName);

Uri uri = FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", file);
context.grantUriPermission(fileName, uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(uri);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intent.addFlags(
                Intent.FLAG_GRANT_WRITE_URI_PERMISSION |
                Intent.FLAG_GRANT_READ_URI_PERMISSION
            );
context.startActivity(intent);

this is the file_path.xml

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
  <files-path name="files" path="/" />
</paths>

I keep getting the "Parse Error: there is a problem parsing the package" message. But if I open the apk manually the installation works fine.

any help? Thanks

Sneakol90
  • 39
  • 5
  • Must be sure that you have added file provider code in manifest file and your package name should be correct. – Piyush Apr 15 '19 at 08:05
  • this is what I have in the manifest – Sneakol90 Apr 15 '19 at 08:10
  • Look at this : https://stackoverflow.com/questions/1492401/parse-error-there-is-a-problem-parsing-the-package-while-installing-android#answer-6329829 – Kévin Giacomino Apr 15 '19 at 08:13
  • I've tried to install through adb and I'm getting this error Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install com.macs.mobile.App without first uninstalling.] – Sneakol90 Apr 15 '19 at 08:53

0 Answers0