Gradle似乎在我正在进行的项目中丢失了构建类型.我可以重新创建一个小问题,如下所示.我有以下文件:
build.gradle
local.properties
src/main/AndroidManifest.xml
的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:
sdk.dir=/path/to/android-sdk-linux
的src / main / AndroidManifest.xml中:
我希望Gradle生成任务installDebug和installRelease,因为我将调试和发布定义为buildTypes.但事实并非如此.命令gradle任务产生:
: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
------------------
...
出了什么问题?为什么不安装任务安装?
最佳答案
首先,您需要在根项目中创建密钥库.
您需要在build.gradle中提供这些详细信息.
您需要在build.gradle中提供这些详细信息.
您可以创建两个signingConfigs debug&如果你想要释放.
最后在buildTypes中链接到那个.
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任务中可用
希望这对你有所帮助.