【发布时间】:2021-07-09 16:11:10
【问题描述】:
我有一个 react native 应用程序,它从数据库中获取书籍并显示它们。当 mongodb 后端运行时,它在 iOS 上运行良好,但在 android 上却不行。我只是收到如下所示的网络错误。
你们中有人知道如何解决吗? 这是我的 build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.3")
// 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("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
这是我的 AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<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" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />s
<uses-sdk android:targetSdkVersion="29" android:minSdkVersion="16" tools:overrideLibrary="com.facebook.react"/>
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
</manifest>
请告诉我如何解决此问题。 谢谢。
(如果您需要查看任何前端或后端文件,请在 cmets 中告诉我。)
【问题讨论】:
标签: android database mongodb react-native android-studio