App version shows as 0.0(0) after uploading to Fabric Beta - android

I'm manually uploading the build in Crashlytics Beta. But the version number always shows as 0.0(0) like mentioned in this post. (Please don't mark as duplicate as this is a bit different as this occurs even with manual upload) I'm using Android Studio 3.1.3. and Gradle version 4.4
Here's my gradle :
classpath 'io.fabric.tools:gradle:1.+'
compile('com.crashlytics.sdk.android:crashlytics:2.9.1#aar') {
transitive = true;
}
Complete app/build.gradle :
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.3'
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.getkeepsafe.dexcount'
apply plugin: 'io.fabric'
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven { url 'http://kochava.bintray.com/maven' }
}
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
flavorDimensions "default"
useLibrary 'org.apache.http.legacy'
dexOptions {
preDexLibraries true
javaMaxHeapSize "2g" // Use gig increments depending on needs
}
lintOptions {
abortOnError false
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
repositories {
flatDir { dirs 'libs' }
}
signingConfigs {
debugConfig {
storeFile file('keystore/debug.keystore')
storePassword "/*password*/"
keyAlias "androiddebugkey"
keyPassword "/*password*/"
}
releaseConfig {
storeFile file("keystore/release.keystore")
storePassword "/*password*/"
keyAlias "/*KeyAliasname*/"
keyPassword "/*password*/"
}
}
// Versioning
def versionPropsFile = file('version.properties')
def versionBuild
/*Setting default value for versionBuild which is the last incremented value stored in the file */
if (versionPropsFile.canRead()) {
Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
versionBuild = versionProps['VERSION_BUILD'].toInteger()
} else {
throw new GradleException("Could not read version.properties!")
}
/*Wrapping inside a method avoids auto incrementing on every gradle task run. Now it runs only when we build apk*/
ext.autoIncrementBuildNumber = {
if (versionPropsFile.canRead()) {
def Properties versionProps = new Properties()
versionProps.load(file("version.properties").newReader()/*new FileInputStream(versionPropsFile)*/)
versionBuild = versionProps['VERSION_BUILD'].toInteger() + 1
versionProps['VERSION_BUILD'] = versionBuild.toString()
versionProps.store(versionPropsFile.newWriter(), null)
} else {
throw new GradleException("Could not read version.properties!")
}
}
def appId = "com.example.appName"
def appName = "My App"
def appBuildName = "appBuildName"
def versionMajor = 6
def versionMinor = 6
def versionPatch = 0
def appVersionName = "${versionMajor}.${versionMinor}.${versionPatch}"
def appVersionCode = versionBuild
defaultConfig {
applicationId appId
minSdkVersion 16
targetSdkVersion 27
resValue "bool", "is_prod", "false"
resValue "bool", "is_prod_staging", "false"
resValue "bool", "is_amazon", "false"
// by default, enable logging
resValue "bool", "is_debuggable", "true"
multiDexEnabled = true
}
buildTypes {
applicationVariants.all { variant ->
variant.outputs.all { output ->
def project = appBuildName
def SEP = "-"
def buildType = variant.variantData.variantConfiguration.buildType.name.toUpperCase()
def flavor = variant.productFlavors[0].name.toUpperCase()
def version = "v" + appVersionName + "." + (appVersionCode - 500000)
def newApkName = project + SEP + version + SEP + buildType + SEP + flavor + ".apk"
println "Output Apk Name: " + newApkName
outputFileName = new File(newApkName)
}
}
debug {
applicationIdSuffix ".debug"
ext.enableCrashlytics = false
}
uat {
initWith(buildTypes.debug)
applicationIdSuffix ".uat"
signingConfig signingConfigs.debugConfig
ext.enableCrashlytics = true
}
staging {
applicationIdSuffix ".uat"
signingConfig signingConfigs.debugConfig
debuggable false
// we want the prod endpoint, with no logging
resValue "bool", "is_prod_staging", "true"
resValue "bool", "is_debuggable", "false"
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ext.enableCrashlytics = true
}
prodStaging {
initWith(buildTypes.staging)
resValue "bool", "is_prod_staging", "false"
resValue "bool", "is_prod", "true"
}
prodStagingNoSuffix {
initWith(buildTypes.prodStaging)
applicationIdSuffix ""
debuggable false
}
release {
// we want the prod endpoint, with no logging
resValue "bool", "is_prod", "true"
resValue "bool", "is_debuggable", "false"
debuggable false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.releaseConfig
ext.enableCrashlytics = true
}
}
productFlavors {
play {
resValue "bool", "is_amazon", "false"
}
amazon {
resValue "bool", "is_amazon", "true"
}
}
// Hook to check if the release/debug task is among the tasks to be executed.
//Let's make use of it
gradle.taskGraph.whenReady { taskGraph ->
def tasks = taskGraph.getAllTasks()
tasks.find {
println it
if (it.name.toLowerCase().contains("package")
&& !it.name.toLowerCase().contains("debug")
&& !it.name.toLowerCase().contains("release")) {
/* when run release task */
/* note that the task cannot be a release as our release codes need to align */
println("We've matches on the internal release task")
autoIncrementBuildNumber()
return true
}
return false
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'com/kofax/android/abc/configuraPK'
exclude 'META-INF/rxjava.properties'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1#aar') {
transitive = true;
}
// Apache 2.0
implementation files('libs/adobeMobileLibrary-4.13.2.jar')
implementation files('libs/dagger-2.7.jar')
implementation files('libs/isg-3.2.0.0.0.761.jar')
implementation files('libs/sdk-release.jar')
implementation files('libs/login-with-amazon-sdk.jar')
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.facebook.android:facebook-android-sdk:4.27.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.5.0'
implementation 'com.squareup:otto:1.3.6'
implementation 'commons-io:commons-io:2.4'
implementation 'commons-codec:commons-codec:1.10'
implementation 'org.apache.commons:commons-lang3:3.4'
implementation 'org.roboguice:roboguice:3.0.1'
implementation 'com.novoda:accessibilitools:1.3.0'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'me.relex:circleindicator:1.2.2#aar'
implementation 'com.kochava.base:tracker:3.0.0#aar'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation project(path: ':linkedin-sdk', configuration: 'default')
implementation 'com.squareup.picasso:picasso:2.5.2'
//rxjava
implementation 'io.reactivex.rxjava2:rxjava:2.1.1'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
//room
implementation 'android.arch.persistence.room:runtime:1.1.1'
annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'
implementation 'android.arch.persistence.room:rxjava2:1.1.1'
//gson
implementation 'com.google.code.gson:gson:2.3.1'
//retrofit
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation 'com.squareup.okhttp3:okhttp:3.4.1'
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
Note : It used to work fine with Android Studio 2.2

Related

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/xxx/xxx/viewmodels/CameraXViewModel;

The APK is generated and everything works at compile time but app crash at runtime. The crash is when launching the camera module for barcode scanning implemented with CameraX.
Here is the crash log:
08-22 17:31:16.537 16660-16660/com.xxx.xxx E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xxx.xxx, PID: 16660
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/xxx/xxx/viewmodels/CameraXViewModel;
at com.xxx.xxx.barcode.CameraXLivePreviewActivity.onCreate(CameraXLivePreviewActivity.kt:94)
at android.app.Activity.performCreate(Activity.java:7314)
at android.app.Activity.performCreate(Activity.java:7305)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2948)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3073)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1774)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:7055)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:523)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:836)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.xxx.xxx.viewmodels.CameraXViewModel" on path: DexPathList[[zip file "/data/app/com.xxx.xxx-LKiFwx0pU2KUfueyYsAm-w==/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx.xxx-LKiFwx0pU2KUfueyYsAm-w==/lib/arm64, /data/app/com.xxx.xxx-LKiFwx0pU2KUfueyYsAm-w==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
Here is line 94 where the ViewModel is accessed.
Kindly refer my build details.
Here is the project-level build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.android.tools.build:gradle:7.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(:app)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.gms.google-services'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.xxx.xxx"
minSdk 21
targetSdk 31
versionCode 19
versionName "1.2.13"
multiDexEnabled true
signingConfig signingConfigs.config
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
buildConfigField "String", "AREA", "\"\""
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
buildConfigField "String", "AREA", "\"\""
}
ABC {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
buildConfigField "String", "AREA", "\"_A\""
}
XYZ {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
buildConfigField "String", "AREA", "\"_X\""
}
}
flavorDimensions "appVariant", "projectCode"
productFlavors {
A {
dimension "appVariant"
}
B {
dimension "appVariant"
}
C {
dimension "appVariant"
}
D {
dimension "appVariant"
}
DEV {
dimension "projectCode"
}
QA {
dimension "projectCode"
}
LIVE {
dimension "projectCode"
}
DEMO {
dimension "projectCode"
}
BETA {
dimension "projectCode"
}
}
applicationVariants.all { variant ->
variant.outputs.all { output ->
def project = "TEST_PROJECT"
def SEP = "_"
def flavor = variant.productFlavors[0].name
def projcode = variant.productFlavors[1].name
def buildType = variant.buildType.name
def buildTypeName = "";
switch (buildType) {
case "ABC": buildTypeName = SEP + "AB"; break;
case "XYZ": buildTypeName = SEP + "XY"; break;
default:
buildTypeName = "";
}
def version = variant.versionName
def date = new Date();
def formattedDate = date.format('ddMMyy_HHmm')
def newApkName = project + buildTypeName + SEP + flavor + SEP + projcode + SEP + version + ".apk"
outputFileName = new File(newApkName)
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
dataBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'androidx.databinding:databinding-runtime:7.0.2'
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.google.firebase:firebase-messaging-ktx:22.0.0'
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.2'
implementation 'androidx.camera:camera-core:1.0.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//Retrofit and GSON
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.2.1'
implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'
//Kotlin Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0"
// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
//Kodein Dependency Injection
implementation "org.kodein.di:kodein-di-generic-jvm:6.2.1"
implementation "org.kodein.di:kodein-di-framework-android-x:6.2.1"
//Android Room
implementation "androidx.room:room-runtime:2.2.5"
implementation "androidx.room:room-ktx:2.2.5"
kapt "androidx.room:room-compiler:2.2.5"
//Android Navigation Architecture
implementation "androidx.navigation:navigation-fragment-ktx:2.2.0-alpha02"
implementation "androidx.navigation:navigation-ui-ktx:2.2.0-alpha02"
implementation 'com.xwray:groupie:2.8.0'
implementation 'com.xwray:groupie-kotlin-android-extensions:2.8.0'
implementation 'com.xwray:groupie-databinding:2.8.0'
implementation "androidx.preference:preference-ktx:1.1.0"
//Image loading
implementation "com.squareup.picasso:picasso:2.71828"
//barcode
implementation 'com.google.mlkit:barcode-scanning:17.0.0'
// CameraX
implementation "androidx.camera:camera-camera2:1.0.0-SNAPSHOT"
implementation "androidx.camera:camera-lifecycle:1.0.0-SNAPSHOT"
implementation "androidx.camera:camera-view:1.0.0-SNAPSHOT"
// On Device Machine Learnings
implementation "com.google.android.odml:image:1.0.0-beta1"
implementation 'com.google.mlkit:camera:16.0.0-beta1'
implementation 'me.dm7.barcodescanner:zxing:1.9.13'
implementation(files("./libs/scandecode-release.aar"))
implementation 'com.valdesekamdem.library:md-toast:0.9.0'
implementation 'com.tt:whorlviewlibrary:1.0.3'
}
Not sure what is wrong.
Any help will be appreciated.
Solved!.
Implemented multidex from the developer site.
https://developer.android.com/studio/build/multidex
Also there were two view model classes CameraXViewModel & CameraXviewModel.kt, removed the file CameraXviewModel.kt from the project. CameraXViewModel is the one which is used and CameraXviewModel was not referenced any where in the project.
ASFAIK Java and Kotlin is case sensitive for classes, so ideally it should work. Here everything compiled and APK generated but app crashed at runtime.
Hope this helps someone.

I have a problem loading widgets in android studio

I do not know why this problem happened I opened my android studio and it does not load the view of my RecyclerView and some other widgets, since I cleaned the cache also used the Rebuild Project but the problem persists, I would appreciate your support
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:scrollbarStyle="outsideOverlay"
android:scrollbarThumbVertical="#android:color/transparent"
android:scrollbars="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:listitem="#layout/item_list_specialties_list"
tools:itemCount="6"
tools:layoutManager="android.support.v7.widget.LinearLayoutManager"
tools:spanCount="1" />
</RelativeLayout>
here is the buildgradle
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply from: "$rootProject.rootDir/app/config.gradle" //Compile Play Store
//apply from: "$rootProject.rootDir/app/config-share-fabric.gradle" //Compile Fabric
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file("keystore.properties")
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
def serverProperties = new Properties()
def serverPropertiesFile = rootProject.file("server.properties")
serverProperties.load(new FileInputStream(serverPropertiesFile))
def configuration = ext.configuration
def configurationUser = ext.configurationUser
def configurationSpecialist = ext.configurationSpecialist
def configurationSeller = ext.configurationSeller
android {
compileSdkVersion configuration.compileSdk
buildToolsVersion configuration.buildTools
defaultConfig {
applicationId configuration.applicationId
minSdkVersion configuration.minimumSdk
targetSdkVersion configuration.targetSdk
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testHandleProfiling true
testFunctionalTest true
multiDexEnabled true
resConfigs("es", "en")
manifestPlaceholders = [
projectName : configuration.projectName,
fabricApiKey: "17fdb5821b7ac5a50e3250fb679a180d9ab54889"
]
resValue("string", "project_name", "\"${configuration.projectName}\"")
// Used by Room, to test migrations
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation":
"$projectDir/schemas".toString()]
}
}
}
//See https://stackoverflow.com/a/36931232
/*sourceSets {
main {
res.srcDirs = [
'src/main/res',
'src/main/res/drawable',
'src/main/res/drawable/splash',
'src/main/res/drawable/selectors'
]
}
}*/
signingConfigs {
debug {
keyAlias keystoreProperties['keyAliasDebug']
keyPassword keystoreProperties['keyPasswordDebug']
storeFile file(keystoreProperties['storeFileDebug'])
storePassword keystoreProperties['storePasswordDebug']
}
configReleaseUser {
keyAlias keystoreProperties['keyAliasUser']
keyPassword keystoreProperties['keyPasswordUser']
storeFile file(keystoreProperties['storeFileUser'])
storePassword keystoreProperties['storePasswordUser']
}
configReleaseSpecialist {
keyAlias keystoreProperties['keyAliasSpecialist']
keyPassword keystoreProperties['keyPasswordSpecialist']
storeFile file(keystoreProperties['storeFileSpecialist'])
storePassword keystoreProperties['storePasswordSpecialist']
}
configReleaseSeller {
keyAlias keystoreProperties['keyAliasSeller']
keyPassword keystoreProperties['keyPasswordSeller']
storeFile file(keystoreProperties['storeFileSeller'])
storePassword keystoreProperties['storePasswordSeller']
}
}
flavorDimensions "app", "server"
productFlavors {
user {
dimension "app"
applicationId configurationUser.applicationId
versionCode configurationUser.versionCode
versionName "${configurationUser.versionMajor}.${configurationUser.versionMinor}" +
".${configurationUser.versionPath}-${configurationUser.versionClasifier}"
proguardFile 'user-proguard-rules.pro'
testApplicationId "pe.com.linkup.android.test.user"
}
specialist {
dimension "app"
applicationId configurationSpecialist.applicationId
versionCode configurationSpecialist.versionCode
versionName "${configurationSpecialist.versionMajor}.${configurationSpecialist.versionMinor}" +
".${configurationSpecialist.versionPath}-${configurationSpecialist.versionClasifier}"
proguardFile 'specialist-proguard-rules.pro'
testApplicationId "pe.com.linkup.android.test.specialist"
}
seller {
dimension "app"
applicationId configurationSeller.applicationId
versionCode configurationSeller.versionCode
versionName "${configurationSeller.versionMajor}.${configurationSeller.versionMinor}" +
".${configurationSeller.versionPath}-${configurationSeller.versionClasifier}"
proguardFile 'seller-proguard-rules.pro'
testApplicationId "pe.com.linkup.android.test.seller"
}
//Desarrollo Local
local {
dimension "server"
applicationIdSuffix ".local"
}
//Desployment Fabric
dev {
dimension "server"
applicationIdSuffix ".dev"
}
//Desployment PlayStore - Testing
staging {
dimension "server"
//applicationIdSuffix ".staging"
}
//Desployment PlayStore - Production
production {
dimension "server"
}
}
// Configura específicamente cada Flavor
productFlavors.all { flavor ->
switch (flavor.name) {
case "user":
flavor.manifestPlaceholders.put("appName", configurationUser.appName)
flavor.resValue("string", "app_name", "\"${configurationUser.appName}\"")
break
case "specialist":
flavor.manifestPlaceholders.put("appName", configurationSpecialist.appName)
flavor.resValue("string", "app_name", "\"${configurationSpecialist.appName}\"")
break
case "seller":
flavor.manifestPlaceholders.put("appName", configurationSeller.appName)
flavor.resValue("string", "app_name", "\"${configurationSeller.appName}\"")
break
case "local":
flavor.buildConfigField("String", "BASE_URL", "\"${serverProperties['baseUrlLocal']}\"")
flavor.buildConfigField("String", "CLIENT_ID", "\"${serverProperties['clientIdLocal']}\"")
flavor.buildConfigField("String", "CLIENT_SECRET", "\"${serverProperties['clientSecretLocal']}\"")
flavor.buildConfigField("String", "GRANT_TYPE", "\"${serverProperties['grantTypeLocal']}\"")
break
case "dev":
flavor.buildConfigField("String", "BASE_URL", "\"${serverProperties['baseUrlDev']}\"")
flavor.buildConfigField("String", "CLIENT_ID", "\"${serverProperties['clientIdDev']}\"")
flavor.buildConfigField("String", "CLIENT_SECRET", "\"${serverProperties['clientSecretDev']}\"")
flavor.buildConfigField("String", "GRANT_TYPE", "\"${serverProperties['grantTypeDev']}\"")
break
case "staging":
flavor.buildConfigField("String", "BASE_URL", "\"${serverProperties['baseUrlStaging']}\"")
flavor.buildConfigField("String", "CLIENT_ID", "\"${serverProperties['clientIdStaging']}\"")
flavor.buildConfigField("String", "CLIENT_SECRET", "\"${serverProperties['clientSecretStaging']}\"")
flavor.buildConfigField("String", "GRANT_TYPE", "\"${serverProperties['grantTypeStaging']}\"")
break
case "production":
flavor.buildConfigField("String", "BASE_URL", "\"${serverProperties['baseUrlProduction']}\"")
flavor.buildConfigField("String", "CLIENT_ID", "\"${serverProperties['clientIdProduction']}\"")
flavor.buildConfigField("String", "CLIENT_SECRET", "\"${serverProperties['clientSecretProduction']}\"")
flavor.buildConfigField("String", "GRANT_TYPE", "\"${serverProperties['grantTypeProduction']}\"")
break
default:
break
}
}
// Configura las variantes merged. Ejm: applicationId ya viene unido con el applicationIdSuffix
applicationVariants.all { variant ->
def name = variant.name
if (name.contains("Local")) {
def filesAuthorityValue = variant.applicationId + ".fileProvider"
variant.mergedFlavor.manifestPlaceholders.put("filesAuthority", filesAuthorityValue)
variant.buildConfigField("String", "FILES_AUTHORITY", "\"${filesAuthorityValue}\"")
} else if (name.contains("Dev")) {
def filesAuthorityValue = variant.applicationId + ".fileProvider"
variant.mergedFlavor.manifestPlaceholders.put("filesAuthority", filesAuthorityValue)
variant.buildConfigField("String", "FILES_AUTHORITY", "\"${filesAuthorityValue}\"")
} else if (name.contains("Staging")) {
def filesAuthorityValue = variant.applicationId + ".fileProvider"
variant.mergedFlavor.manifestPlaceholders.put("filesAuthority", filesAuthorityValue)
variant.buildConfigField("String", "FILES_AUTHORITY", "\"${filesAuthorityValue}\"")
} else if (name.contains("Production")) {
def filesAuthorityValue = variant.applicationId + ".fileProvider"
variant.mergedFlavor.manifestPlaceholders.put("filesAuthority", filesAuthorityValue)
variant.buildConfigField("String", "FILES_AUTHORITY", "\"${filesAuthorityValue}\"")
}
}
buildTypes {
debug {
//applicationIdSuffix ".debug"
minifyEnabled false
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
productFlavors.user.signingConfig signingConfigs.debug
productFlavors.specialist.signingConfig signingConfigs.debug
productFlavors.seller.signingConfig signingConfigs.debug
buildConfigField "boolean", "LOG", "true"
// disable crashlytics
buildConfigField "boolean", "ENABLE_CRASHLYTICS", "false"
ext.enableCrashlytics = false
}
relebug {
//applicationIdSuffix ".relebug"
minifyEnabled false
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "boolean", "LOG", "true"
// disable crashlytics
buildConfigField "boolean", "ENABLE_CRASHLYTICS", "false"
ext.enableCrashlytics = false
matchingFallbacks = ['release']
}
release {
zipAlignEnabled true
minifyEnabled true
shrinkResources true
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
productFlavors.user.signingConfig signingConfigs.configReleaseUser
productFlavors.specialist.signingConfig signingConfigs.configReleaseSpecialist
productFlavors.seller.signingConfig signingConfigs.configReleaseSeller
buildConfigField "boolean", "LOG", "false"
// enable crashlytics
buildConfigField "boolean", "ENABLE_CRASHLYTICS", "true"
ext.enableCrashlytics = true
}
}
// Ignora algunas variantes de compilación para su visualización en la BuildVariant
variantFilter { variant ->
def app = variant.getFlavors().get(0).name
def server = variant.flavors.get(1).name
def isRelease = variant.buildType.name.contains('release')
def isRelebug = variant.buildType.name.contains('relebug')
def isDebug = variant.buildType.name.contains('debug')
if (server.contains('local')) {
variant.setIgnore(false)
} else if (server.contains('dev')) {
variant.setIgnore(false)
} else if (server.contains('staging')) {
variant.setIgnore(false)
} else if (server.contains('production')) {
variant.setIgnore(true) //Temporal
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
lintOptions {
abortOnError false
lintConfig file("../lint.xml")
}
dexOptions {
jumboMode true
//incremental true
}
testOptions {
reportDir "$rootDir/test-reports"
resultsDir "$rootDir/test-results"
unitTests {
returnDefaultValues = true
all {
jvmArgs '-XX:MaxPermSize=256m'
if (it.name == 'testDebugUnitTest') {
systemProperty 'debug', 'true'
}
}
}
}
//Renombrar Apk de salida
applicationVariants.all { variant ->
variant.outputs.all { output ->
def projectName = "linkup"
def formattedDate = new Date().format('yyyyMMdd', TimeZone.getTimeZone("UTC"))
def apkName = "${projectName}-${variant.flavorName}-${variant.versionName}-${variant.versionCode}-${formattedDate}-${variant.buildType.name}" + ".apk"
def apkDirectory = "${output.outputFile.parent}/apk/${variant.flavorName}/${variant.buildType.name}"
//outputFileName = new File(apkDirectory, apkName)
outputFileName = apkName
}
}
crashlytics {
enableNdk true
androidNdkOut 'src/main/obj'
androidNdkLibsOut 'src/main/libs'
}
}
repositories {
jcenter()
google()
mavenCentral()
maven { url "https://jitpack.io" }
maven { url 'https://maven.fabric.io/public' }
}
apply from: "$rootProject.rootDir/app/library.gradle"
def library = ext.library
def libraryTest = ext.libraryTest
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation library.support_appcompat
implementation library.support_recyclerview
implementation library.support_v4
implementation library.support_v13
implementation library.support_design
implementation library.support_cardview
implementation library.support_customtabs
implementation library.support_annotations
implementation library.support_vector_drawable
implementation library.support_constraint
implementation library.support_multidex
implementation library.firebase_core
implementation library.firebase_auth
implementation library.firebase_database
implementation library.firebase_storage
implementation library.firebase_messaging
implementation library.firebase_config
implementation library.firebase_invites
implementation library.exoplayer_core
implementation library.exoplayer_ui
implementation library.exoplayer_dash
implementation library.butterknife
annotationProcessor library.butterknife_compiler
implementation library.retrofit2
implementation library.retrofit2_converter_gson
implementation library.logging_interceptor
implementation library.glide
implementation library.joda_time
implementation library.shortcut_badger
implementation library.smiley_rating
//Room
implementation library.room
annotationProcessor library.room_compiler
implementation library.room_assets
//GMS
implementation library.play_services_location
implementation library.play_services_maps
// Crashlytics
implementation(library.crashlytics) {
transitive = true
}
// Crashlytics NDK
implementation(library.crashlytics_ndk) {
transitive = true
}
implementation library.spinner_date_picker
//Testing
testImplementation libraryTest.junit
testImplementation libraryTest.mockito_core
testImplementation libraryTest.robolectric
testImplementation libraryTest.robolectric_shadows
//UI testing
// Espresso dependenciesVersions
androidTestImplementation(libraryTest.expresso_core, {
exclude group: 'com.android.support', module: 'support-annotations'
})
}
configurations.all {
resolutionStrategy.force library.support_annotations
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.2'
}
//TODO: Pendiente -> https://howards543.ddns.net/gradle-script-with-multi-flavor-resource-management/
task("copyGoogleServicesJson", type: Copy) {
println 'copyGoogleServicesJson'
from('$rootProject.rootDir/app/services/dev/google-services.json')
into("$rootProject.rootDir/app")
include('*.json')
}
//apply from: "$rootProject.rootDir/setup/artifacts.gradle"
apply plugin: 'com.google.gms.google-services'
Just based on the dependencies, these were added correctly and the code did not move, my buildgradle structure it in this way where I use library.gradle to call the libraries by version and this is the specic code of the implementation of the RecyclerView.
ext.versions = [
supportLib : '28.0.0'
]
def version = ext.versions
ext.library = [
support_recyclerview : 'com.android.support:recyclerview-v7:' + version.supportLib
]
Use Fragment with RecyclerView and Activity host for this Fragment.

