我有一些麻烦试图生成我的应用程序的发行版。
应用在react-native run-android
的模拟器中正常运行。
当我尝试在我的应用的android目录中运行“ gradlew assembleRelease
”时,我得到了这些信息:
D:\REACTNATIVE\finalprj\android>gradlew assembleRelease
失败:构建失败,并出现异常。
出了什么问题:
无法确定任务':app:lintVitalRelease'的依赖性。
无法解决配置':app:lintClassPath'的所有任务依赖项。
找不到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()
}
}
请帮助我
任何评论和建议都将受到赞赏。
答案 0 :(得分:0)
尝试创建release APK时必须签名。
您可以使用jarsigner
从命令行对应用程序捆绑包进行签名。要对APK进行签名,您必须使用zipalign
和apksigner
,如下所示:
Androidstudio
中,选择“视图”>“工具窗口”>“终端” 以
打开命令行并导航到目录
未签名的APK已定位。zipalign
对齐未签名的APK:zipalign -v -p 4 my-app-unsigned.apk my-app-unsigned-aligned.apk
apksigner
使用私钥对APK签名:apksigner sign --ks my-release-key.jks --out my-app-release.apk my-app-unsigned-aligned.apk
apksigner verify my-app-release.apk
配置Gradle以对您的应用进行签名
打开模块级build.gradle
文件,并添加signingConfigs {}
块,其中包含storeFile
,storePassword
,keyAlias
和keyPassword
的条目,然后将该对象传递给您的构建类型中的signingConfig属性。例如:
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
...
}
}
}
答案 1 :(得分:0)
将此添加到 android {....} 内的 build.gradle 中。
android{
....
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}