问题
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.
回答1:
This happens because there isn't a keystore present. Follow the steps mentioned in https://reactnative.dev/docs/signed-apk-android
- You can generate a private signing key using keytool. (instructions vary according to operating system)
- Edit the file
~/.gradle/gradle.properties
orandroid/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=*****
- 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
}
}
}
...
来源:https://stackoverflow.com/questions/58390956/task-installdebug-not-found-in-project-app