Search code examples
react-nativereact-native-firebase

Task 'installDebug' not found in project ':app'


I get error on my react-native app while I am trying to execute following code

react-native run-android --variant=release
Starting a Gradle Daemon (subsequent builds will be faster)

> Configure project :react-native-firebase
react-native-firebase: using React Native prebuilt binary from /Users/sanglee/Documents/react-native-firebase-starter/node_modules/react-native/android

FAILURE: Build failed with an exception.

* What went wrong:
Task 'installDebug' not found in project ':app'.

I downloaded react-native app from react-native-firebase and cannot even test with android.


Solution

  • This happens because there isn't a keystore present. Follow the steps mentioned in https://reactnative.dev/docs/signed-apk-android

    1. You can generate a private signing key using keytool. (instructions vary according to operating system)
    2. Edit the file ~/.gradle/gradle.properties or android/gradle.properties, and add the following (replace ***** with the correct keystore password, alias and key password),
     MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore 
     MYAPP_UPLOAD_KEY_ALIAS=my-key-alias
     MYAPP_UPLOAD_STORE_PASSWORD=*****
     MYAPP_UPLOAD_KEY_PASSWORD=*****
    
    1. Edit the file android/app/build.gradle in your project folder, and add the signing config,
    ...
    android {
        ...
        defaultConfig { ... }
        signingConfigs {
            release {
                if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                    storeFile file(MYAPP_UPLOAD_STORE_FILE)
                    storePassword MYAPP_UPLOAD_STORE_PASSWORD
                    keyAlias MYAPP_UPLOAD_KEY_ALIAS
                    keyPassword MYAPP_UPLOAD_KEY_PASSWORD
                }
            }
        }
        buildTypes {
            release {
                ...
                signingConfig signingConfigs.release
            }
        }
    }
    ...