如何设置摇篮和Android的工作室做发布版本?摇篮、如何设置、工作室、版本

2023-09-04 08:44:08 作者:我用力爱过,却还是和你错过。今天QQ乐园为大家送上一组非常伤

我想建立Android应用程序,并开始在上面签名。 为此,我需要有apk文件的发布版本。谷歌文档建议只有Eclipse和蚂蚁的方式有发布版本:http://developer.android.com/tools/publishing/app-signing.html#releasecompile

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 builds: http://developer.android.com/tools/publishing/app-signing.html#releasecompile

不过,我无法找到如何强制APK的摇篮构建发行版本。 build.gradle 并没有给出任何暗示无论是。 gradlew任务提示,没有安装版本的配置,但卸载版本存在:

However I cannot find how to force gradle build release version of apk. build.gradle does not give any hints either. gradlew tasks suggests, that there is no install Release configuration, but uninstall release exists:

Install tasks
-------------
installDebug - Installs the Debug build
installTest - Installs the Test build for the Debug build
uninstallAll - Uninstall all applications.
uninstallDebug - Uninstalls the Debug build
uninstallRelease - Uninstalls the Release build
uninstallTest - Uninstalls the Test build for the Debug build

我的 build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.android.support:support-v4:13.0.+'
    compile files('libs/android-support-v4.jar')
    compile project(":libraries:ActionBarSherlock")
    compile project(":libraries:CollabsibleSearchMenu")
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.0.1"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 16
    }
}

我所缺少的?

What I am missing?

推荐答案

在机器人工作室的最新版本,你可以做:

in the latest version of android studio, you can just do:

./gradlew assembleRelease

或Ar的简称。这将产生一个无符号的释放APK。建立一个签名的apk同样可以做,也可以使用生成 - >生成机器人工作室签名的.apk

or aR for short. This will produce an unsigned release apk. Building a signed apk can be done similarly or you can use Build -> Generate Signed Apk in Android Studio.

此处查看文档

下面是我build.gradle供参考:

Here is my build.gradle for reference:

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:0.5.+'
  }
}
apply plugin: 'android'

dependencies {
  compile fileTree(dir: 'libs', include: '*.jar')
}

android {
compileSdkVersion 17
buildToolsVersion "17.0.0"

sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }

    // Move the tests to tests/java, tests/res, etc...
    instrumentTest.setRoot('tests')

    // Move the build types to build-types/<type>
    // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
    // This moves them out of them default location under src/<type>/... which would
    // conflict with src/ being used by the main source set.
    // Adding new build types or product flavors should be accompanied
    // by a similar customization.
    debug.setRoot('build-types/debug')
    release.setRoot('build-types/release')

}

buildTypes {
    release {

    }
}