Search code examples
androidreact-nativegoogle-play-console

Problem uploading apk to google play console (android:exported)


I recently updated the targetSDK to version 31, after that, I started receiving the following error when uploading the apk to the google play console.

I have already made the necessary corrections reported at: developer.android.com/about/versions/12/behavior-changes-12#exported, however, I continue to receive the error.

In the file below I have set android:exported="true" at all times. However, I previously followed the recommendation:

If the app component includes the LAUNCHER category, set android:exported to true. In most other cases, set android:exported to false.

It still didn't work.

BuildScript:

ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
        googlePlayServicesAuthVersion = "16.0.1"
        ndkVersion = "21.4.7075529"
    }

See my AndroidManifest.xml file

<manifest
  xmlns:android="http://schemas.android.com/apk/res/android"
  package="farmacia.digital.com"
>
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
  <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  <uses-permission android:name="android.permission.USE_FINGERPRINT" />
  <uses-permission android:name="android.permission.USE_BIOMETRIC" />
  <uses-permission android:name="android.permission.VIBRATE" />
  <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.WAKE_LOCK" />
  <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
  <application
    android:requestLegacyExternalStorage="true"
    android:name=".MainApplication"
    android:label="@string/app_name"
    android:icon="@drawable/icon"
    android:roundIcon="@drawable/icon"
    android:allowBackup="false"
    android:theme="@style/AppTheme"
  >
    <meta-data
      android:name="com.facebook.sdk.ApplicationId"
      android:value="@string/facebook_app_id"
    />
    <meta-data
      android:name="expo.modules.updates.EXPO_UPDATE_URL"
      android:value="https://exp.host/@datalytics/farmacia-digital"
    />
    <meta-data
      android:name="expo.modules.updates.EXPO_SDK_VERSION"
      android:value="40.0.0"
    />
    <meta-data
      android:name="expo.modules.updates.EXPO_RELEASE_CHANNEL"
      android:value="default"
    />

    <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: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="farmaciadigital" />
      </intent-filter>
    </activity>

    <activity
      android:name="com.facebook.react.devsupport.DevSettingsActivity"
      android:exported="false"
    />

    <meta-data
      android:name="com.dieam.reactnativepushnotification.notification_foreground"
      android:value="true"
    />
    <!-- Change the resource name to your App's accent color - or any other color you want -->
    <meta-data
      android:name="com.dieam.reactnativepushnotification.notification_color"
      android:resource="@color/blue"
    />

    <receiver
      android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions"
    />
    <receiver
      android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher"
    />
    <receiver
      android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver"
      android:exported="false"
    >
        <intent-filter>
          <action android:name="android.intent.action.BOOT_COMPLETED" />
          <action android:name="android.intent.action.QUICKBOOT_POWERON" />
          <action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
        </intent-filter>
    </receiver>

    <service
      android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
      android:exported="false"
    >
      <intent-filter>
          <action android:name="com.google.firebase.MESSAGING_EVENT" />
      </intent-filter>
    </service>
  </application>
</manifest>

Solution

  • All Activities, services and applications inside of Android Manifest should have the exported tag.

    I can see that you have missed that inside of the Application tag.

    Also I advise you to use an emulator or device which has an API level above 31 (android 12 and above) to run the application in debug mode instead of creating a release build and uploading to the PlayStore every time.

    After doing that, if you realize that all tags have the exported tag set, this means that you might have some libraries that may not have this set.

    So as a solution you'd need to manually resolve this inside of node_modules or, the more reasonable and logical approach, which is upgrading the dependencies.

    If the library is no longer maintained, you'd have to go with the 1st approach, or find a replacement.

    For Finding the libraries:

    enter image description here

    Open Android Studio, and open Android Manifest and press on Merged Manifest at the bottom, this will show you the list of manifests inside of the 3rd party packages that are added to your project as shown in the image above.

    The ones that do not have exported set will show in red at the right hand side of the screen.

    Just go over them one by one and try to upgrade them and that should fix your issue. If not, add the exported tag manually to the problematic libraries.