Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define apk output directory when using gradle?

Tags:

How to define apk output directory when using gradle?

I would like to have possibility to upload apk to shared folder after each build.

like image 796
Ziem Avatar asked Apr 03 '14 09:04

Ziem


People also ask

Where is APK after Gradle build?

All APKs you build are saved in project_name / module_name /build/outputs/apk/ . For more information, see Run Apps on a Hardware Device.

How do I change the Gradle path in Android Studio?

To change its path go to this path File > Settings... > Build, Execution, Deployment > Gradle In the Global Gradle settings Change Service directory path to what you want.

Where is the output of Gradle build?

By default, gradle outputs generated source files into build/classes directory.

Where do Gradle files go Android Studio?

In File Explorer right-click on the This PC (or Computer) icon, then click Properties -> Advanced System Settings -> Environmental Variables. Under System Variables select Path, then click Edit. Add an entry for C:\Gradle\gradle-4.1\bin. Click OK to save.


1 Answers

thats work for me:

android.applicationVariants.all { variant ->     def outputName = // filename     variant.outputFile = file(path_to_filename) } 

or for Gradle 2.2.1+

android {     applicationVariants.all { variant ->         variant.outputs.each { output ->             output.outputFile = new File(path_to_filename, output.outputFile.name)         }     } } 

but "clean" task will not drop that apk, so you should extend clean task as below:

task cleanExtra(type: Delete) {     delete outputPathName }  clean.dependsOn(cleanExtra) 

full sample:

apply plugin: 'android'  def outputPathName = "D:\\some.apk"  android {     compileSdkVersion 19     buildToolsVersion "19.0.3"      defaultConfig {         minSdkVersion 8         targetSdkVersion 19         versionCode 1         versionName "1.0"     }     buildTypes {         release {             runProguard false             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'         }     }      applicationVariants.all { variant ->         variant.outputFile = file(outputPathName)     } }  dependencies {     compile 'com.android.support:appcompat-v7:19.+'     compile fileTree(dir: 'libs', include: ['*.jar']) }  task cleanExtra(type: Delete) {     delete outputPathName }  clean.dependsOn(cleanExtra) 
like image 147
gerbit Avatar answered Sep 19 '22 15:09

gerbit