There was a problem parsing the package Android 12 - S10e

Hi everyone :).

First of all, thank you so much for all the great help and Expo experience! It’s been awesome so far!

I’ve been diving around StackOverflow, Medium, (Heck, even the Expo Forums) and some Google, but haven’t found the solution yet.

I’m currently using an ejected Expo App. I need to upgrade the compileSdkVersion and targetSdkVersion to 31 as Intercom currently needs it.

While everything else remains the same, once I change the compileSdkVersion and targetSdkVersion to the aforementioned values and download the compiled .apk eas build --profile development --platform android I get hit in my S10e (Android 12) with There was a problem parsing the package.

I’ve tried running it on an Android 9 emulator and it fails as well. Nonetheless, a Samsung Galaxy S10 with Android 11 runs it well.

If I downgrade the version to 30, the project resumes and it runs well again.

I’ve researched all these links (and more - Currently limited to only 2 links)

From what I’ve gathered, I need to update the <application> and <service>s tags with android:exported="true" accordingly.

I did that, but the .apk is still uninstallable on my device.

Here’s the AndroidManifest.xml from src/main

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="app.omitted">
  <uses-permission android:name="android.permission.CAMERA"/>
  <uses-permission android:name="android.permission.INTERNET"/>
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
  <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
  <uses-permission android:name="android.permission.RECORD_AUDIO"/>
  <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
  <uses-permission android:name="android.permission.USE_BIOMETRIC"/>
  <uses-permission android:name="android.permission.USE_FINGERPRINT"/>
  <uses-permission android:name="android.permission.VIBRATE"/>
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  <queries>
    <intent>
      <action android:name="android.intent.action.VIEW"/>
      <category android:name="android.intent.category.BROWSABLE"/>
      <data android:scheme="https"/>
    </intent>
  </queries>
  <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
    <meta-data android:name="expo.modules.updates.ENABLED" android:value="true"/>
    <meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="44.0.0"/>
    <meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
    <meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
    <meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://exp.host/omitted"/>
    <activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:screenOrientation="portrait" android:exported="true">
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
      <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:scheme="app.pana"/>
        <data android:scheme="exp+pana"/>
      </intent-filter>
    </activity>
    <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="true"/>
    <activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity" android:theme="@style/Base.Theme.AppCompat" android:exported="true"/>
  </application>
</manifest>

eas.json

{
    "cli": {
        "version": ">= 0.47.0"
    },
    "build": {
        "development": {
            "developmentClient": true,
            "distribution": "internal",
            "android": {
                "image": "ubuntu-18.04-jdk-11-ndk-r19c"
            }
        },
        "preview": {
            "distribution": "internal"
        },
        "production": {}
    },
    "submit": {
        "production": {}
    }
}

Here’s part of the build.gradle:


buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
    }
    repositories {
        google()
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.1.0")

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url(new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../android"))
        }
        maven {
            // Android JSC is installed from npm
            url(new File(["node", "--print", "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), "../dist"))
        }

        google()
        mavenCentral()
        jcenter()
        maven { url 'https://www.jitpack.io' }
    }
}

I don’t know what else to do. Any ideas?

Ok. After seeing the output from the debugger I’ve been able to see the following:

Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl1122952726.tmp/base.apk (at Binary XML file line #147): expo.modules.devlauncher.launcher.DevLauncherActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]

But what I don’t get is why it isn’t working.

Found the solution. Cross posting from StackOverflow:

The problem was in the merged AndroidManifest.xml that resided in the generated .apk had several <activity> tags that did not included the android:exported="true|false" values. These tags were not shown in expo’s AndroidManifest.xml, and had to be overriden.

One of the main culprits was the Expo dev server.

You need to include an override in the android/app/src/main/AndroidManifest.xml (To be honest I didn’t know how to include it in the /android/app/src/debug folder):

Here’s an example on how you do that

  <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
    <meta-data android:name="expo.modules.updates.ENABLED" android:value="true"/>
    <meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="44.0.0"/>
    <meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
    <meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
    <meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="/>
    <activity android:name=".MainActivity" android:exported="true" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:screenOrientation="portrait">
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
      <intent-filter>
        <! -- omitted just for reference -->
      </intent-filter>
    </activity>

<!-- These are the culprits -->
<!-- Include these -->
    <activity android:name="expo.modules.devlauncher.launcher.DevLauncherActivity" android:exported="true"/>
    <activity android:name="expo.modules.devlauncher.launcher.errors.DevLauncherErrorActivity" android:exported="true"/>
    <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false"/>
    <activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity" android:exported="false"/>
<!-- Intercom is a specific package that I'm using -->
    <activity android:name="io.intercom.android.sdk.helpcenter.collections.IntercomHelpCenterActivity" android:exported="false"/>
    <activity android:name="com.intercom.input.gallery.GalleryInputFullScreenActivity" android:exported="false"/>
    <activity android:name="com.intercom.input.gallery.GalleryLightBoxActivity" android:exported="false"/>
  </application>

In addition, if your application won’t install, is because there may be other tags that need further updates. To check, do the following:

  1. Download Android Studio
  2. Create an empty project or open an existing one
  3. Go to the Build Tab → Analyze APK → Select your expo .apk
  4. Open AndroidManifest.xml and analyze wether all the <activity> <service> <provider> tags have the android:exported="true" included.

If you’ve seen any of them that have not been included, you will need to override them in the AndroidManifest.xml within the src/main (in case you want to apply it for all the builds - e.g dev, staging, production).

  1. You override them by including them INSIDE the <application> tag, specify the name attribute, and include android:exported="true" (or false).

Ex:

 <activity android:name="expo.modules.devlauncher.launcher.DevLauncherActivity" android:exported="true"/>

Omit all the other attributes and/or children, they will not be removed.