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

2024-04-25

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可用的?


要首先发布,您需要创建keystore在根项目中。 您需要在 build.gradle 中提供这些详细信息。

您可以创建两个signingConfigs如果需要的话,调试并发布两者。

终于在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
            }
        }

Then installRelease也将在gradle Task

希望这对您有帮助。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android 项目中缺少 Gradle 构建任务 installRelease 的相关文章

随机推荐