Android.Gradle: Autoincrement Versoin Name before deploy - android

Gradle2 4.2
My app/build.gradle:
android {
compileSdkVersion 26
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.myproject"
minSdkVersion 16
targetSdkVersion 23
versionCode 25
versionName "1.2.25"
}
}
My steps for deploy apk to Fabric (Beta by CrashLytics)
Manually increment versionCode and verionName. In this example: versionCode 26 and versionName "1.2.26"
Create distributive (apk) and deploy to CrashLytics by command:
gradlew assembleDebug crashlyticsUploadDistributionDebug
And as result my apk success deploy to Fabric with versionName = "1.2.26"
OK. It's work fine.
But I need to automatically increment versionCode and versionName BEFORE deploy to Fabric.
To do this I need to write custom Gradle task. Does my approach correct?

Related

minSdkVersion is newer than the device API Level error while installing app

I am installing Android app with target sdk version android S in Android phone with Api level 30. My default config settings for app is like
compileSdkVersion 'android-S'
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.test"
minSdkVersion 21
targetSdkVersion "S"
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
But when I install the apk in Emulator with Api Level 30 I am getting error as
Installation did not succeed.
The application could not be installed: INSTALL_FAILED_OLDER_SDK
The application's minSdkVersion is newer than the device API level.
How to resolve this ? Which things need to be modified to make it working ?
targetSdkVersion "S"
Using a prelimary version the minSdkVersion becomes S too automatically.
Changing to this version worked
compileSdkVersion 'android-S'
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.test"
minSdkVersion 21
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Android instant & installable app set different version code

I have an android app with instant feature. I want to set versionCode 1 for instant app and versionCode 1000 for installable app.
I have 3 build.gradle for base, installed and instant feature.
base app
defaultConfig {
applicationId "com.mypackage"
minSdkVersion 16
targetSdkVersion 29
versionCode = 1
versionName = '1.0.0'
}
installed app
defaultConfig {
applicationId "com.mypackage"
minSdkVersion 16
targetSdkVersion 29
versionCode = 1000
versionName = '1.0.0'
}
instant app
defaultConfig {
applicationId "com.mypackage"
minSdkVersion 16
targetSdkVersion 29
versionCode = 1
versionName = '1.0.0'
}
When building android app bundle, I am getting versionCode 1 for both instant & installable version. versionCode is always picked from base variant build.gradle.
How can I set versionCode 1000 for installable version?
I am trying to achieve this as per android documents.
Restart the version codes for the Google Play Instant experience at 1.
Increase the version code of the installable APK by a large number, such as 1000, to ensure that there is enough space for your instant experience's version number to increase.

Cannot find PROCESSED_RES output for Main

Getting this error while building android app bundle -
Cannot find PROCESSED_RES output for Main{type=MAIN, fullName=debug,
filters=[], versionCode=-1, versionName=null}
I have just added a dynamic feature module in existing android studio project, Getting this error while building android app bundle
change versionName and versionCode increment with every release
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.company.app"
minSdkVersion 16
targetSdkVersion 28
versionCode 14 // increment with every release
versionName '1.4.8' // change with every release
}
}

Gradle related error

I have recently started using the android studio. Just after installing and downloading all the requisite files, I am welcomed by this error,"Failed to find the target with the hash string 'API 27'....", whereas I already have both API 27 and 28 installed (although 28 shows up to be partly installed).
I am completely new to this software.
Tools
SDK
error
you should use like below in gradle
{
compileSdkVersion 27
buildToolsVersion '27.0.1'
defaultConfig {
applicationId "xxxxxxxxx"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
}
don't write like compileSdkVersion 'API 27' its compileSdkVersion 27 only

Android.Gradle: Autoincrement versionCode/versionName before create distributive

Android Studio 2.3.3, Gradle 4.2
My app/build.gradle snippet:
defaultConfig {
applicationId "com.myproject"
minSdkVersion 16
targetSdkVersion 23
versionCode 3
versionName "1.2.3"
}
My steps to create release distributive (apk):
Increment versionCode and versionName
Run, from console, command: gradlew assembleRelease
OK. It's work.
But I do not want manually increment versionCode/versionName before create distributive.
Is it possible to automate it? Or I need to write custom Gradle task?

Categories

Resources