Android项目中缺少Gradle构建任务installRelease

前端之家收集整理的这篇文章主要介绍了Android项目中缺少Gradle构建任务installRelease前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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中提供这些详细信息.

您可以创建两个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任务中可用

希望这对你有所帮助.

原文链接:https://www.f2er.com/android/430184.html

猜你在找的Android相关文章