I am looking dynamically for the APK name for each assembly with a date / time (yyMMddHHmm). I completed this and gradle builds and correctly calls the APK, however Android Studio will not record the correct name to try to click on the device.
There is a question on this topic with good information confirming the problem and that manual synchronization is required before each build. Android Studio downloads a sterile APK to the device if gradle has custom logic changing the name of the APK
For a complete picture, here is my build.gradle
android { compileSdkVersion 22 buildToolsVersion "22.0.1" // grab the date/time to use for versionCode and file naming def date = new Date(); def clientBuildDate = date.format('yyMMddHHmm') // for all client files, set the APK name applicationVariants.all { variant -> variant.outputs.each { output -> output.outputFile = new File(output.outputFile.parent, "myapp-" + versionName.replace(".","_") + "-" + clientBuildDate + ".apk") } } .... defaultConfig{...} buildTypes{...} compileOptions{...} signingConfigs{...} }
The above will generate output, for example:
myapp-1_0_0-1507021343.apk myapp-1_0_0-1507021501.apk myapp-1_0_0-1507021722.apk
but Android Studio will always try to download the first version to the phone, because it is not synchronized and does not know the name change after each assembly.
Is there any suggestion on how to force synchronize every build / launch of Android studio? Manually synchronizing before building is a show stopper, and I only need to go back to the default APK naming scheme.
Usage: AS 1.2.1.1 and 'com.android.tools.build: gradle: 1.2.3'
android android-studio gradle
Ryan wick
source share