在项目':app'中找不到任务'installDebug'

时间:2019-10-15 09:03:08

标签: react-native react-native-android react-native-firebase

当我尝试执行以下代码时,我的本机应用程序出现错误

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'.

我从react-native-firebase下载了react-native应用,甚至无法在android上进行测试。

2 个答案:

答案 0 :(得分:1)

发生这种情况是因为不存在密钥库。请遵循https://facebook.github.io/react-native/docs/0.60/signed-apk-android

中提到的步骤
  1. 您可以使用keytool生成私钥。 (说明因操作系统而异)
  2. 编辑文件~/.gradle/gradle.propertiesandroid/gradle.properties,然后添加以下内容(用正确的密钥库密码,别名和密钥密码替换*****)
 MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore 
 MYAPP_UPLOAD_KEY_ALIAS=my-key-alias
 MYAPP_UPLOAD_STORE_PASSWORD=*****
 MYAPP_UPLOAD_KEY_PASSWORD=*****
  1. 在您的项目文件夹中编辑文件android/app/build.gradle,并添加签名配置,
...
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
        }
    }
}
...

答案 1 :(得分:0)

确保您在Windows中使用PowerShell,而不是Git Bash