简体   繁体   English

React Native 无法识别 Android SDK

[英]React Native won't recognize the Android SDK

I have a React Native application, that runs fine on iOS, I tried to run it on Android too, but I always get the error:我有一个 React Native 应用程序,它在 iOS 上运行良好,我也尝试在 Android 上运行它,但我总是收到错误消息:

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
D8: Cannot fit requested classes in a single dex file (# methods: 116691 > 65536 ; # fields: 80012 > 65536)

I tried every solution I saw, nothing worked.我尝试了我看到的所有解决方案,但没有任何效果。

I ran the react-native-community cli doctor and it seems like React Native won't recognize the Android SDK.我运行了react-native-community cli doctor ,似乎 React Native 无法识别 Android SDK。 I checked, and the emulator sdk and the gradle sdk versions are the same.我查了下, emulator sdkgradle sdk版本是一样的。 echoing ANDROID_HOME on the terminal properly gives me the sdk path, I followed the React Native getting started again to see if I missed something, but it seems like everything is install correctly.在终端上正确回显ANDROID_HOME为我提供了 sdk 路径,我再次遵循 React Native 入门以查看是否遗漏了什么,但似乎一切都已正确安装。

I can't figure out why this won't run.我不明白为什么这不会运行。

In your android\\app\\build.gradle try adding在您的android\\app\\build.gradle尝试添加

android {
    ...
    defaultConfig {
        ...
        multiDexEnabled true
   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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