I am using android's data binding library for views in a library project
i have added the following line in my root gradle file
classpath 'com.android.databinding:dataBinder:1.0-rc1'
and have enabled the dataBinding as given below in module's gradle file
apply plugin: 'com.android.databinding'
...
...
android {
....
dataBinding {
enabled = true
}
}
i have enabled the multiDex in my library project
as well as in the host app which is using this library
but i get this stack trace of error while launching the library's activity
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/databinding/DataBinderMapper;
at android.databinding.DataBindingUtil.<clinit>(DataBindingUtil.java:31)
at sdk.ui.activities.MyActivity.onCreate(MyActivity.java:76)
at android.app.Activity.performCreate(Activity.java:6280)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1116)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2534)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2647)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1502)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5763)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.databinding.DataBinderMapper" on path: DexPathList[[zip file "/data/app/testApp.dev-1/base.apk"],nativeLibraryDirectories=[/data/app/testApp.dev-1/lib/arm64, /data/app/testApp.dev-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.databinding.DataBindingUtil.<clinit>(DataBindingUtil.java:31)
at sdk.ui.activities.MyActivity.onCreate(MyActivity.java:76)
at android.app.Activity.performCreate(Activity.java:6280)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1116)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2534)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2647)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1502)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5763)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749)
Suppressed: java.lang.ClassNotFoundException: android.databinding.DataBinderMapper
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 15 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
Make sure that ALL your modules that use DataBinding have it enabled. This was the reason I got that exception.
android {
....
dataBinding {
enabled = true
}
}
finally i was able to solve this issue.
It seems there was a conflict between apt version of the app and library modules.
upgraded the apt version in the app to
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
Besides adding the following to build.gradle:
android {
dataBinding {
enabled = true
}
}
I also have to add the following dependency:
dependencies {
kapt 'com.android.databinding:compiler:3.1.4'
}
Best guess. Get rid of android-apt
And if there are libraries using apt
Instead of apt 'lt.mdm.sdd:myLib:1.5.1' use
annotationProcessor 'lt.mdm.sdd:myLib:1.5.1'.
I'm not sure if this will help you, and i have no idea if library it self should be changed.
It helped me (i was using androidannotations.org older version with apt) at least.
Update
And i have no idea why you apply plugin: 'com.android.databinding'? It works without it as well.
I had the same problem after performing the migration androdx. I tried all the above methods but not resolved. I suddenly found that I used
com.android.tools.build:gradle version is 3.3. I update it to 3.5. Problem is solved.
project build.gradle:
classpath 'com.android.tools.build:gradle:3.3.0'
Update to
classpath 'com.android.tools.build:gradle:3.5.0'
Redo the migration.
classpath 'com.android.databinding:dataBinder:1.0-rc1'
apply plugin: 'com.android.databinding'
Remove that lib. from gradle.
I had the same problem, but I solved it removing
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
from the global build.gradle and removing
apply plugin: 'android-apt'
from the local build.gradle, then it worked like a charm.
It seems it was a mixed problem with Butterknife too. Pretty weird.
The new way of adding DataBinding is by adding on the build.gradle of all your modules:
android {
...
buildFeatures {
dataBinding true
}
}
Don't forget to add also the kotlin-kapt plugin at the top:
plugins {
...
id 'kotlin-kapt'
}
Get inspiration from #Bolein95 say.Because it depend on a library that does not support androidx(no setting databinding=true),Written by a colleague who has left.I copy a few necessary files from his github repo, it work!
Related
Project-level build.gradle
buildscript {
addRepos(repositories)
dependencies {
classpath 'com.google.gms:google-services:4.3.5'
// Crashlytic
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.6.0'
}
}
App-level build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
dependencies {
// Crashlytic
implementation 'com.google.firebase:firebase-crashlytics:18.0.0'
}
With gradle 4.3.5 and Firebase crashlytic 2.6.0 My app stop compiling with the error below
class org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar$2 cannot be cast to class org.gradle.api.file.Directory (org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar$2 and org.gradle.api.file.Directory are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader #68be2bc2)
class org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar$2 cannot be cast to class org.gradle.api.file.Directory (org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar$2 and org.gradle.api.file.Directory are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader #68be2bc2)
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
But everything works if I change Firebase crashlytic version to 2.3.0
Do you guys have any idea why is this happen?
UPDATED ANSWER:
The reason for the compiling issue is that version of Gradle and Crashlytics Gradle plug-in is incompatible.
As described here, starting from Crashlytics Gradle plugin version 2.5.0:
The Crashlytics
Gradle plugin is compatible with Gradle v5.6.4+ and the Android Gradle
plugin v3.4.2+. Support for previous Gradle and Android Gradle plugin
versions have been removed.
So, the Solution is to use the latest Gradle and firebase-crashlytics-gradle versions. Thanks to #Mher for describing the compatible up-to-date versions here. Follow his answer for updating versions. Don't forget to change compileOptions in app level build.gradle as:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Warning: My old answer below is a workaround to fix the Gradle and Crashlytics compatibility for those who are not ready to update the Gradle version. The proper solution is to update the Gradle version. In the old answer below, the mentioned firebase-crashlytics-gradle:2.4.1 was buggy for me and it was not able to upload mapping files to the Firebase console which deobfuscates the crash reports. So, try to follow the above-updated answer instead of downgrading the Crashlytics Gradle version.
OLD ANSER FOR WHO CANNOT UPDATE THE GRADLE VERSION:
I hit the exact same issue. Seems the latest crashlytics-gradle plugin is incompatible with something. Using the lower version of crashlytics-gradle plugin helped. Instead of firebase-crashlytics-gradle:2.6.0 Try to use this version:
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
That worked for me... If that doesn't work for you, you can maybe try even lower versions. A list of versions can be found here:
https://firebase.google.com/support/release-notes/android#crashlytics_gradle_plugin_v2-0-0
When you search for "Crashlytics Gradle plugin version", you can see all released versions for Crashlytics Gradle plugin.
I also had to change compileOptions in app level build.gradle as:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
When target and source compatibility was not set to 1_8, project compiled but was crashing when trying to run the app:
--------- beginning of crash
2021-06-09 17:22:28.765 29519-29519/com.resmed.myair.cpl E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.resmed.myair.cpl, PID: 29519
java.lang.BootstrapMethodError: Exception from call site #45 bootstrap method
at com.google.firebase.components.ComponentDiscovery.discoverLazy(ComponentDiscovery.java:112)
at com.google.firebase.FirebaseApp.<init>(FirebaseApp.java:418)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:299)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:267)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:252)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:51)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1917)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1892)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:45)
at android.app.ActivityThread.installProvider(ActivityThread.java:6239)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NoClassDefFoundError: Invalid descriptor: minimize.
at com.google.firebase.components.ComponentDiscovery.discoverLazy(ComponentDiscovery.java:112)
at com.google.firebase.FirebaseApp.<init>(FirebaseApp.java:418)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:299)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:267)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:252)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:51)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1917)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1892)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:45)
at android.app.ActivityThread.installProvider(ActivityThread.java:6239)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
In my case
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
solved the error but crashlytics didn't send errors to server.
I changed versions in \android\build.gradle to
classpath 'com.android.tools.build:gradle:4.2.0'
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
and in \android\gradle\wrapper\gradle-wrapper.properties to
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
and now everything works just fine.
I had to switch from:
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
to
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.0'
and then it worked. Seems like some new versions of the library aren't necessarily compatible with gradle.
Just try going down a few versions and build again.
Include:
implementation 'com.google.firebase:firebase-crashlytics'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.0'
In your Gradle File
I recently updated my Android Studio to 3.1.0 and I am using Gradle 4.4.0 and ever since I have updated my IDE I have been having issues with Jacoco. I get a runtime crash, which looks like:
03-29 15:41:19.944 6629-6629/com.MyApp.pr.redesign.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.MyApp.pr.MyApp.app, PID: 6629
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/jacoco/agent/rt/internal_773e439/Offline;
at com.MyApp.pr.eventcollector.utils.MyApp.$jacocoInit(Unknown Source:13)
at com.MyApp.pr.eventcollector.utils.MyApp.<clinit>(Unknown Source:0)
at com.MyApp.pr.eventcollector.utils.MyApp.setLevel(Unknown Source:0)
at com.MyApp.pr.MyApp.MyApp.setupLogging(MyApp.java:175)
at com.MyApp.pr.MyApp.MyApp.onCreate(MyApp.java:77)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.jacoco.agent.rt.internal_773e439.Offline" on path: DexPathList[[zip file "/data/app/com.MyApp.pr.redesign.app-EGnUUyKeM4P-cZrCGsyoUQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.MyApp.pr.redesign.app-EGnUUyKeM4P-cZrCGsyoUQ==/lib/arm64, /data/app/com.MyApp.pr.redesign.app-EGnUUyKeM4P-cZrCGsyoUQ==/base.apk!/lib/arm64-v8a, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.MyApp.pr.eventcollector.utils.MyApp.$jacocoInit(Unknown Source:13)
at com.MyApp.pr.eventcollector.utils.MyApp.<clinit>(Unknown Source:0)
at com.MyApp.pr.eventcollector.utils.MyApp.setLevel(Unknown Source:0)
at com.MyApp.pr.MyApp.MyApp.setupLogging(MyApp.java:175)
at com.MyApp.pr.MyApp.MyApp.onCreate(MyApp.java:77)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Here is what my Gradle files look like:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply from: 'gradle/configurations.gradle'
apply from: 'gradle/gradleLintConfig.gradle'
buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven {
}
maven {
url "https://maven.fabric.io/public"
}
}
dependencies {
// 3.0.1 (November 2017) - is a minor update to support Android Studio 3.0.1, and includes general bug fixes and performance improvements.
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:3.2.0'
//Here is Jacoco reference
classpath 'org.jacoco:org.jacoco.core:0.8.0'
// Nebula lint is used as a lint for our Gradle scripts. It helps identify if our
// Gradle scripts have unused dependencies for example. Also, it checks for conformance
// to Gradle standards.
classpath 'com.netflix.nebula:gradle-lint-plugin:9.0.0'
//Crashlytics - Crash reporting
classpath 'io.fabric.tools:gradle:1.25.1'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
tasks.withType(JavaCompile) {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And here is the app build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply from: "$project.rootDir/gradle/findbugs.gradle"
apply plugin: 'jacoco'
jacoco {
toolVersion = '0.8.0'
}
...
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
minifyEnabled false
}
debug {
versionNameSuffix="-debug"
debuggable true
/**
* Code below is commented out because it causes build issue
* when using newer version of gradle (3.1.0)
*/
testCoverageEnabled true
minifyEnabled false
}
}
}
...
dependencies {
...
}
I don't know what the issue is. I have tried to add the .jar files directly to the project with the same result. If anyone can help, I would be forever grateful!
I have same issue with gradle 4.6 and android plugin 3.1.0 when launching build from android studio / idea. However when I use gradle to build apk and deploy it with adb it works fine.
So it seems that the problem is related to IDE itself.
It does not package right jacoco version to apk.
EDIT:
I've disabled instant run and it works fine now.
I cant say my answer is the definitive problem because I can't see your dependencies in app build.gradle, but with this newest version of Gradle "compile" is no longer supported. This might be the root cause either in your build.gradle or the build.gradle of Jacoco.
I am building a library in Android Studio which has multiple Gradle dependencies such as the estimote and firebase sdk. When I export the library as an aar and then import it to a sample project, I get a run time error:
E/UncaughtException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/estimote/sdk/BeaconManager;
at com.mgenio.sdk.BeaconSDK.init(BeaconSDK.java:87)
at com.mgenio.sdk.BeaconSDK.checkSDK(BeaconSDK.java:214)
at com.mgenio.sdk.BeaconSDK.access$800(BeaconSDK.java:33)
at com.mgenio.sdk.BeaconSDK$3.onResponse(BeaconSDK.java:186)
at com.mgenio.sdk.BeaconSDK$3.onResponse(BeaconSDK.java:182)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.estimote.sdk.BeaconManager" on path: DexPathList[[zip file "/data/app/com.mgenio.smartscansample-1/base.apk"],nativeLibraryDirectories=[/data/app/com.mgenio.smartscansample-1/lib/arm64, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
Is there a special way to export my aar library so it includes these external dependencies? Thanks!
I had a similar issue some months ago, if you're publishing your library in a repository, then you have to add an xml or another kind of file that contains the dependencies your library have.
And if you need yo use any class of those dependencies, when you compile your library in the gradle file in your app module, you have to add transitive=true to have access to this classes or resources like this
compile('mx.segundamano.doubleseekbarview'){
transitive=true
}
EDIT
If you're publishing to Bintray - Maven repository, add this lines to your gradle file at the same level where your bintray configuration is
task generateSourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier 'sources'
}
artifacts {
archives generateSourcesJar
}
Is there a special way to export my aar library so it includes these external dependencies?
No
Exept you deploy your aar into a maven or ivy repository.
These aar dependency have some inbuild functionality in itself such as ic-launcher icon , image,logo, animation and much more.
Dhamija Dependency is one of them. such as :-
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.0#aar'
compile 'com.daimajia.androidanimations:library:1.0.8#aar
but you can use a best commercial dependency inside aar Remove above dependency and use this :
implementation 'com.airbnb.android:lottie:2.5.4'
hope this will resolve your issue !
You just add the same dependencies to your sample project and let Gradle take care of it.
I have an android application which depends on some android libraries I have built on my own.
If I build the application with the library dependencies specified in the build.gradle then I get the following exception.
-6694/com.mycompany.myproject D/AndroidRuntime: Shutting down VM
05-10 18:47:55.986 6694-6694/com.mycompany.myproject E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mycompany.myproject, PID: 6694
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/jacoco/agent/rt/internal_773e439/Offline;
at com.mycompany.ui.components.ListArrayAdapter.$jacocoInit(ListArrayAdapter.java)
at com.mycompany.ui.components.ListArrayAdapter.<init>(ListArrayAdapter.java)
at com.mycompany.myproject.NationalityFragment.onCreateView(NationalityFragment.java:47)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:339)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:602)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220)
at android.app.Activity.performStart(Activity.java:5953)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
If I remove the dependencies and instead copy the concerned classes from the libraries and run the application, it runs perfectly fine.
Also I have other dependencies like junit and app-compat and those don't seem to cause this issue. Any ideas what might be causing this issue?
I have tried specifying the jacoco plugin to the following version
and it still doesn't seem to work.
I have tried removing jacoco dependencies from the libraries : no
effect.
My main build.gradle looks like this :
task wrapper(type: Wrapper) {
gradleVersion = '2.13'
}
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
}
}
subprojects {
project.ext.set('compileSdkVersion', 23)
project.ext.set('buildToolsVersion', '23.0.3')
project.ext.set('minSdkVersion', 19)
project.ext.set('targetSdkVersion', 23)
project.ext.set('versionCode', 1)
project.ext.set('versionName', '1.0-SNAPSHOT')
project.ext.set('javaVersion', JavaVersion.VERSION_1_7)
group 'com.mycompany.myproject'
version = project.ext.get('versionName')
repositories {
mavenLocal()
mavenCentral()
}
}
I got this error after updating Android Studio. I found out that switching off Instant Run in Settings fixed it.
According to here, you'll need to jacocoagent.jar put on the classpath. In other words, you'll need to compile the same version of jacocoagent.jar in gradle.
First check the version code here(In your situation is version0.7.4.201502262128) and then download jars from here.
Put jacocoagent.jar in libs folder then add compile fileTree(dir: 'libs', include: ['jacocoagent.jar']) in your app's build.gradle.
bijang is correct. You need to add the jacocoagent.jar. Rather than including the jar directly, pull it down from maven. The version of the jacocoagent has to match the version of the jacocoplugin since the Offline.class package has a commmit hash. Here are my dependencies:
compile 'org.jacoco:jacoco-maven-plugin:0.7.9'
compile 'org.jacoco:org.jacoco.agent:0.7.9:runtime'
For Jacoco 0.8.7 i added the following to the app/build.gradle to resolve the issue
implementation 'org.jacoco:org.jacoco.agent:0.8.7'
java.lang.NoClassDefFoundError: android.databinding.DataBinderMapper
at android.databinding.DataBindingUtil.<clinit>(DataBindingUtil.java:31)
at com.example.MainActivity.onCreate(MainActivity.java:13)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
I hope this is a bug, does anyone face a similar problem? I unzipped classes.jar under the exploded-arr folder, but couldn't find the DataBinderMapper class.
Any workarounds / fixes would be appreciated.
Make sure that ALL your modules that use DataBinding have it enabled. This was the reason I got that exception.
android {
...
dataBinding {
enabled = true
}
}
You should include the android-apt plugin in your build.gradle in order to generate the android.databinding.DataBinderMapper class.
In your project build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
classpath 'com.android.databinding:dataBinder:1.0-rc2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
//.... more
}
In each module build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
apply plugin: 'com.neenbedankt.android-apt'
More information
I was facing same error. What I have done is that I updated the dependency for databinding in app.gradle file
kapt 'com.android.databinding:compiler:3.1.0-alpha05'
to
kapt 'com.android.databinding:compiler:3.2.0-alpha04'
after updating the databinder compiler, I started getting this error. To get rid from this problem I have to revert the databinding compiler to old version and it taken me away from this problem. Now I am waiting for stable databinding compiler version and will upgrade to that version till then I will go with old compiler version.
I was having this issue this last week, and was having a hard time figuring it out, but finally I discovered that I had two layouts with the same name in different libraries that each use databinding. I'm guessing this was causing the generated binding classes to end up in some kind of bad state at runtime.
I was able to troubleshoot it into a situation where, instead of getting this error on one Fragment, I got a ClassCastException to happen on the Fragment that had a layout with the same name. The generated Binding class was trying to cast a LinearLayout into a RelativeLayout. The only way it could be doing this is if it were trying to use a layout file from a completely different module that had the same name.
After making sure there were no layouts that share the same name -- even across different library modules -- it cleared up.
If you are facing this issue when you run your tests, just add:
kaptTest "androidx.databinding:databinding-compiler:+"
to dependencies on build.gradle files of all your modules.