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:
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:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="example"/>
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
------------------
...
What is going wrong? Why isn't task installRelease
available?
The top-level build.gradle file, located in the root project directory, defines dependencies that apply to all modules in your project. By default, the top-level build file uses the plugins block to define the Gradle dependencies that are common to all modules in the project.
The work that Gradle can do on a project is defined by one or more tasks. A task represents some atomic piece of work which a build performs. This might be compiling some classes, creating a JAR, generating Javadoc, or publishing some archives to a repository.
The build scripts of all projects which are part of the build are executed. Gradle determines the subset of the tasks, created and configured during the configuration phase, to be executed. The subset is determined by the task name arguments passed to the gradle command and the current directory.
For release first you need to create keystore
in root project.
And you need to provide those details in build.gradle.
You can create two signingConfigs
debug & release both if you want.
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
}
}
Then installRelease
will be also available in gradle
Task
Hope this be helpful for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With