Migration to androidx.databinding on AndroidStudio 3.0 - data-binding

I'd like to ask if it's possible to migrate to androidx.databinding in AndroidStudio 3.0.
I don't want to upgrade to AndroidStudio 3.2 just yet, and it seems that I can only import android.databinding instead of the androidx version.
I have added this in my app gradle file:
kapt "androidx.databinding:databinding-compiler:3.2.0-alpha16"
Project gradle dependency:
classpath 'com.android.tools.build:gradle:3.1.0'
All the other androidx libraries I added on gradle can be imported in code, but not databinding. Has anyone here still using AndroidStudio 3.0 successfully used androidx.databinding?
Thanks.
UPDATE:
In the app build.gradle, I updated the dependency from -jre8 to -jdk8:
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
This is the app build.gradle dependencies:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.appcompat:appcompat:$rootProject.supportLibVersion"
implementation "com.google.android.material:material:$rootProject.supportLibVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'
kapt 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
// architecture components
implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.archLifecycleVersion"
implementation "androidx.lifecycle:lifecycle-runtime:$rootProject.archLifecycleVersion"
implementation "androidx.room:room-runtime:$rootProject.roomVersion"
implementation "androidx.paging:paging-runtime:$rootProject.pagingVersion"
kapt "androidx.lifecycle:lifecycle-compiler:$rootProject.archLifecycleVersion"
kapt "androidx.room:room-compiler:$rootProject.roomVersion"
kapt "androidx.databinding:databinding-compiler:3.2.1"
testImplementation 'junit:junit:4.12'
}
configurations {
all {
exclude group: 'com.android.support'
exclude module: 'httpclient'
exclude module: 'commons-logging'
}
}
And this is the project build.gradle versions:
ext {
archLifecycleVersion = '2.0.0'
roomVersion = '2.1.0-alpha02'
pagingVersion = '2.1.0-beta01'
supportLibVersion = '1.0.0'
}
I executed this to find out more about the issue on my project:
./gradlew :app:kaptDebugKotlin
and I got this error:
e: error: cannot access NonNull
class file for android.support.annotation.NonNull not found
Consult the following stack trace for details.
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for android.support.annotation.NonNull not found
e: [kapt] An exception occurred: java.lang.UnsatisfiedLinkError: org.sqlite.core.NativeDB._open_utf8([BI)V
at org.sqlite.core.NativeDB._open_utf8(Native Method)
at org.sqlite.core.NativeDB._open(NativeDB.java:71)
at org.sqlite.core.DB.open(DB.java:174)
at org.sqlite.core.CoreConnection.open(CoreConnection.java:220)
at org.sqlite.core.CoreConnection.<init>(CoreConnection.java:76)
at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:25)
at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:24)
at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:45)
at org.sqlite.JDBC.createConnection(JDBC.java:114)
at androidx.room.verifier.DatabaseVerifier$Companion.create(DatabaseVerifier.kt:81)
So it seems that the underlying sqlite library is still using android.support.annotation.NonNull. Any idea on how to solve this?
Thanks.

Related

ERROR: Failed to resolve: com.google.android.material:material-rc01: Affected Modules: app

After adding 'com.google.android.material:material-rc01' in place of com.android.support:design as per documentation, studio failed to detect the dependency.
Then I downgrade the version of dependency to
implementation 'com.google.android.material:material:1.1.0-alpha09'
and it works.
But why this problem arises? any explanation?
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-
jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material-rc01'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso core:3.2.0'
}
ERROR: Failed to resolve: com.google.android.material:material-rc01:
Affected Modules: app
The error arises due to the fact that you're not specifying a version for the implementation; the program needs the following:
The group
The name of the dependency to implement
Version of the dependency
All this is covered in more detail here
When I got this error message, I solved it with the below line:
implementation 'com.google.android.material:material:1.0.0-rc01'
As you can see, the line above follows the implement 'compileGroup:name:version' pattern from the list, which in this case is 1.0.0-rc01; -rc01 seems to be a name for the version, just like -alpha09.
Note as well that you are not downgrading as you say if you didn't specify a version previously, which is why your app couldn't build.
I just had the same issue. I solved it by using the following dependency:
implementation "com.google.android.material:material:1.0.0"
To solve such issues you always can check if the lib you are looking for does really exists in Google's Maven repo: https://dl.google.com/dl/android/maven2/index.html
Hope that help, cheers!

E/FirebaseInstanceId: Token retrieval failed: AUTHENTICATION_FAILED Firebase

