"Parse Error: There Is a Problem Parsing the Package" While Installing Android Application

Parse Error : There is a problem parsing the package while installing Android application

You said that the first time you installed the application it worked fine.

The only difference in the steps you outlined between the two versions are:

  1. The version number (I'm assume
    that this did not participate in
    breaking anything)
  2. The code
  3. The name of the .apk file

Try renaming the ARDemo1.apk file back to ARDemo.apk (make sure to back up the older version) and see if that helps. My guess is that it has something to do with the name of the apk.

If it still does not work, then you can eliminate the name of the apk file as the source of the problem and start investigating 2) by rebuilding your old version and see if you have same problem again. If the problem does not exists with the rebuilt version of your old code then you know it must be something to do with your code.

I hope that gets you somewhere.

Cheers,
Joseph

Error while installing release version of Flutter app on Android 12 : Parse Error : There was a problem parsing the package

In Android 12 and later any launchable activity should contain this flag in manifest :

exported="true"

apk generated showing There was a problem while parsing the package on certain device

The Reason of: Problem parsing package error

  1. You might have turned off “Allow installation from unknown resources”
  2. The downloaded .apk is not fully downloaded or corrupted
  3. The app is not compatible with the Hardware or version of the OS you are using

reference: https://medium.com/@GuruTechnolabs/how-to-fix-problem-parsing-the-package-error-in-android-c2fca91673cb

Parsing error while updating app programmatically

I had same problem. There is an option to check canRequestPackageInstalls () in Android 8.0.0 (API 26).

This might be the solution of your problem. Find more here

FileProvider: Installing APK. There was an error parsing the package.

For anyone who has the same problem.
I had to specify the exactly folder with getExternalFilesDir();

MainActivity

public class MainActivity extends AppCompatActivity {

Button btnStartIntentFileProvider;
String strRootPathInternalStorage = Environment.getExternalStorageDirectory().toString();
String strApkToInstall = "app-debug.apk";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

btnStartIntentFileProvider = (Button)findViewById(R.id.btnFileProvider);
btnStartIntentFileProvider.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {

File fileApkToInstall = new File(getExternalFilesDir("Download"), strApkToInstall);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Uri apkUri = FileProvider.getUriForFile(MainActivity.this, BuildConfig.APPLICATION_ID + ".provider", fileApkToInstall);
Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
intent.setData(apkUri);
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
MainActivity.this.startActivity(intent);
} else {
Uri apkUri = Uri.fromFile(fileApkToInstall);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MainActivity.this.startActivity(intent);
}
}
});
}
}

Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.spicysoftware.test">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.spicysoftware.test.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>

<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

provider_paths (in XML Folder)

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


Related Topics



Leave a reply



Submit