Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native, Whats com.facebook.react.devsupport.DevSettingsActivity

There is 2 activities inside AndroidManifest.xml when you init new project by react-native, the first one is MainActivity and the second one is com.facebook.react.devsupport.DevSettingsActivity. What's the usage of the second one?

like image 278
Alireza Akbari Avatar asked Jul 31 '18 08:07

Alireza Akbari


2 Answers

Adding to the accepted answer, for those who are wondering how to add this activity to debug manifest, follow these steps

  1. Add a folder inside <project_root>/andorid/app/src and name it debug
  2. Add a file inside and name it AndroidManifest.xml
  3. Paste the following code in that file and save.
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" >
        <!-- This activity will be removed for release builds -->
        <activity android:name="com.facebook.react.devsupport.DevSettingsActivity"
              android:exported="false"/>
    </application>
</manifest>

This should be done if you plan on debugging your app over the local network using wireless debugging on Android. Hope someone finds this helpful.

like image 154
Justin Avatar answered Nov 08 '22 08:11

Justin


You can find explanation of this activity at the header of the file

DevSettingsActivity.java under $ProjectRoot\node_modules\react-native\ReactAndroid\src\main\java\com\facebook\react\devsupport\DevSettingsActivity.java:

  • Activity that display developers settings. Should be added to the debug manifest of the app.
  • Can be triggered through the developers option menu displayed by {@link DevSupportManager}.
like image 27
Qin Chao Avatar answered Nov 08 '22 09:11

Qin Chao