I've tried many solutions but none of them seem to work. I'm trying to setup firebase with my android project but I keep getting an error which states E/FirebaseInstanceId: Token retrieval failed: AUTHENTICATION_FAILED. Note: Google-services.json is installed into my app directory.
App:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-core:16.0.1'
}
apply plugin: 'com.google.gms.google-services'
My App:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}

Failed to capture fingerprint of input files for task ':app:preDebugBuild' property 'compileManifests' during up-to-date check

I'm setting firebase on my project and when I add inappmessaging-display lib this error appears:
Dependency resolved to an incompatible version:
Dependency(fromArtifactVersion=ArtifactVersion(groupId=com.google.firebase,
artifactId=firebase-messaging, version=17.3.2),
toArtifact=Artifact(groupId=com.google.firebase,
artifactId=firebase-iid), toArtifactVersionString=[17.0.2]) FAILURE:
Build failed with an exception.
What went wrong: Failed to capture fingerprint of input files for task ':app:preDebugBuild' property 'compileManifests' during
up-to-date check. In project 'app' a resolved Google Play services
library dependency depends on another at an exact version (e.g.
"[17.0. 2]", but isn't being resolved to that version. Behavior
exhibited by the library will be unknown.
Dependency failing: com.google.firebase:firebase-messaging:17.3.2 -> com.google.firebase:firebase-iid#[17.0.2], but fire base-iid version was 17.0.3.
The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art ifact
with the issue. -- Project 'app' depends onto
com.google.firebase:firebase-iid#17.0.3 -- Project 'app' depends
onto com.google.firebase:firebase-messaging#17.3.2 -- Project 'app'
depends onto com.google.firebase:firebase-ads#17.1.2 -- Project
'app' depends onto
com.google.firebase:firebase-inappmessaging-display#17.0.4 --
Project 'app' depends onto
com.google.firebase:firebase-analytics#16.0.6 -- Project 'app'
depends onto com.google.firebase:firebase-analytics-impl#16.2.4 --
Project 'app' depends onto
com.google.firebase:firebase-inappmessaging#17.0.4 -- Project 'app'
depends onto com.google.firebase:firebase-core#16.0.6 -- Project
'app' depends onto
com.google.firebase:firebase-measurement-connector-impl#17.0.4 --
Project 'app' depends onto com.google.firebase:firebase-config#16.1.3
-- Project 'app' depends onto com.google.firebase:firebase-crash#16.2.1 -- Project 'app' depends
onto com.google.firebase:firebase-abt#16.0.1 -- Project 'app'
depends onto com.google.firebase:firebase-perf#16.2.3 -- Project
'app' depends onto
com.google.android.gms:play-services-measurement-api#16.0.4
For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep endency
paths to the artifact. This error message came from the
google-services Gradle plugin, report issues at https://
github.com/google/play-services-plugins and disable by adding
"googleServices { disableVersionCheck = false }" to your build.gradle
file.
project file
buildscript {
ext.kotlin_version = '1.3.11'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.2.0'
classpath ('com.google.firebase:firebase-plugins:1.1.5')
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
plugins {
id 'com.gradle.build-scan' version '1.16'
}
ext {
support_library_version = '28.0.0' //use the version of choice
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
buildScan {
licenseAgreementUrl = 'https://gradle.com/terms-of-service'
licenseAgree = 'yes'
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.myapp.pocapp"
minSdkVersion 25
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:animated-vector-drawable:$support_library_version"
implementation "com.android.support:exifinterface:$support_library_version"
implementation "com.android.support:cardview-v7:$support_library_version"
implementation "com.android.support:customtabs:$support_library_version"
implementation "com.android.support:support-media-compat:$support_library_version"
implementation "com.android.support:support-v4:$support_library_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.android.support:appcompat-v7:$support_library_version"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
//Play services dependencies
implementation('com.google.android.gms:play-services-plus:15.0.1')
implementation('com.google.android.gms:play-services-gcm:15.0.1')
implementation('com.google.android.gms:play-services-maps:15.0.1')
implementation('com.google.android.gms:play-services-ads:15.0.1')
implementation('com.google.android.gms:play-services-location:15.0.1')
implementation('com.google.android.gms:play-services-analytics:16.0.3')
implementation('com.google.android.gms:play-services-basement:15.0.1')
implementation('com.google.android.gms:play-services-auth:16.0.0')
implementation('com.google.android.gms:play-services-drive:15.0.1')
//General google dependencies
implementation('com.android.installreferrer:installreferrer:1.0')
implementation('com.android.billingclient:billing:1.2')
//Firebase dependencies
implementation('com.google.firebase:firebase-core:16.0.6')
implementation('com.google.firebase:firebase-perf:16.2.3')
implementation('com.google.firebase:firebase-ads:17.1.2')
implementation('com.google.firebase:firebase-crash:16.2.1')
implementation('com.google.firebase:firebase-config:16.1.3')
implementation('com.google.firebase:firebase-messaging:17.3.2')
implementation('com.google.firebase:firebase-inappmessaging:17.0.4')
implementation('com.google.firebase:firebase-inappmessaging-display:17.0.4')
}
apply plugin: 'com.google.gms.google-services'
I already updated all libs to latest versions.
I am also facing same issue,
At finally got a Solution.
Please remove Cordova-plugin-firebase and
Use the latest major releases just by running: cordova plugin add cordova-plugin-firebase-lib
Simply follow the following link: https://www.npmjs.com/package/cordova-plugin-firebase-lib
Check your internet connection.
If you are connected,try to use a proxy server (using hotspot shield,PSiphone, etc.)
The problem was on firebase libs versions, Just update every lib to fix this.
cd android
./gradlew clean
try this

Firebase Failed to resolve: firebase-messaging-15.0.0 (Previous solutions disconnect Firebase Connection)

I have been trying to set up Firebase Cloud Messaging on an app. Everything runs ok until I add FCM dependencies to the app. I immediately get this error:
Failed to resolve: firebase-messaging-15.0.0
Open File
Here are the dependencies;
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-core:16.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-messaging:17.0.0:15.0.0'
}
apply plugin: 'com.google.gms.google-services'
I have been reading answers like this all day and the only solution that works involves deleting everything from ": - 0" in the last line of the code.
The problem is that it immediately removes the connection to FCM. New to android programming, so forgive any obvious oversight. Thanks
This happens because the version of the dependencies conflict. You can remove one of the version and select the preferred one. In this case your
implementation 'com.google.firebase:firebase-messaging:17.0.0:15.0.0'
seems to have double version. You should choose whether to use 17.0.0 or 15.0.0 one.
The detail can be found in this video
https://youtu.be/NN_Ch5qzFWQ
cheers !

retrofit 2.0 xml simplexml converter issue while having retrolambda in gradle file

Here is my gradle file
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.demo.sample"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
//Retrofit
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
//Retrofit support libraries
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
//compile 'com.squareup.retrofit2:converter-simplexml:2.0.0-beta4'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0-beta4'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
//RxAndroid
compile 'io.reactivex:rxandroid:1.1.0'
//Explicit support for latest RxJava
compile 'io.reactivex:rxjava:1.1.0'
//Square dagger
provided 'com.squareup.dagger:dagger-compiler:1.2.2'
compile 'com.squareup.dagger:dagger:1.2.2'
//Butterknife
compile 'com.jakewharton:butterknife:6.1.0'
//Picasso
compile 'com.squareup.picasso:picasso:2.3.3'
//Testing dependency
testCompile 'junit:junit:4.12'
testCompile 'org.assertj:assertj-core:2.1.0'
testCompile 'org.mockito:mockito-core:2.0.23-beta'
}
If i un-comment line compile 'com.squareup.retrofit2:converter-simplexml:2.0.0-beta4' android studio throws nasty error at compile time
:app:transformClassesWithDexForDebug
trouble processing "javax/xml/XMLConstants.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
This is often due to inadvertently including a core library file
in your application's project, when using an IDE (such as
Eclipse). If you are sure you're not intentionally defining a
core class, then this is the most likely explanation of what's
going on.
However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.
If you really intend to build a core library -- which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application -- then use
the "--core-library" option to suppress this error message.
If you go ahead and use "--core-library" but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.
If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.
1 error; aborting
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_74.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
I'm not understanding what the error actually means. Also, is there a way to get around this problem.
Seem like Simple XML has transitive dependencies which are already included in Android. See https://github.com/square/retrofit/issues/1536.
We need to exclude three dependencies: stax:stax-api, stax:stax, and xpp3:xpp3.
I managed to achieve this by using this compile statement in gradle
compile ('com.squareup.retrofit2:converter-simplexml:2.0.0-beta4'){
exclude module: 'stax-api'
exclude module: 'stax'
exclude module: 'xpp3'
}

Resources