问题描述
摇篮似乎已经失去了一个项目,我工作的一个构建类型。我可以如下重新建立一个最小的问题。我有以下文件:
Gradle seems to have lost a build type in a project I am working on. I can recreate a minimal problem as follows. I have the following files:
build.gradle
local.properties
src/main/AndroidManifest.xml
的build.gradle:
build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 1
targetSdkVersion 23
}
buildTypes {
debug {
}
release {
}
}
}
local.properties:
local.properties:
sdk.dir=/path/to/android-sdk-linux
的src / main / AndroidManifest.xml中:
src/main/AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="example"/>
我希望摇篮生成任务 installDebug
和 installRelease
,因为我定义调试
和发布
为 buildTypes
。然而,这种情况并非如此。命令任务的gradle
生产:
I would expect Gradle to generate tasks installDebug
and installRelease
, since I define debug
and release
as buildTypes
. However, this isn't the case. The command gradle tasks
produces:
:tasks
------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------
...
Install tasks
-------------
installDebug - Installs the Debug build.
installDebugAndroidTest - Installs the android (on device) tests for the Debug build.
uninstallAll - Uninstall all applications.
uninstallDebug - Uninstalls the Debug build.
uninstallDebugAndroidTest - Uninstalls the android (on device) tests for the Debug build.
uninstallRelease - Uninstalls the Release build.
Verification tasks
------------------
...
这是怎么回事了?为什么不是任务 installRelease
可用?
推荐答案
有关发行首先你需要在根项目创建密钥库
。
而你需要提供的build.gradle这些细节。
For release first you need to create keystore
in root project.And you need to provide those details in build.gradle.
您可以创建两个 signingConfigs
调试和放大器;松开两个,如果你想要的。
You can create two signingConfigs
debug & release both if you want.
最后在 buildTypes
链接到这一点。
At last in buildTypes
link to that.
android {
signingConfigs {
debug {
keyAlias 'alias'
keyPassword 'password'
storeFile file('../xyz.jks')
storePassword 'password'
}
}
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 1
targetSdkVersion 23
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.debug
}
}
然后 installRelease
将在 gradle这个
任务
希望这对你有所帮助。
这篇关于摇篮建立任务installRelease缺少Android项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!