Home > OS >  React native problem with android:exported="true" in other library
React native problem with android:exported="true" in other library

Time:10-01

React native application. Despite having entered in the manifest android:exported="true" i still have this problem in the build phase. It almost seems that some installed plugins did not insert it.

I read in some posts that proposed as a temporary solution to downgrade to version 30 of the android SDK, but i cannot because with that version it does not allow me to compile.

  • React Native 0.68
  • Android SDK version 33
  • Android Gradle Plugin version 7.3.0

From Merged Manifest

Error: android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. mobile_app.app debug manifest, line 26 Error: android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. mobile_app.app debug manifest, line 33

CodePudding user response:

solution:

  • In Git-bash run: * ./gradlew assembleDebug --stacktrace --info | tee my-logs.txt
  • Search "InstrumentationActivityInvoker"
  • Open file and add android:exported="true" on activity

Same issue, But I can't know the reason for it. It happens when I have updated macos, Do you have any information?

CodePudding user response:

Based on the response from Aleja Duque-Torres, here's a temporary solution by adding the following code segment to your AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="...your package name"
    xmlns:tools="http://schemas.android.com/tools">       <!-- ADD THIS LINE -->

        <!-- Other Content -->
        
        <application
        .../>

        <!-- ADD STARTS HERE -->

        <activity
            android:name="androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity"
            android:exported="false"
            tools:replace="android:exported"/>
        <activity
            android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity"
            android:exported="false"
            tools:replace="android:exported"/>
        <activity
            android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity"
            android:exported="false"
            tools:replace="android:exported"/>
            
        <!-- ADD ENDS HERE -->

        </application>
</manifest>

Then do a build folder clean and run the project again. Hope this helps!

P.s. my guess is that this problem is due to some dependency package getting messed up. If someone else has any insight please feel free to shed some light on it!

  • Related