问题
I have some troubles trying to generate a release of my app.
App runs normally in emulator with react-native run-android
.
when i try to run 'gradlew assembleRelease
' in android directory of my app, i get these :
D:\REACTNATIVE\finalprj\android>gradlew assembleRelease
FAILURE: Build failed with an exception.
What went wrong:
Could not determine the dependencies of task ':app:lintVitalRelease'.
Could not resolve all task dependencies for configuration ':app:lintClassPath'.
Could not find com.android.tools.lint:lint-gradle:26.4.2.
Searched in the following locations:
- file:/C:/Users/Sam/.m2/repository/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.pom
- file:/C:/Users/Sam/.m2/repository/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.jar
- https://dl.google.com/dl/android/maven2/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.pom
- https://dl.google.com/dl/android/maven2/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.jar
- file:/D:/REACTNATIVE/finalprj/node_modules/react-native/android/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.pom
- file:/D:/REACTNATIVE/finalprj/node_modules/react-native/android/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.jar
- file:/D:/REACTNATIVE/finalprj/node_modules/jsc-android/dist/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.pom
- file:/D:/REACTNATIVE/finalprj/node_modules/jsc-android/dist/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.jar
- https://jcenter.bintray.com/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.pom
- https://jcenter.bintray.com/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.jar
Required by:
project :app
build.gradle :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath('com.android.tools.build:gradle:3.4.2')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
jcenter()
google()
}
}
Help me plz
any comments and suggestions are appreciated.
回答1:
You have to sign the release APK when you try to create it.
You can use jarsigner
to sign an App Bundle from the command line. To sign APK instead, you must use zipalign
and apksigner
as follows:
- In the
Androidstudio
, select View > Tool Windows > Terminal to open the command line and navigate to the directory where the unsigned APK is located. - Align the unsigned APK using
zipalign
:
zipalign -v -p 4 my-app-unsigned.apk my-app-unsigned-aligned.apk
- Sign your APK with your private key using
apksigner
:
apksigner sign --ks my-release-key.jks --out my-app-release.apk my-app-unsigned-aligned.apk
- Verify that your APK is signed:
apksigner verify my-app-release.apk
Configure Gradle to sign your app
Open the module-level build.gradle
file and add the signingConfigs {}
block with entries for storeFile
, storePassword
, keyAlias
and keyPassword
, and then pass that object to the signingConfig property in your build type. For example:
android {
...
defaultConfig { ... }
signingConfigs {
release {
// You need to specify either an absolute path or include the
// keystore file in the same directory as the build.gradle file.
storeFile file("my-release-key.jks")
storePassword "password"
keyAlias "my-alias"
keyPassword "password"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
...
}
}
}
来源:https://stackoverflow.com/questions/57539728/react-native-project-build-failed-could-not-find-com-android-tools-lint-could