compile gradle task is always executed

I have a multidex project with minSDK 21, using gradle 4.5.1 and gradle plugin 3.0.1. My issue is that even without any source file change when I try to assemble and deploy to a phone the compile task is executed. When running with --info I get the following reasons:
Task ':app:compileStandardDebugJavaWithJavac' is not up-to-date because:
Input property 'source' file C:...\app\build\generated\source\buildConfig\standard\debug[package]\BuildConfig.java has changed.
Input property 'source' file C:...\app\build\generated\source\dataBinding\standard\debug\android\databinding\layouts\DataBindingInfo.java has changed.
Can you help my identify what could cause these files to change and causes a recompile? I believe the Databinding sources either shouldn't change without changing sources, or it shouldn't affect if the compile task is up-to-date. The same goes for BuildConfig.java.
I have gradle caching, configure on demand and daemon enabled.
Here's the app build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
minSdkVersion 21
targetSdkVersion 25
applicationId 'package'
// for automated testing
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
buildConfigField "boolean", "PUBLIC_RELEASE", 'false'
}
dataBinding {
enabled true
}
lintOptions {
abortOnError false
}
flavorDimensions "tier1"
productFlavors {
standard {
resValue "string", "app_name", "myapp"
dimension "tier1"
}
beta {
applicationId 'package.beta'
resValue "string", "app_name", "myapp2"
dimension "tier1"
}
}
applicationVariants.all { variant ->
variant.outputs.all { output ->
def project = "myapp"
def separator = "-"
def flavor = variant.productFlavors[0].name
def buildType = variant.variantData.variantConfiguration.buildType.name
def newApkName = project + separator + flavor + separator + buildType + ".apk"
outputFileName = newApkName
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
beta {
aidl.srcDirs = ['src/standard/aidl']
java.srcDirs = ['src/standard/java']
}
}
signingConfigs {
buildTypes {
debug {
buildConfigField "java.util.Date", "buildTime", "new java.util.Date(" + System.currentTimeMillis() + "L)"
}
release {
buildConfigField "java.util.Date", "buildTime", "new java.util.Date(" + System.currentTimeMillis() + "L)"
}
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug_StandardAndBeta
debuggable true
buildConfigField "boolean", "CallLogEnabled", "true"
minifyEnabled false
}
release {
signingConfig signingConfigs.release_StandardAndBeta
debuggable false //set to true for custom debugable release build
buildConfigField "boolean", "CallLogEnabled", "false"
minifyEnabled true //set to false for custom debugable release build
proguardFiles 'proguard.cfg'
}
}
packagingOptions {
exclude 'LICENSE.txt'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
disable "NewApi", "RtlCompat", "MissingPermission", "InvalidPackage", "RecyclerView"
abortOnError false
}
}
repositories {
flatDir {
dirs 'libs'
}
// Crashlytics
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// - Google APIs
implementation('com.google.api-client:google-api-client-android:1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation('com.google.apis:google-api-services-gmail:v1-rev53-1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation 'net.openid:appauth:0.4.1'
implementation 'com.microsoft.graph:msgraph-sdk-android:1.1.+'
implementation 'net.hockeyapp.android:HockeySDK:4.1.1'
// DB framework
implementation 'com.j256.ormlite:ormlite-android:4.48'
// RX Java
implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'io.reactivex:rxjava:1.1.6'
// HTTP frameworks
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.1.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
// Google Adwords Tracking
implementation files('libs/Google/GoogleConversionTrackingSdk-2.2.4.jar')
// GMS
implementation 'com.google.android.gms:play-services-analytics:9.0.2'
implementation 'com.google.android.gms:play-services-gcm:9.0.2'
implementation 'com.google.android.gms:play-services-identity:9.0.2'
implementation 'com.google.android.gms:play-services-ads:9.0.2'
implementation 'com.google.android.gms:play-services-auth:9.0.2'
// Other dependencies
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:preference-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.google.code.gson:gson:2.8.+'
implementation 'com.github.clans:fab:1.6.+'
implementation 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
implementation 'com.caverock:androidsvg:1.2.2-beta-1'
implementation 'de.greenrobot:eventbus:2.4.1'
implementation 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
implementation 'com.facebook.device.yearclass:yearclass:1.0.+'
implementation 'com.facebook.android:facebook-android-sdk:4.15.0'
implementation 'org.parceler:parceler-api:1.1.9'
annotationProcessor 'org.parceler:parceler:1.1.9'
// Android architecture components
implementation "android.arch.lifecycle:extensions:1.0.0"
}
It's because you're using a buildConfigField with System.currentTimeMillis(). This line causes the BuildConfig class to be updated for debug builds:
buildConfigField "java.util.Date", "buildTime", "new java.util.Date(" + System.currentTimeMillis() + "L)"
The Android Gradle Plugin updates the BuildConfig.java everytime you do a build and inserts the current Date, producing a static field similar to this one:
public static final java.util.Date buildTime = new java.util.Date(1518194256644L);
and since the time changes all the time (haha), the file has to be recompiled.
In my case, the problem was that I was appending date to version name.
def static getDate() {
return new Date().format('yyyyMMddHHmmss')
}
buildTypes {
debug {
// REMOVE THIS LINE
versionNameSuffix '-' + getDate()
applicationIdSuffix ".test"
}
The line in question was
versionNameSuffix '-' + getDate()
In case anyone else encounters the same problem.

UnsupportedOperationException The "android" command is no longer included in the SDK

I have project in Kotlin and I have updated Android Studio to 2.3.3 and gradle to 3.3 and build tools to 25.3.1. During building I got this error:
Caused by: java.lang.UnsupportedOperationException: The "android" command is no longer included in the SDK. Any references to it (e.g. by third-party plugins) should be removed.
at com.android.SdkConstants.androidCmdName(SdkConstants.java:1947)
at com.android.SdkConstants$androidCmdName$0.callStatic(Unknown Source)
at com.jakewharton.sdkmanager.internal.AndroidCommand$Real.<init>(AndroidCommand.groovy:21)
at com.jakewharton.sdkmanager.internal.PackageResolver.resolve(PackageResolver.groovy:22)
at com.jakewharton.sdkmanager.internal.PackageResolver$resolve.call(Unknown Source)
at com.jakewharton.sdkmanager.SdkManagerPlugin$_apply_closure2$_closure3.doCall(SdkManagerPlugin.groovy:44)
at com.jakewharton.sdkmanager.SdkManagerPlugin$_apply_closure2$_closure3.doCall(SdkManagerPlugin.groovy)
at com.jakewharton.sdkmanager.SdkManagerPlugin.time(SdkManagerPlugin.groovy:51)
at com.jakewharton.sdkmanager.SdkManagerPlugin$_apply_closure2.doCall(SdkManagerPlugin.groovy:43)
at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)
at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:44)
at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:79)
at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:30)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy16.afterEvaluate(Unknown Source)
at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:82)
... 56 more
Gralde file:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
jcenter()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.github.JakeWharton:sdk-manager-plugin:master'
}
}
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
apply plugin: 'io.fabric'
task increaseBuildStageVersion << {
def versionPropsFileI = file('version.properties')
if (versionPropsFileI.canRead()) {
def Properties versionPropsI = new Properties()
versionPropsI.load(new FileInputStream(versionPropsFileI))
def value = 1
println("INCREASING STAGE VERSION")
def versionBuild = versionPropsI['VERSION_BUILD_STAGE'].toInteger() + value
def codeVersion = versionPropsI['VERSION_CODE_STAGE'].toInteger() + value
versionPropsI['VERSION_BUILD_STAGE'] = versionBuild.toString()
versionPropsI['VERSION_CODE_STAGE'] = codeVersion.toString()
versionPropsI.store(versionPropsFileI.newWriter(), null)
} else {
throw new GradleException("Could not read version.properties!")
}
}
task increaseBuildProductionVersion << {
def versionPropsFileI = file('version.properties')
if (versionPropsFileI.canRead()) {
def Properties versionPropsI = new Properties()
versionPropsI.load(new FileInputStream(versionPropsFileI))
def value = 1
println("INCREASING PRODUCTION VERSION")
def versionBuild = versionPropsI['VERSION_BUILD_PRODUCTION'].toInteger() + value
def codeVersion = versionPropsI['VERSION_CODE_PRODUCTION'].toInteger() + value
versionPropsI['VERSION_BUILD_PRODUCTION'] = versionBuild.toString()
versionPropsI['VERSION_CODE_PRODUCTION'] = codeVersion.toString()
versionPropsI.store(versionPropsFileI.newWriter(), null)
} else {
throw new GradleException("Could not read version.properties!")
}
}
tasks.whenTaskAdded { task ->
if (task.name == 'packageStageRelease') {
task.dependsOn increaseBuildStageVersion
} else if (task.name == 'packageProductionRelease') {
task.dependsOn increaseBuildProductionVersion
}
}
android {
signingConfigs {
release {
.....
}
}
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.fivedottwelve.bonusapp"
minSdkVersion 19
targetSdkVersion 25
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
signingConfig signingConfigs.release
def gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
def buildTime = new GregorianCalendar().format("dd-MM-yyyy' 'h:mm:ss a Z")
buildConfigField "String", "GIT_SHA", "\"{$gitSha}\""
buildConfigField "String", "BUILD_TIME", "\"{$buildTime}\""
}
debug {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable true
buildConfigField "String", "GIT_SHA", "\"DEBUG\""
buildConfigField "String", "BUILD_TIME", "\"BUILD_TIME\""
}
}
productFlavors {
development {
versionName "1.0." + getStageVersionName() + "-stage"
versionCode getStageVersionCode()
applicationIdSuffix ".stage"
resValue "string", "app_name", "BonusApp"
buildConfigField('String', 'API_URL', "\"https://fivedottwelve.com/\"")
}
stage {
versionName "1.0." + getStageVersionName() + "-stage"
versionCode getStageVersionCode()
applicationIdSuffix ".stage"
resValue "string", "app_name", "BonusApp"
buildConfigField('String', 'API_URL', "\"https://fivedottwelve.com/\"")
}
production {
versionName "1.0." + getProdVersionName()
versionCode getProdVersionCode()
resValue "string", "app_name", "BonusApp"
buildConfigField('String', 'API_URL', "\"https://fivedottwelve.com/\"")
}
}
dexOptions {
preDexLibraries true
maxProcessCount 6
javaMaxHeapSize "3g"
}
testOptions {
unitTests.all {
// All the usual Gradle options.
testLogging {
jvmArgs '-XX:MaxPermSize=256m'
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen { false }
showStandardStreams = true
}
}
}
lintOptions {
disable 'InvalidPackage', 'ContentDescription'
abortOnError false
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
packagingOptions {
exclude 'main/AndroidManifest.xml'
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
exclude 'LICENSE.txt'
exclude 'LICENSE'
}
}
kapt {
generateStubs = true
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile 'com.github.salomonbrys.kotson:kotson:2.5.0'
compile "com.android.support:support-v4:$rootProject.ext.android_support_version"
compile "com.android.support:appcompat-v7:$rootProject.ext.android_support_version"
compile "com.android.support:design:$rootProject.ext.android_support_version"
compile "com.android.support:recyclerview-v7:$rootProject.ext.android_support_version"
compile "com.android.support:cardview-v7:$rootProject.ext.android_support_version"
compile 'com.android.support:multidex:1.0.1'
compile "com.google.android.gms:play-services-base:$rootProject.ext.play_service_version"
compile "com.google.android.gms:play-services-gcm:$rootProject.ext.play_service_version"
kapt "com.google.dagger:dagger-compiler:$rootProject.ext.Dagger_version"
compile "com.google.dagger:dagger:$rootProject.ext.Dagger_version"
compile "io.reactivex:rxjava:$rootProject.ext.RxJava_version"
compile "io.reactivex:rxandroid:$rootProject.ext.RxAndroid_version"
provided 'javax.annotation:jsr250-api:1.0'
compile "com.squareup.okhttp3:okhttp:$rootProject.ext.retrofit_http_version"
compile "com.squareup.okhttp3:okhttp-urlconnection:$rootProject.ext.retrofit_http_version"
compile "com.squareup.okhttp3:logging-interceptor:$rootProject.ext.retrofit_http_version"
compile "com.squareup.retrofit2:retrofit:$rootProject.ext.retorfit_version"
compile "com.squareup.retrofit2:converter-gson:$rootProject.ext.retorfit_version"
compile "com.squareup.retrofit2:adapter-rxjava:$rootProject.ext.retorfit_version"
compile 'com.facebook.android:facebook-android-sdk:4.20.0'
compile 'me.relex:circleindicator:1.2.1#aar'
//glide
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0#aar'
//transitions
compile "com.andkulikov:transitionseverywhere:1.7.0"
//beacons
compile "com.kontaktio:sdk:$rootProject.ext.kontakt_io"
compile('com.crashlytics.sdk.android:crashlytics:2.6.7#aar') {
transitive = true;
}
}
repositories {
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' }
maven { url 'http://maven.livotovlabs.pro/content/groups/public' }
maven { url 'https://maven.fabric.io/public' }
}
/*
Resolves dependency versions across test and production APKs, specifically, transitive
dependencies. This is required since Espresso internally has a dependency on support-annotations.
*/
configurations.all {
resolutionStrategy.force "com.android.support:support-annotations:$rootProject.ext.android_support_version"
}
/*
All direct/transitive dependencies shared between your test and production APKs need to be
excluded from the test APK! This is necessary because both APKs will contain the same classes. Not
excluding these dependencies from your test configuration will result in an dex pre-verifier error
at runtime. More info in this tools bug: (https://code.google.com/p/android/issues/detail?id=192497)
*/
configurations.compile.dependencies.each { compileDependency ->
println "Excluding compile dependency: ${compileDependency.getName()}"
configurations.androidTestCompile.dependencies.each { androidTestCompileDependency ->
configurations.androidTestCompile.exclude module: "${compileDependency.getName()}"
}
}
I removed apply plugin: 'android-sdk-manager' and it works

