我想构建android应用并开始对其进行签名。为此,我需要发布apk的发行版。Google文档仅建议使用Eclipse和蚂蚁发布版本的方法:http : //developer.android.com/tools/publishing/app-signing.html#releasecompile
但是我找不到如何强制gradle build发行版本的apk。build.gradle
也没有给出任何提示。gradlew tasks
建议没有安装发布版本的配置,但存在卸载版本:
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
}
}
我缺少什么?
在最新版本的android studio中,您可以执行以下操作:
./gradlew assembleRelease
或aR
简称。这将产生一个未签名的发布apk。构建签名的apk可以类似地完成,也可以在Android Studio中使用Build-> Generate Signed Apk。
这是我的build.gradle供参考:
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 {
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句