Facing issue “ Failed to install the app. Make sure you have the Android development environment ” in react native

时光怂恿深爱的人放手 提交于 2019-12-19 06:56:11

问题


Would you please help me, I am stuck to create a new project in react-native Like below screenshot. I have able to run old projects. but I am not able to run a new project

I have followed these steps:

  1. react-native init projectName
  2. cd projectName
  3. react-native run-projectName

But I get the error below:

error Failed to install the app. Make sure you have the Android development environment set up:


回答1:


To make sure your environment is setup properly for android, go to the root of your react-native project. Open the android project(folder) in the Android Studio IDE.

All errors with your environment will show up, and that will automatically start the Gradle Daemon to sync and configure the build for you. Once it finished, close the Android Studio and come back to command-line and run: react-native run-android

This works fine.




回答2:


Edit:

According to the updated questions, with screenshots comment below, seems like your problem is related to this other post from years ago.

The solution I could provide for you is to find your gradle*.zip file, delete it, and re-run the command. That way, the command would try downloading the gradle again. And this time, please make sure your connection is stable during the command run process, as the command will re-download the gradle zip again.

For reasons of the solution I provided, according to the link, it is caused by your connection is unstable and the gradle zip downloaded during the process is corrupted.

Previous Answer:

Do you have Android Studio installed on your computer?

Have you tried running the command again after you started an Android emulator device from Android Studio?

The command you mentioned AFAIK, does not try to run any emulator for you, and you need to run an emulator yourself to test your app.

Also you need to have Android SDK installed to run a react-native android-app. It does not comes with react-native, but it does comes with Android Studio.

So, maybe you should start there!




回答3:


I too stumbled into this problem today. It happens when you take project form other users. Hence the ndk and sdk path are of the other user. So make sure the ndk and sdk path are correctly mentioned inside your local.properties file.




回答4:


Just do $:cd android and then $: gradlew clean worked for me on Windows



来源:https://stackoverflow.com/questions/56891033/facing-issue-failed-to-install-the-app-make-sure-you-have-the-android-develop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!