Yewon Kim
Yewon Kim

Reputation: 53

Two errors (Build failed and Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081) keep happening

I got two errors (Build failed and command failed). I tried to change my port number or gradle version..etc.. but this two error keep happening :( Please help me I'm soooo exhausted.

/* this is my versions */
    buildscript {
        ext {
            buildToolsVersion = "29.0.2"
            minSdkVersion = 16
            compileSdkVersion = 29
            targetSdkVersion = 29
        }
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath("com.android.tools.build:gradle:3.2.0")
            classpath 'com.google.gms:google-services:4.0.1'
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    wrapper {
        gradleVersion = '4.6'


/* this is my error */
    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.2/userguide/command_line_interface.html#sec:command_line_warnings
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    A problem occurred configuring project ':app'.
    > Failed to notify project evaluation listener.
       > org.gradle.api.file.ProjectLayout.fileProperty(Lorg/gradle/api/provider/Provider;)Lorg/gradle/api/file/RegularFileProperty;       
    
    * 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 1m 8s
    
    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

Upvotes: 0

Views: 600

Answers (2)

Ujjawal Maurya
Ujjawal Maurya

Reputation: 616

Here is how i resolved:


1. Navigate to the android directory:

cd android

2. Clean the build:

./gradlew clean

3. Rebuild the app:

./gradlew assembleDebug

4. Then try:

cd ..
npx react-native run-android

Upvotes: 0

Pruthviraj Lakhara
Pruthviraj Lakhara

Reputation: 51

Can tell which distribution url you are using ? (can find in ../android/gradle/wrapper/gradle-wrapper.properties)

many time it give error

and if you are using physical device then please check api level of your device if it is old then try in new one

Upvotes: 2

Related Questions