1

"I'm using command line to build android project but gradlew installDebug command is giving an error. Showing Task 'installDebug' not found in root project 'Android'"

My top-level build.gradle file:-

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

My Module-level build.gradle file is:-

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    defaultConfig {
        applicationId "com.avinash.myapplication"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:appcompat-v7:25.3.1'
}
Avinash
  • 11
  • 1
  • 3

2 Answers2

1

Step 1 :

Don't use react-native run-android.

Step 2 :

If you are using Windows and you don't have the file gradlew.bat (but only gradlew), download it from here or copy it from an another react-native project.

Step 3 :

In directory /android execute the command gradlew tasks or gradlew.bat tasks if you are on Windows.

Check the commands that can be used in Install tasks

Install tasks
-------------
installDevKernelDebug - Installs the DebugDevKernel build.
installDevKernelDebugAndroidTest - Installs the android (on device) tests for the DevKernelDebug build.
installProdKernelDebug - Installs the DebugProdKernel build.
installProdKernelDebugAndroidTest - Installs the android (on device) tests for the ProdKernelDebug build.
uninstallAll - Uninstall all applications.
uninstallDevKernelDebug - Uninstalls the DebugDevKernel build.
uninstallDevKernelDebugAndroidTest - Uninstalls the android (on device) tests for the DevKernelDebug build.
uninstallDevKernelRelease - Uninstalls the ReleaseDevKernel build.
uninstallProdKernelDebug - Uninstalls the DebugProdKernel build.
uninstallProdKernelDebugAndroidTest - Uninstalls the android (on device) tests for the ProdKernelDebug build.
uninstallProdKernelRelease - Uninstalls the ReleaseProdKernel build.
Use the command gradlew installDevKernelDebug.

Step 4 :

If you are using react-native, go in the root directory and run npm start or expo start if you are using expo. In the browser go to http://localhost:19002 (or the port it says on your console).

Select the local connection and recover the value like expXXXXXXXXXXXXXXXXXXX://127.0.0.1:19000.

Check the file on .\android\app\src\main\java\host\exp\exponent\generated\DetachBuildConstants.java and copy the value in DEVELOPMENT_URL variable.

Step 5 :

Exit Metro Bundler with CTRL+C on the console.

Step 6 :

Run cd android to enter ./android/ directory

Step 7 :

Run gradlew installDevKernelDebug or other task you listed on Step 3.

I found most of these directions on this thread: https://github.com/expo/expo/issues/4097

ofundefined
  • 2,692
  • 2
  • 18
  • 35
0

You might be missing the Android NDK, can try to install it using the SDK Manager of Android-Studio.

For details can refer to: https://stackoverflow.com/a/58987549/1435026

fanyangxi
  • 562
  • 7
  • 6