How to set up gradle and android studio to do release build?

前端 未结 6 1999
礼貌的吻别
礼貌的吻别 2020-12-02 07:21

I want to build android app and start signing it. For that I need to have Release version of apk. Google documentation suggests only Eclipse and ant ways to have release bu

6条回答
  •  天涯浪人
    2020-12-02 07:36

    To activate the installRelease task, you simply need a signingConfig. That is all.

    From http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Android-tasks:

    Finally, the plugin creates install/uninstall tasks for all build types (debug, release, test), as long as they can be installed (which requires signing).

    Here is what you want:

    Install tasks
    -------------
    installDebug - Installs the Debug build
    installDebugTest - Installs the Test build for the Debug build
    installRelease - Installs the Release build
    uninstallAll - Uninstall all applications.
    uninstallDebug - Uninstalls the Debug build
    uninstallDebugTest - Uninstalls the Test build for the Debug build
    uninstallRelease - Uninstalls the Release build   <--- release
    

    Here is how to obtain the installRelease task:

    Example build.gradle:

    buildscript {
        repositories {
            jcenter()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:1.2.3'
        }
    }
    
    apply plugin: 'com.android.application'
    
    android {
      compileSdkVersion 22
      buildToolsVersion '22.0.1'
    
      defaultConfig {
        applicationId 'demo'
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName '1.0'
      }
    
      signingConfigs {
          release {
              storeFile 
              storePassword 
              keyAlias 
              keyPassword 
          }
      }
    
      buildTypes {
        release {
            signingConfig signingConfigs.release
        }
      }
    }
    

提交回复
热议问题