different flavors in android

I want to create smth like this in my project, but i'm new to gradle, so i don't know a lot of things it can do.
Here is project structure in explorer
gradle.build from app module
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7'
}
}
// Manifest version information!
def versionMajor = 1
def versionMinor = 0
def versionPatch = 0
def versionBuild = 0 // bump for dogfood builds, public betas, etc.
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
def gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
def date = new Date()
def buildTime = date.format("dd.MM.yy", TimeZone.getTimeZone("UTC"))
def buildTimeInternal = date.format("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC"))
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
buildConfigField "String", "GIT_SHA", "\"${gitSha}\""
buildConfigField "String", "BUILD_TIME", "\"${buildTimeInternal}\""
testApplicationId "ru.ltst.u2020mvp.tests"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
debug {
storeFile file("../distribution/debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
release {
storeFile file("../distribution/debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
buildTypes {
debug {
applicationIdSuffix '.dev'
versionNameSuffix '-dev'
debuggable true
signingConfig signingConfigs.debug
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard-project.txt')
signingConfig signingConfigs.release
}
}
productFlavors {
internal {
applicationId 'ru.ltst.u2020mvp.internal'
}
production {
applicationId 'ru.ltst.u2020mvp'
}
}
lintOptions {
textReport true
textOutput 'stdout'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'LICENSE.txt'
}
}
// TODO remove eventually: http://b.android.com/162285
configurations {
internalDebugCompile
}
dependencies {
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:support-annotations:23.0.1'
compile "com.android.support:appcompat-v7:23.0.1"
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.google.dagger:dagger:2.0.1'
apt 'com.google.dagger:dagger-compiler:2.0'
provided 'org.glassfish:javax.annotation:10.0-b28'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
internalDebugCompile 'com.squareup.retrofit:retrofit-mock:1.9.0'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.jakewharton.timber:timber:2.7.1'
internalDebugCompile 'com.jakewharton.madge:madge:1.1.1'
internalDebugCompile 'com.jakewharton.scalpel:scalpel:1.1.1'
compile 'io.reactivex:rxjava:1.0.8'
compile 'io.reactivex:rxandroid:0.24.0'
internalCompile 'com.mattprecious.telescope:telescope:1.4.0#aar'
// Espresso 2 Dependencies
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.0') {
exclude module: 'support-annotations'
}
}
// change apk name
android.applicationVariants.all { variant ->
for (output in variant.outputs) {
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = "u2020-mvp-${output.name}-${buildTime}.apk"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
// print build finish time
gradle.buildFinished { buildResult ->
def buildFinishDate = new Date()
def formattedDate = buildFinishDate.format('yyyy-MM-dd HH:mm:ss')
println "Build finished: ${formattedDate}"
}
Can someone explain to me how it works?
When i change build Variant the java content is changed. (e.g it was main, internal,internalDebug for internalDebug variant and then it became main,internal,internalRelease for internalRelease build variants).
The reason I'm asking is that i don't see any "internalRelease" word in gradle file, so i don't understand the logic of how the build variants were created and how it defines what modules to show for different build variants
debug for test without signature and release for publish with signature;click the left-top robot ,and turn android to project , u will understand;

Categories

Resources