简体   繁体   中英

React Native package server not connected to Android simulator

I'm running my react native app on an android simulator. My app works fine and is connected with my react-native package server (npm start command I used to start my server) with the android simulator Galaxy J3 series and Galaxy pixel C series. But the same app won't work (packages not loading through server) with the latest Android simulator Samsung Galaxy S21 Ultra API 28. It throws an error, Could not connect to the development server Note: I set the dev setting the same to all simulators is same. Android studio version: 3.6.1 在此处输入图像描述

Build.grdle

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 21
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.2'

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

After searching and a lot of trials I end up with the solution. I added android:usesCleartextTraffic="true" line in <application tag in androidmanifest.xml file. Then I rerun the app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM