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 )
Related
I am getting the following error when I build the app with proguard. This failure is new. I updated some of the libraries used in the app to latest (including the target and compile sdk version to 30)but the joda library version is not changed. It is implementation 'net.danlew:android.joda:2.8.2'
Any idea why this error is coming now and how it can be resolved.
I already have the rule -keep class org.joda.** { *; } in my progurad rules.
java.lang.RuntimeException: Unable to create application com.xxx.xxx.xxx: java.lang.RuntimeException: Could not read ZoneInfoMap
at android.app.ActivityThread.handleMakeApplication(ActivityThread.java:7506)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7440)
at android.app.ActivityThread.access$1500(ActivityThread.java:301)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2148)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8506)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Caused by: java.lang.RuntimeException: Could not read ZoneInfoMap
at net.a.a.a.a.a(SourceFile:42)
at com.xxx.xxx.xxx.onCreate(SourceFile:116)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
EDIT
Updating joda version to the latest 2.10.9.1 fixes the issue.
I am not adding this as answer as I wanted to know why this error appeared all of a sudden? Can any other version update can lead to this.
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)
After configuring account kit sdk as
compile 'com.facebook.android:account-kit-sdk:4.+'
and gradle sync it conflict with com.google.android.gms gradle as mixing versions can lead to runtime crashes and my app crash as
Firebase API initialization failure.
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.google.firebase.FirebaseApp.zza(Unknown Source)
at ...
the above error is due to mixing google play services gradle (I think Google play services gradle may be used by Facebook Account Kit SDK) because I have same version for all Google play services gradles.
And one more crash is coming from Facebook Account Kit SDK side as
java.lang.RuntimeException: Unable to get provider com.facebook.accountkit.internal.AccountKitInitProvider: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
at android.app.ActivityThread.installProvider(ActivityThread.java:5260)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4808)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4748)
at android.app.ActivityThread.access$1700(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1436)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:5529)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
at com.facebook.accountkit.internal.Initializer.initialize(Initializer.java:99)
at com.facebook.accountkit.internal.AccountKitController.initialize(AccountKitController.java:592)
at com.facebook.accountkit.internal.AccountKitInitProvider.onCreate(AccountKitInitProvider.java:31)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1758)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1733)
at android.app.ActivityThread.installProvider(ActivityThread.java:5257)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4808)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4748)
at android.app.ActivityThread.access$1700(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1436)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:5529)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
But after removing
compile 'com.facebook.android:account-kit-sdk:4.+'
my app working without any issue.
But to integrate Facebook Account Kit in my app I have to include above gradle which conflict with google play services.
Totally disappointed, please help.
After upgrading Firebase Gradle as
compile 'com.google.firebase:firebase-messaging:11.6.0'
its not colliding but still gives above RuntimeException from Account Kit SDK.
To fix this you can do something like the following
compile ('com.facebook.android:account-kit-sdk:4.27.0') {
exclude group: 'com.google.android.gms', module: 'play-services-auth-api-phone'
exclude group: 'com.google.android.gms', module: 'play-services-auth'
}
compile 'com.google.android.gms:play-services-auth:11.6.0'
compile 'com.google.firebase:firebase-messaging:11.6.0'
That would remove the stale support gms library from Facebook's SDK and then swap in the same version of the lib that Firebase is using.
Possibly the conflict of libraries can be the reason. See dependencies here;
https://mvnrepository.com/artifact/com.facebook.android/account-kit-sdk/4.27.0
See if you could submit an issue with the facebook to update it.
Or if you need facebook for authentication only, you can use Facebook Android Sdk
What feature/service from firebase r u using , can u pls share the snippet of ur gradle dependencies for the same to better understand the problem here?
For Unable to get provider RuntimeException exception it seems that, Application is not initialized first, Content Providers are initialized before it.
And in Facebook account kit SDK's code it was trying to get my application context.
Now the problem was, I did implement method getApplicationContext() in application class that is getting application shared variable but that variable was setting globally and Facebook Account Kit sdk code getting Null application context.
Solution : setting shared variable in onCreate method instead of setting globally it resolved the problem of Unable to get provider.
And For Mixing issue, Account Kit SDK use 11.0.1 version for play services gradle and in my project I am having 11.0.4 that is actually not the issue because on compile time gradle takes latest gradle but In my project I am not referring below gradle which Facebook Account Kit SDK is using.
compile 'com.google.android.gms:play-services-auth-api-phone:11.0.1'
Solution : I have added above gradle with version 11.0.4 and the mixing gradle issue has been resolved.
compile 'com.google.android.gms:play-services-auth-api-phone:11.0.4'
And as suggested by #astryk if I exclude play-services-auth-api-phone module then gradle mixing error is not showing but it is not including that module becasue in AccountKitActivity on next button click my application crashes as
Crash Report Thread:main Exception:java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/auth/api/phone/SmsRetriever;
at com.facebook.accountkit.internal.PhoneLoginController.createSmsToken(PhoneLoginController.java:250)
at com.facebook.accountkit.internal.PhoneLoginController.logIn(PhoneLoginController.java:188)
at com.facebook.accountkit.internal.LoginManager.logInWithPhoneNumber(LoginManager.java:372)
at com.facebook.accountkit.internal.AccountKitController.logInWithPhoneNumber(AccountKitController.java:631)
at com.facebook.accountkit.ui.PhoneLoginFlowManager.logInWithPhoneNumber(PhoneLoginFlowManager.java:57)
at com.facebook.accountkit.ui.ActivityPhoneHandler.onPhoneLoginComplete(ActivityPhoneHandler.java:189)
at com.facebook.accountkit.ui.AccountKitActivity$1.onReceive(AccountKitActivity.java:176)
at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297)
at android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46)
at android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:5529)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.auth.api.phone.SmsRetriever" on path: DexPathList[[zip file "/data/app/com.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myappList item -1/lib/arm64, /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)
... 16 more
Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.auth.api.phone.SmsRetriever
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)
... 17 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available`
I am using Firebase Crash Reporting and Firebase Remote Config. Version of both is 9.8.0.
On most devices setup works perfectly (I followed Set up crash reporting). But on small percentage of devices (it is actually crash with the highest occurrence) it crashes when I try to initialize Remote Config in Application onCreate method.
java.lang.RuntimeException: Unable to create application com.company.application.AppApplication: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.company.application. Make sure to call FirebaseApp.initializeApp(Context) first.
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6429)
at android.app.ActivityThread.access$1800(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7329)
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.IllegalStateException: Default FirebaseApp is not initialized in this process com.company.application. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.a.d(Unknown Source)
at com.google.firebase.b.a.a(Unknown Source)
at com.company.application.d.a.a(SourceFile:21)
at com.company.application.AppApplication.onCreate(SourceFile:76)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1037)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6426)
... 8 more
Prior to version 10.0.0, Firebase Crash created an additional process in your app named background_crash. An instance of your AppApplication class is created and executed for each process in your app, including background_crash.
If you want to perform initialization of Firebase services in your application class, you need to add a guard to prevent the initialization from being performed in background_crash. On way to do that is:
if (!FirebaseApp.getApps(this).isEmpty()) {
// Not in crash process. Do your Remote Config init here.
}
Another solution is to upgrade to the latest version of Firebase, 10.0.1.
Assuming this answer is valid, I can't explain why the failure only occurs on some devices, unless the version of Google Play Services installed on the device is a factor, and the failing devices have an older version.
set classpath 'com.google.gms:google-services:4.0.1' in dependencies.
Implement the androidTestImplementation dependencies :
androidTestImplementation('com.android.support.test.espresso:espresso-core:.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
As an example, dynamically loading the following code using the groovyshell-example app found here: https://github.com/pieces029/grooidshell-example/tree/update/build-tools-and-scripts:
def class Outer {
def class Inner {}
}
new Outer.Inner()
Result in Android Emulator API 23
Result = Outer$Inner#a9ea1cd
Result in Android Emulator API 24
Result = null
Stacktrace in API 24
08-13 02:23:03.233 3147-3147/me.champeau.groovydroid E/GrooidShell: Dynamic loading failed!
BUG! exception in phase 'semantic analysis' in source unit 'script14710549832242032452851.groovy' throw with null exception
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:935)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:593)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:542)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:254)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:211)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:221)
at me.champeau.groovydroid.GrooidShell.evaluate(GrooidShell.java:85)
at me.champeau.groovydroid.GroovyActivity.generateMessage(GroovyActivity.groovy:38)
at me.champeau.groovydroid.GroovyActivity.executeCode(GroovyActivity.groovy:31)
at java.lang.reflect.Method.invoke(Native Method)
at android.view.View$DeclaredOnClickListener.onClick(View.java:4693)
at android.view.View.performClick(View.java:5610)
at android.view.View$PerformClick.run(View.java:22260)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.NullPointerException: throw with null exception
at java.net.URLClassLoader.findClass(URLClassLoader.java:371)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:677)
at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:545)
at org.codehaus.groovy.control.ClassNodeResolver.tryAsLoaderClassOrScript(ClassNodeResolver.java:185)
at org.codehaus.groovy.control.ClassNodeResolver.findClassNode(ClassNodeResolver.java:170)
at org.codehaus.groovy.control.ClassNodeResolver.resolveName(ClassNodeResolver.java:126)
at org.codehaus.groovy.control.ResolveVisitor.resolveToOuter(ResolveVisitor.java:676)
at org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:308)
at org.codehaus.groovy.control.ResolveVisitor.resolveNestedClass(ResolveVisitor.java:341)
at org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:308)
at org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:276)
at org.codehaus.groovy.control.ResolveVisitor.resolveOrFail(ResolveVisitor.java:260)
at org.codehaus.groovy.control.ResolveVisitor.resolveOrFail(ResolveVisitor.java:272)
at org.codehaus.groovy.control.ResolveVisitor.transformConstructorCallExpression(ResolveVisitor.java:1047)
at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:706)
at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitExpressionStatement(ClassCodeExpressionTransformer.java:142)
at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:37)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:166)
at org.codehaus.groovy.control.ResolveVisitor.visitBlockStatement(ResolveVisitor.java:1318)
at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:104)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:115)
at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitConstructorOrMethod(ClassCodeExpressionTransformer.java:53)
08-13 02:23:03.234 3147-3147/me.champeau.groovydroid E/GrooidShell: at org.codehaus.groovy.control.ResolveVisitor.visitConstructorOrMethod(ResolveVisitor.java:201)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:126)
at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1078)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:53)
at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1261)
at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:176)
at org.codehaus.groovy.control.CompilationUnit$11.call(CompilationUnit.java:651)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:931)
... 21 more
The version of the DX library included in that project is 1.7. Where the best I can tell by opening up the dx.jar file included with the latest (24.1.1) build tools is 1.12. I am guessing that similar to Java backwards compatibility is kept in place but lower versions will not run on newer version.
On that note, I would guess that someone just posted the dx jar to central and that is not an official google release. I think the best bet would be to reference the jar that is included in the build tools you are compiling with.