1

I am setting up my environment to start developing react native apps. I keep getting the following error:

PS C:\map\development\learnreact\react-native\helloworld> react-native run-android Starting JS server... Building and installing the app on the device (cd android && gradlew.bat installDebug)...

Configure project :app Observed package id 'platform-tools' in inconsistent location 'C:\Users\bheka\AppData\Local\Android\Sdk\platform-tools' (Expected 'C:\Users\bheka\AppData\Local\Android\Sdk\platform-tools\platform-tools') Checking the license for package Android SDK Build-Tools 27.0.3 in C:\Users\bheka\AppData\Local\Android\Sdk\platform-tools\licenses Warning: License for package Android SDK Build-Tools 27.0.3 not accepted. Checking the license for package Android SDK Platform 26 in C:\Users\bheka\AppData\Local\Android\Sdk\platform-tools\licenses Warning: License for package Android SDK Platform 26 not accepted.

FAILURE: Build failed with an exception.

  • What went wrong: A problem occurred configuring project ':app'.

    Failed to install the following Android SDK packages as some licences have not been accepted. platforms;android-26 Android SDK Platform 26 build-tools;27.0.3 Android SDK Build-Tools 27.0.3 To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager. Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html Using Android SDK: C:\Users\bheka\AppData\Local\Android\Sdk\platform-tools

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 2s Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/getting-started.html

I have accepted licenses using .\sdkmanager --licenses but no luck. I have reinstalled the sdk using the sdk manager in android studio with no luck. Anyone know what I should do?

Bhekani Khumalo
  • 143
  • 2
  • 9

2 Answers2

2

Make sure the sdkbuildtools used by Android Studio and your emulator are the same as the ones in your build.gradle file in your project folder. If they do not match then either change the build.gradle file to use the installed sdk version. What probably happened is you have sdk 27 used by your android studio and your rn project tried to build it using sdk 26. Accepting the license will not change anything because while it's accepted it is still not used by your emulator and you Android Studio. Hope that helps!

Annie Hill
  • 379
  • 3
  • 16
  • Please upvote my answer if you found it useful :) Thanks! – Annie Hill Oct 17 '18 at 12:40
  • I am now getting this error: `Could not run adb reverse: spawnSync C:\Users\bheka\AppData\Local\Android\Sdk\platform-tools/platform-tools/adb ENOENT` Any idea what I can do? – Bhekani Khumalo Oct 17 '18 at 16:09
  • https://stackoverflow.com/questions/45229579/could-not-run-adb-reverse-react-native – Annie Hill Oct 18 '18 at 11:02
  • Please start another issue, since my answer resolved the problem you asked for please accept it as an answer. As for the new issue you're having make sure the port is free (can be blocked by apache, skype etc) or try running on another port. – Annie Hill Oct 18 '18 at 13:34
  • Thank you, I figured out a fix, I had to add a folder and name it "platform-tools" and adb.exe in it inside the `C:\Users\bheka\AppData\Local\Android\Sdk\platform-tools` and it worked. – Bhekani Khumalo Oct 18 '18 at 20:15
0

I had similar issue and was resolved by fixing environment variable, ANDROID_SDK_ROOT. It was previously pointing to .../sdk/platform-tools/ and later worked by changing it to .../sdk

Dharman
  • 30,962
  • 25
  • 85
  • 135
Azghanvi
  • 934
  • 10
  • 22