Gradle 似乎在我正在处理的项目中丢失了构建类型。我可以重新创建一个最小的问题,如下所示。我有以下文件:
build.gradle
local.properties
src/main/AndroidManifest.xml
构建.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 {
}
}
}
本地.属性:
sdk.dir=/path/to/android-sdk-linux
src/main/AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="example"/>
我希望 Gradle 生成任务installDebug
and installRelease
,因为我定义debug
and release
as buildTypes
。然而,事实并非如此。命令gradle tasks
产生:
: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
可用的?