本文介绍了在项目“:app"中找不到任务“installDebug"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试执行以下代码时,我的 react-native 应用程序出错

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

我从 react-native-firebase 下载了 react-native 应用程序,甚至无法使用 android 进行测试.

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

推荐答案

发生这种情况是因为不存在密钥库.按照 https://reactnative.dev/docs/signed-apk-android 中提到的步骤操作一个>

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

  1. 您可以使用 keytool 生成私有签名密钥.(说明因操作系统而异)
  2. 编辑文件 ~/.gradle/gradle.propertiesandroid/gradle.properties,并添加以下内容(将 ***** 替换为正确的密钥库密码、别名和密钥密码),
  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. 编辑项目文件夹中的 android/app/build.gradle 文件,并添加签名配置,
  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
        }
    }
}
...

这篇关于在项目“:app"中找不到任务“installDebug"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 18:04