8

Just recently ejected expo and I'm trying to run my app on an android device. I followed the instructions (hopefuly right) but I keep getting this error when I try to run my app:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> java.io.IOException: The filename, directory name, or volume label syntax is incorrect

* 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 3s

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.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> java.io.IOException: The filename, directory name, or volume label syntax is incorrect

* 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 3s

    at makeError (C:\Users\User\Documents\jad for eject\jad\jad\node_modules\execa\index.js:174:9)
    at C:\Users\User\Documents\jad for eject\jad\jad\node_modules\execa\index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async runOnAllDevices (C:\Users\User\Documents\jad for eject\jad\jad\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
    at async Command.handleAction (C:\Users\User\Documents\jad for eject\jad\jad\node_modules\@react-native-community\cli\build\index.js:186:9)

Thanks for the help!

YosefBro
  • 596
  • 1
  • 7
  • 17

7 Answers7

17

I had the same issue on Windows, and my problem was with the Gradle local.properties file. It contained the following:

org.gradle.java.home=C:\Program Files\Java\jdk-15.0.1
sdk.dir=C:\Users\user\AppData\Local\Android\Sdk

The problem was probably the windows backslash (\). What worked is escaping it:

org.gradle.java.home="C:\\Program Files\\Java\\jdk-15.0.1"
sdk.dir=C:\\Users\\user\\AppData\\Local\\Android\\Sdk
Gabi Lee
  • 1,193
  • 8
  • 13
6

I struggled with this issue for 3 hours but nothing worked.

I managed to solve my issue by removing the quote in the local.properties file :

sdk.dir = "C:\\Users\\<USER>\\AppData\\Local\\Android\\Sdk"

To

sdk.dir = C:\\Users\\<USER>\\AppData\\Local\\Android\\Sdk
Alias
  • 61
  • 1
  • 2
4

I was able to solve the issue by changing

sdk.dir =   C:\Users\mob\AppData\Local\Android\Sdk

to

sdk.dir =   C:\\Users\\mob\\AppData\\Local\\Android\\Sdk
Pratik Khadtale
  • 265
  • 4
  • 11
1

I Solved the issues by below setting:

Adding the following commands at end in my android > gradlew script:

yes | $ANDROID_HOME/tools/bin/sdkmanager "platforms;android-28"

yes | $ANDROID_HOME/tools/bin/sdkmanager "build-tools;28.0.3"

And Under android > gradle > wrapper > gradle-wrapper.properties change

distributionUrl=https://services.gradle.org/distributions/gradle-6.{any}-all.zip

to

distributionUrl=https://services.gradle.org/distributions/gradle-6.3-all.zip

And also check node version if node v12 or above then update JDK v{any} to JDK v14.

Also in android > build.gradle change

buildToolsVersion: {any} to buildToolsVersion: 28.0.3

And before changing buildToolsVersion check whether you have installed v28.0.3 or not. If not then no problem the above two commands install it automatically.

and the last thing is to check whether you have the local.properties file or not. If it is present under android folder then check your sdk path is correct. And if it is not present then under android folder create a new file named local.properties and under that file write the following command:

sdk.dir=Your SDK folder path

Hopefully, after the following setting you are good to go to run npx react-native run-android

This Worked for me!

1

i had similar issues on my react native project but i fix then using the following steps on windows users:

  1. Delete your node_modulues and reinstall it
  2. check or increase your grade distributionUrl to 6.+
  3. create or your local.properties to match this sdk.dir=C:\\Users\\USER\\AppData\\Local\\Android\\sdk
  4. add the following under your gradew

yes | $ANDROID_HOME/tools/bin/sdkmanager "platforms;android-28"

yes | $ANDROID_HOME/tools/bin/sdkmanager "build-tools;28.0.3"

Ejeh
  • 425
  • 5
  • 7
0

First of all, understand that the JavaIOException occurs when the java could not file the directory or any file it is looking for. So, in your case the gradlew is looking for the SDK and it is not finding it.

To resolve this issue, check build.gradle for this:

ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 16
    compileSdkVersion = 28
    targetSdkVersion = 28
}

As, you see the buildToolsVersion = "28.0.3". This name should be under your $SDK_DIR/build-tools/ by the folder named 28.0.3. If your buildToolsVersion and the name of the folder is mismatched it throws JavaIOException. So, change the buildToolsVersion as you require from here.

If this does not work, try restarting your PC.

0

Ive just remove both of these lines from gradle local.properties

org.gradle.java.home="C:\\Program Files\\Java\\jdk-19"
sdk.dir = "D:\\Android_SDK"

and then added this enviroment variable to my system :

ANDROID_SDK_ROOT -> "Path of my installed SDK". like this :

enter image description here

Ahad Porkar
  • 1,666
  • 2
  • 33
  • 68