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.
Related
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 project with this build setting :
Project have separate debug variant
applicationIdSuffix '.debug'
versionNameSuffix '-DEBUG'
On the time of release, there are showing many build variants.
But I'm a beginner developer, so need to sure from you guys, which one is debug build variant that one I need to release?
Then what will do the other build variants?
And this project includes many modules ( like 3rd Party Sample Project )
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
//noinspection GradleDynamicVersion
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-perf'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven {
url 'some url/'
credentials {
username 'someusername'
password 'somepassword'
}
}
}
// for Crashlytics
apply plugin: 'io.fabric'
// Create a variable called keystorePropertiesFile, and initialize it to your
// keystore.properties file, in the rootProject folder.
def keystorePropertiesFile = rootProject.file("keystore.properties")
// Initialize a new Properties() object called keystoreProperties.
def keystoreProperties = new Properties()
// Load your keystore.properties file into the keystoreProperties object.
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
// applicationVariants.all { variant ->
// //(variant.buildType.name == 'release') {
// variant.mergeAssetsProvider.configure {
// doLast {
// delete(fileTree(dir: outputDir, includes: ['**/*.pdf'])) // '**/js',
// }
// }
// //}
// }
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
lintOptions {
checkReleaseBuilds true
abortOnError true
//warningsAsErrors true
baseline file("lint-baseline.xml")
fatal 'StopShip'
}
compileSdkVersion 28
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.application.sanchyan"
versionName "3.1.8.4"
versionCode 18
targetSdkVersion 28
vectorDrawables.useSupportLibrary = true
renderscriptSupportModeEnabled true
renderscriptTargetApi 19
multiDexEnabled true
}
buildTypes {
debug {
applicationIdSuffix '.debug'
versionNameSuffix '-DEBUG'
//minifyEnabled true
// By using a special debug ProGuard file, you can turn off obfuscation, which would
// otherwise hinder debugging.
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro',
'proguard-rules-debug.pro'
}
release {
minifyEnabled true
//shrinkResources true
signingConfig signingConfigs.release
//multiDexKeepFile file('multidex-config.txt')
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ext.enableCrashlytics = true
//
// IMPORTANT PART:
//
// tell your MultiDex to keep the classes you defined in your Proguard .pro file.
//multiDexKeepProguard file('proguard-rules.pro')
}
}
flavorDimensions "region", "mode", "api"
productFlavors {
// Read these to understand the whole concept better:
// li
// https://proandroiddev.com/advanced-android-flavors-part-1-building-white-label-apps-on-android-ade16af23bcf
// API
pre21 {
dimension "api"
minSdkVersion 19
versionNameSuffix ""
}
post21 {
dimension "api"
minSdkVersion 21
versionNameSuffix ""
}
// MODE
full {
dimension "mode"
}
demo {
dimension "mode"
applicationIdSuffix '.demo'
versionNameSuffix " [Demo]"
}
internal {
dimension "mode"
applicationIdSuffix '.internal'
versionNameSuffix " [Internal]"
}
// REGION
brigon {
dimension "region"
applicationIdSuffix '.brigon'
}
uei {
dimension "region"
applicationIdSuffix '.uei'
}
uk {
dimension "region"
versionNameSuffix ""
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation project(':polygonview')
implementation project(':tabbuttonview')
implementation project(':imagetoggleview')
implementation project(':wedgeview')
implementation project(':panzoomview')
implementation project(':flowlayout')
implementation project(':infoview')
implementation project(path: ':utilities')
implementation 'androidx.appcompat:appcompat:1.1.0' // 1.1.0-rc01
/* beta2 causes issues with layouts not showing content till updating (eg DevicePicker) */
//noinspection GradleDependency
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta3' // 2.0.0-beta1
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'cn.aigestudio.wheelpicker:WheelPicker:1.1.2'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.material:material:1.2.0-alpha02' // 1.1.0-alpha09
implementation 'com.google.firebase:firebase-core:17.2.1' // 17.0.0
implementation 'com.google.firebase:firebase-messaging:20.0.1'
implementation 'com.google.firebase:firebase-perf:19.0.2'
implementation 'com.google.maps.android:android-maps-utils:0.6.2'
implementation 'com.pacioianu.david:ink-page-indicator:1.3.0'
implementation 'com.squareup.moshi:moshi:1.9.2'
//noinspection GradleDependency
pre21Implementation 'com.squareup.okhttp3:okhttp:3.14.4'
post21Implementation 'com.squareup.okhttp3:okhttp:4.2.2'
//implementation 'com.squareup.okhttp3:okhttp:3.14.4'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'org.apache.commons:commons-text:1.8'
// for Crashlytics
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.crashlytics.sdk.android:answers:1.4.7'
// for PSPDFKit
implementation 'com.pspdfkit:pspdfkit:6.0.3'
implementation 'androidx.palette:palette:1.0.0'
// for Chrome web content
implementation 'com.android.support:customtabs:28.0.0'
// for image cropping
// implementation 'com.github.yalantis:ucrop:2.2.4-native'
implementation 'com.github.yalantis:ucrop:2.2.4'
// implementation 'com.androidplot:androidplot-core:0.9.4'
// Room components
// implementation "android.arch.persistence.room:runtime:$rootProject.roomVersion"
// annotationProcessor "android.arch.persistence.room:compiler:$rootProject.roomVersion"
// androidTestImplementation "android.arch.persistence.room:testing:$rootProject.roomVersion"
// Lifecycle components
implementation "android.arch.lifecycle:extensions:$rootProject.archLifecycleVersion"
//annotationProcessor "android.arch.lifecycle:compiler:$rootProject.archLifecycleVersion"
implementation "android.arch.lifecycle:common-java8:1.1.1"
testImplementation 'junit:junit:4.13-rc-2'
testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.1'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
//noinspection GradlePath
implementation files('C:/Users/Dell/Documents/ProjectFilePath/libs/YouTubeAndroidPlayerApi.jar')
}
apply plugin: 'com.google.gms.google-services'
And the error shows on release build time is
Missing org.conscrypt.ConscryptHostnameVerifer
I don't know how much future error will come to release.
Please help me out
read this topic
And this one
While reading the info message, it gives me an idea about this Conscrypt and did a research and found out that I need to install conscrypt to my gradle.app
implementation 'org.conscrypt:conscrypt-android:2.2.1'
and it works.
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
I have some troubles compiling my project with Gradle 3. When I update my project to use this version of Gradle, the gradle sync is okay, but as soon as I hit the run button, it gives me this:
Error:Execution failed for task
':app:compileBetaGoogleWebkitDebuggableReleaseJavaWithJavac'.
> java.lang.NoClassDefFoundError: com/fyber/annotations/FyberSDK
With older gradle (2.3.3) it works just perfect, but I need to update the project, for undisclosable, professional reason. What can go wrong between those two gradle versions, that one sees the FyberSDK and the other does not?
Here is my gradle script
apply plugin: 'com.android.application'
def mVersionCode = 16;
def mVersionName = "1.16"
android {
signingConfigs {
releaseSigning {
keyAlias 'redacted'
keyPassword 'redacted'
storeFile file('redacted')
storePassword 'redacted'
}
}
compileSdkVersion 23
defaultConfig {
applicationId "redacted"
minSdkVersion 19
targetSdkVersion 23
versionCode mVersionCode
versionName mVersionName
resValue "string", "app_version_name", mVersionName
resValue "string", "app_name", "redacted"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.releaseSigning
}
debuggableRelease {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.releaseSigning
}
}
flavorDimensions "server", "lib"
productFlavors {
pubGoogle {
dimension "server"
minSdkVersion 19
buildConfigField("boolean", "isGoogleBuild", "true")
}
betaGoogle {
dimension "server"
minSdkVersion 14
resValue "string", "app_version_name", mVersionName + "beta"
resValue "string", "app_name", "redacted Beta"
buildConfigField("boolean", "isGoogleBuild", "true")
}
pubAmazon {
dimension "server"
minSdkVersion 19
buildConfigField("boolean", "isGoogleBuild", "false")
}
betaAmazon {
dimension "server"
minSdkVersion 14
resValue "string", "app_version_name", mVersionName + "beta"
resValue "string", "app_name", "redacted Beta"
buildConfigField("boolean", "isGoogleBuild", "false")
}
/*xwalk {
dimension "lib"
}*/
webkit {
dimension "lib"
}
}
}
repositories {
mavenCentral()
maven {
name "Fyber's maven repo"
url "https://fyber.bintray.com/maven"
}
}
configurations {
provided
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.firebase:firebase-messaging:11.0.1'
compile 'com.sponsorpay:sponsorpay-android-sdk:7.2.8'
compile 'com.fyber:fyber-sdk:8.17.0'
// Fyber Annotations
provided 'com.fyber:fyber-annotations:1.3.0'
annotationProcessor 'com.fyber:fyber-annotations-compiler:1.4.0'
// Fyber mediation services
// UnityAds Mediation
compile 'com.fyber.mediation:unityads:2.1.1-r1#aar'
// ChartBoost Mediation
compile 'com.fyber.mediation:chartboost:6.6.3-r2#aar'
// Vungle Mediation
compile 'com.fyber.mediation:vungle:5.3.0-r1#aar'
// Vungle third-party dependencies
compile 'com.google.dagger:dagger:2.7'
compile 'javax.inject:javax.inject:1'
compile 'de.greenrobot:eventbus:2.2.1'
compile 'io.reactivex:rxjava:1.2.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.squareup.okio:okio:1.11.0'
compile 'com.google.android.gms:play-services-basement:11.0.1'
compile 'com.google.android.gms:play-services-location:11.0.1'
// For AppsFlyer
compile 'com.appsflyer:af-android-sdk:4.6.0#aar'
compile 'com.google.android.gms:play-services-ads:11.0.1'
compile 'com.google.android.gms:play-services-gcm:11.0.1'
compile 'com.google.android.gms:play-services-auth:11.0.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
//xwalkCompile 'org.xwalk:xwalk_core_library:23.53.589.4'
}
apply plugin: 'com.google.gms.google-services'
I also encountered this problem, eventually solved the problem.
you maybe use a annotations like this:
#FyberSDK
all you need to is find this annotations ,and change it's build.gradle file with this:
apply plugin: 'com.android.library'
android {
// ...
// add this code to enable annotationProcessor
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath = true
}
}
}
dependencies {
// ...
// Fyber Annotations
compileOnly 'com.fyber:fyber-annotations:1.3.0'
annotationProcessor 'com.fyber:fyber-annotations-compiler:1.4.0'
// ...
}
try this code ,and sync your project.hope is work fine, it's work fine for me.
if you want learn more for detail, you can read my blog here:
https://segmentfault.com/a/1190000012245056
As per this answer and this answer I already make changes in app gradle but still it is showing me following error while building my application.
Error:android-apt plugin is incompatible with the Android Gradle plugin. Please use 'annotationProcessor' configuration instead.
What am I missing here?
Here is my App Gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'
//project.ext.versionInfo.releaseVersionName = SYNCED_VERSION_NAME
android {
compileSdkVersion 23
flavorDimensions "default"
defaultConfig {
applicationId "in.something"
minSdkVersion 15
targetSdkVersion 23
versionCode 13
versionName "1.10"
multiDexEnabled true
}
productFlavors {
LIVE_BETA {
applicationIdSuffix ".beta"
resValue "string", "app_display_name", "Something(B)"
resValue "string", "SERVER_URL", "http://something/beta"
}
LIVE {
resValue "string", "app_display_name", "something"
resValue "string", "SERVER_URL", "http://something/live"
}
DEV {
applicationIdSuffix ".dev"
resValue "string", "app_display_name", "something(D)"
resValue "string", "SERVER_URL", "http://localhost/"
}
}
buildTypes {
debug {
// applicationIdSuffix "
// .debug"
// versionNameSuffix "-debug"
}
release {
//minifyEnabled true
//shrinkResources true
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
// Rename APK files
// applicationVariants.all { variant ->
// def output = variant.outputs.get(0)
// File apk = output.outputFile
// String newName = output.outputFile.name.replace(".apk", "-${variant.mergedFlavor.versionCode}-${variant.mergedFlavor.versionName}-.apk")
// .replace("app-", "${variant.mergedFlavor.applicationId}-")
// output.outputFile = new File(apk.parentFile, newName)
// }
}
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
//================== Local ========================/
implementation fileTree(include: ['*.jar'], dir: 'libs')
//compile files('libs/ksoap2-android-assembly-3.1.1-jar-with-dependencies.jar')
/** *************************************************/
//================== Default ========================/
implementation 'com.android.support:appcompat-v7:23.1.0'
implementation 'com.android.support:recyclerview-v7:23.1.0'
implementation 'com.android.support:design:23.1.0'
implementation 'com.android.support:cardview-v7:23.1.0'
/** *************************************************/
implementation 'com.fasterxml.jackson.core:jackson-databind:2.6.3'
implementation 'com.fasterxml.jackson.core:jackson-core:2.6.3'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.6.3'
//implementation files('libs/bouncycastle-java5-136-1.0.0.jar')
implementation 'com.joanzapata.iconify:android-iconify-fontawesome:2.1.1'
/************ Location *****************/
implementation 'com.google.android.gms:play-services-location:8.3.0'
/** *************************************************/
/************ Common *****************/
implementation 'commons-io:commons-io:2.4'
implementation 'commons-codec:commons-codec:1.4'
/** ********************************/
implementation('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
implementation files('libs/bouncycastle-java5-136-1.0.0.jar')
}
I am using Android Studio 3.0 and gradle version is 3.0
And add below your
classpath 'io.fabric.tools:gradle:1.+'
definition
classpath "io.realm:realm-gradle-plugin:4.1.1"
For me it looks like it was upgrading Realm from
classpath "io.realm:realm-gradle-plugin:1.0.0"
to
classpath "io.realm:realm-gradle-plugin:4.1.1"