I suddnly started getting this runtime exception at app launch without having room as my dependency at all.
07-20 19:48:37.703 18737-18771/mypackage.x E/AndroidRuntime: FATAL EXCEPTION: pool-4-thread-1
Process: mypackage, PID: 18737
java.lang.IllegalStateException: A migration from 3 to 2 was required but not found. Please provide the necessary Migration path via RoomDatabase.Builder.addMigration(Migration ...) or allow for destructive migrations via one of the RoomDatabase.Builder.fallbackToDestructiveMigration* methods.
at android.arch.persistence.room.RoomOpenHelper.onUpgrade(RoomOpenHelper.java:97)
at android.arch.persistence.room.RoomOpenHelper.onDowngrade(RoomOpenHelper.java:109)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onDowngrade(FrameworkSQLiteOpenHelper.java:144)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:396)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:298)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:96)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:54)
at android.arch.persistence.room.RoomDatabase.compileStatement(RoomDatabase.java:244)
at android.arch.persistence.room.SharedSQLiteStatement.createNewStatement(SharedSQLiteStatement.java:65)
at android.arch.persistence.room.SharedSQLiteStatement.getStmt(SharedSQLiteStatement.java:72)
at android.arch.persistence.room.SharedSQLiteStatement.acquire(SharedSQLiteStatement.java:87)
at androidx.work.impl.model.WorkSpecDao_Impl.resetScheduledState(WorkSpecDao_Impl.java:337)
at androidx.work.impl.WorkManagerImpl.rescheduleEligibleWork(WorkManagerImpl.java:514)
at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:73)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
here are some of the dependencies that I do have from Android arch:
implementation "androidx.core:core-ktx:$ktx_version"
implementation "android.arch.paging:runtime:$paging_runtime"
implementation("android.arch.lifecycle:extensions:$android_arc_version") {
force = true
}
implementation "android.arch.navigation:navigation-fragment-ktx:$navigation_version"
// use -ktx for Kotlin
implementation "android.arch.navigation:navigation-ui-ktx:$navigation_version"
implementation "android.arch.work:work-runtime-ktx:$work_version"
Any idea what might have caused this?
It turns out that android.arch.work:work had a dependency to the room library and I was using the version 1.0.0-alpha03 of work library. I thought of excluding the dependency but I noticed that an update is available for the work component and after trying that, it fixed the issue. So upgrade your work library to fix the issue (at this time the updated version is 1.0.0-alpha04)
Related
I am getting this error while building my Kotlin/Android application?
Caused by: java.lang.reflect.InvocationTargetException
at jdk.internal.reflect.GeneratedMethodAccessor812.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:90)
at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:31)
at org.jetbrains.kotlin.kapt3.base.Kapt.kapt(Kapt.kt:45)
... 30 more
Caused by: com.sun.tools.javac.processing.AnnotationProcessingError: java.lang.IllegalArgumentException: com.example.MyClassName does not represent a declared type
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:992)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:896)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1222)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1335)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1258)
... 35 more
Caused by: java.lang.IllegalArgumentException: com.example.MyClassName does not represent a declared type
at dagger.shaded.auto.common.MoreTypes$CastingTypeVisitor.defaultAction(MoreTypes.java:948)
at dagger.shaded.auto.common.MoreTypes$CastingTypeVisitor.defaultAction(MoreTypes.java:939)
at jdk.compiler/com.sun.tools.javac.code.Type$ErrorType.accept(Type.java:2394)
at dagger.shaded.auto.common.MoreTypes.asDeclared(MoreTypes.java:579)
at dagger.internal.codegen.base.Keys$1.visitDeclared(Keys.java:89)
at dagger.internal.codegen.base.Keys$1.visitDeclared(Keys.java:66)
at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.accept(Type.java:1151)
at dagger.internal.codegen.base.Keys.isValidImplicitProvisionKey(Keys.java:65)
at dagger.internal.codegen.base.Keys.isValidImplicitProvisionKey(Keys.java:50)
I am using dagger2 for dependency injection, in my application, the application uses a module that has a dependency on another module. What should be the correct way to resolve this dependency?
You'll need an implementation dependency on the module you're consuming, but the recent build flag enableAggregatingTask will do so automatically.
Per google/dagger#2123, bcorso responding to Kshitij09 in November 2020:
You mean I either app should have direct dependency (adding implementation) on :libraryB or :libraryA have api dependency on :libraryB right?
Hi #Kshitij09, yes that's the current solution and we're looking into ways to improve this (see #1991 (comment))
In that same thread, bcorso updates in September 2021:
If you're using Hilt (with Gradle) the solution is to use the Hilt Gradle plugin and then enable the aggregating task in your build.gradle modules:
hilt {
enableAggregatingTask = true
}
The enableAggregatingTask build configuration was introduced in Dagger 2.37 in June 2021 and enabled by default in Dagger 2.40 in October 2021.
Okay, so I'm having some very odd behaviour that doesn't make much sense in my app.
My app uses BLE and I have a static class which I initialize on app launch, this typically works with no issue.
Today I made a single change in my app which was to update this:
implementation 'com.google.firebase:firebase-core:17.2.1'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
To this:
implementation 'com.google.firebase:firebase-core:17.2.2'
implementation 'com.google.firebase:firebase-messaging:20.1.0'
And after making this minor version update to firebase core, my app now immediately crashes on launch with the following error:
2020-02-13 09:44:57.530 20760-20760/my.package.name E/AndroidRuntime: FATAL EXCEPTION: main
Process: my.package.name, PID: 20760
java.lang.NoSuchMethodError: No static method injectMembers(Ldagger/MembersInjector;Ljava/lang/Object;)Ljava/lang/Object; in class Ldagger/internal/MembersInjectors; or its super classes (declaration of 'dagger.internal.MembersInjectors' appears in /data/app/my.package.name-Nbmle9woVCiX-2v0teYwZw==/base.apk!classes3.dex)
at com.polidea.rxandroidble.RxBleAdapterStateObservable_Factory.get(RxBleAdapterStateObservable_Factory.java:28)
at com.polidea.rxandroidble.RxBleAdapterStateObservable_Factory.get(RxBleAdapterStateObservable_Factory.java:10)
at com.polidea.rxandroidble.RxBleClientImpl_Factory.get(RxBleClientImpl_Factory.java:104)
at com.polidea.rxandroidble.RxBleClientImpl_Factory.get(RxBleClientImpl_Factory.java:23)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.polidea.rxandroidble.DaggerClientComponent.rxBleClient(DaggerClientComponent.java:419)
at com.polidea.rxandroidble.RxBleClient.create(RxBleClient.java:54)
at my.package.name.Comm.RxBLEComm.<init>(RxBLEComm.java:109) // These are the only
at my.package.name.Comm.RxBLEComm.init(RxBLEComm.java:118) // lines in my code which
at my.package.name.RootApp.onCreate(RootApp.kt:63) // are totally unrealted to firebase
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1155)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5928)
at android.app.ActivityThread.access$1100(ActivityThread.java:200)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6735)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
2020-02-13 09:44:57.586 2989-3111/? E/NetworkController.MobileSignalController(2): showVoteIcon=false
Note: My app does not use dagger at all, though the RxBLE library might...
If I revert the firebase update the app builds and runs with no issue, so for now I'll just stick to using firebase-messaging:20.0.0 and firebase-core:17.2.1, but does anyone have any clue why this might be happening?
This is the only line of code required to make the crash happen:
RxBleClient.create(applicationContext)
Here is a test repo that you can reproduce the crash in:
https://github.com/Doophie/TestAppCrash
Note that there are 2 commits, in the first commit the app has updated firebase and crashes, the second commit it does not crash and uses the older firebase version.
So the issue was the version of the rxandroidble library was incompatible with the new firebase messaging.
When I updated from
implementation 'com.polidea.rxandroidble:rxandroidble:1.4.3'
to
implementation 'com.polidea.rxandroidble:rxandroidble:1.7.1'
the crash stopped.
I have downloaded SDK for Android from
https://developers.chirp.io/downloads
After that I added *.aar library as was explain here:
https://developer.android.com/studio/projects/android-library.html#AddDependency
Hurrah. I can build the project.
Now I want to install the test App on the phone. But the application crashes like this:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.chirp.sdkdemoapp, PID: 12979
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;
at io.chirp.chirpsdk.ChirpSDK.<init>(Unknown Source:2)
at io.chirp.chirpsdk.ChirpSDK.<init>(Unknown Source:5)
at io.chirp.chirpsdk.ChirpSDK.<init>(Unknown Source:8)
at io.chirp.sdkdemoapp.MainActivity.onCreate(MainActivity.java:77)
As I understand it, a problem arose with dependencies when packaging * aar
So I added in build.gradle (marked as Module) dependency for kotlin like:
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.2.61'
After that my ERROR has changed.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.chirp.sdkdemoapp, PID: 13395
java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/MediaType;
at io.chirp.b.a.<init>(Unknown Source:24)
at io.chirp.chirpsdk.a.<init>(Unknown Source:36)
at io.chirp.chirpsdk.ChirpSDK.<init>(Unknown Source:20)
at io.chirp.chirpsdk.ChirpSDK.<init>(Unknown Source:5)
at io.chirp.chirpsdk.ChirpSDK.<init>(Unknown Source:8)
at io.chirp.sdkdemoapp.MainActivity.onCreate(MainActivity.java:77)
I have wrong paths to io.chirp internal libraries.
What should I do to resolve dependency related errors?
You have to import the okhttp 3.12.x dependency required by the ChirpSDK.
However, you don't need to explicitly import the dependency if you are using the SDK from the maven repository as this will be already included:
implementation 'io.chirp:chirpsdk:3.10.0'
and add the repository in your parent maven file:
repositories {
maven {
url "https://maven.chirp.io/release"
}
}
Thanks Dinu for your answer!
Maven repository doesn't work in my case (proxy issues or something else but this is the topic of another discussion).
The problem with using offline ChirpSDK was solved by adding two dependencies:
implementation 'com.squareup.okhttp3:okhttp:3.12.6'
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.50'
When I upgrade WorkManager from 1.0.0-alpha02 to 1.0.0-alpha03.
Old build.gradle
def work_version = "1.0.0-alpha02"
implementation "android.arch.work:work-runtime:$work_version" // use -ktx for Kotlin
// optional - Firebase JobDispatcher support
implementation "android.arch.work:work-firebase:$work_version"
New build.gradle
def work_version = "1.0.0-alpha03"
implementation "android.arch.work:work-runtime:$work_version" // use -ktx for Kotlin
// optional - Firebase JobDispatcher support
implementation "android.arch.work:work-firebase:$work_version"
I notice I need to make the following changes
1.0.0-alpha02
public WorkerResult doWork() {
1.0.0-alpha03
public Result doWork() {
That's not an major issue though. However, if we tend to upgrade an app, which is previously already running using 1.0.0-alpha02, we will get the following runtime exception
android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: WorkTag.tag, WorkTag.work_spec_id (code 1555)
at android.database.sqlite.SQLiteConnection.nativeExecuteForChangedRowCount(Native Method)
at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java:734)
at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java:754)
at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:64)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1679)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1608)
at android.arch.persistence.db.framework.FrameworkSQLiteDatabase.execSQL(FrameworkSQLiteDatabase.java:242)
at androidx.work.impl.WorkDatabaseMigrations$1.migrate(WorkDatabaseMigrations.java:73)
at android.arch.persistence.room.RoomOpenHelper.onUpgrade(RoomOpenHelper.java:85)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onUpgrade(FrameworkSQLiteOpenHelper.java:133)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:256)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:96)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:54)
at android.arch.persistence.room.RoomDatabase.compileStatement(RoomDatabase.java:244)
at android.arch.persistence.room.SharedSQLiteStatement.createNewStatement(SharedSQLiteStatement.java:65)
at android.arch.persistence.room.SharedSQLiteStatement.getStmt(SharedSQLiteStatement.java:72)
at android.arch.persistence.room.SharedSQLiteStatement.acquire(SharedSQLiteStatement.java:87)
at androidx.work.impl.model.WorkSpecDao_Impl.resetScheduledState(WorkSpecDao_Impl.java:337)
at androidx.work.impl.WorkManagerImpl.rescheduleEligibleWork(WorkManagerImpl.java:514)
at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:73)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
May I know what are some workarounds, to avoid such run-time exception?
We introduced implicit tags for Workers in alpha03. In the rare case that you have a pre-existing tag, this will happen. We will address this issue in alpha04. Stay tuned.
When I call SugarRecord.listAll(SignInData.class) I get the following error:
java.lang.NoSuchFieldException: No field mFlags in class Landroid/service/media/MediaBrowserService$Result; (declaration of 'android.service.media.MediaBrowserService$Result' appears in /system/framework/framework.jar:classes2.dex)
at java.lang.Class.getDeclaredField(Native Method)
at android.support.v4.media.MediaBrowserServiceCompatApi24.<clinit>(MediaBrowserServiceCompatApi24.java:36)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:324)
at com.orm.util.ReflectionUtil.getDomainClass(ReflectionUtil.java:274)
at com.orm.util.ReflectionUtil.getDomainClasses(ReflectionUtil.java:258)
at com.orm.SchemaGenerator.createDatabase(SchemaGenerator.java:45)
at com.orm.SugarDb.onCreate(SugarDb.java:28)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:251)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at com.orm.SugarDb.getDB(SugarDb.java:38)
at com.orm.SugarRecord.getSugarDataBase(SugarRecord.java:35)
at com.orm.SugarRecord.find(SugarRecord.java:201)
at com.orm.SugarRecord.listAll(SugarRecord.java:127)
I use SugarORM in version 1.5 and have another dependency with many transitive dependencies. I already excluded some of them, so the gradle build & installation no longer complains about too many methods. But I needed to enable jumboMode, but no minifyEnabled.
I don't know if anything of this has to do with my error, but since it reffers to a dex-file, this is my only clue so far.
EDIT
I excluded even more transitive dependencies so I no longer need the jumboMode but it is still the same error.
In My case I got this Exception because there is no data table. and trying to retrieve data from table. Just insert some data first.(Sorry don't know the root cause of this Exception )