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
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
My 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?
Open your gradle. properties file in Android Studio. Restart Android Studio for your changes to take effect. Click Sync Project with Gradle Files to sync your project.
Android Studio uses Gradle, an advanced build toolkit, to automate and manage the build process, while allowing you to define flexible custom build configurations. Each build configuration can define its own set of code and resources, while reusing the parts common to all versions of your app.
Build Variants
pane, typically found along the lower left side of the window:debug
to release
shift+f10
run!!then, Android Studio will execute assembleRelease
task and install xx-release.apk to your device.
in the latest version of android studio, you can just do:
./gradlew assembleRelease
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.
See the docs here
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 { } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With