Android : Proguard build is failing for joda time - android

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.

Related

Kotlin Multiplatform + Sentry

I want to use Sentry for my Multiplatform Kotlin project.
Sentry for Kotlin Multiplatform
So I was trying to prepare the setup of Sentry with Kotlin Multiplatform.
I was following the guide, made a mavenLocal() build etc.
Now I wanted to add it to the project.
However, when starting my (Android) project, even before starting the onCreate() of the Application I get a crash stating:
Unable to get provider io.sentry.android.core.SentryInitProvider:
java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.
So to be clear this happens already when adding api("io.sentry:sentry-kotlin-multiplatform:0.0.1") to the dependencies. Long before the init call.
All I did was:
Configure shared build.gradle.kts and add
val commonMain by getting {
dependencies {
api("io.sentry:sentry-kotlin-multiplatform:0.0.1")
Adding the sample configuration
fun initializeSentry(context: Context) {
Sentry.init(context) { sentryOptions -> setDsnHere... }
}
and in the Android Application:
initializeSentry(this)
Then tried to run it. But I don't even get to the init call.
The configuration should be reached and the initializeSentry(this) block executed. (I can accept if it fails there but I don't even get that far.)
Instead the app fails stating
E/AndroidRuntime: FATAL EXCEPTION: main
Process: xyz, PID: 23056
java.lang.RuntimeException: Unable to get provider io.sentry.android.core.SentryInitProvider: java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.
at android.app.ActivityThread.installProvider(ActivityThread.java:7467)
...
even before anything else.
So the mere adding to the gradle file causes the crash already (even if the other code is commented out).
-------- Full Stack trace-------
java.lang.RuntimeException: Unable to get provider io.sentry.android.core.SentryInitProvider: java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.
at android.app.ActivityThread.installProvider(ActivityThread.java:7467)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6973)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6744)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7872)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Caused by: java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.
at io.sentry.Sentry.initConfigurations(Sentry.java:201)
at io.sentry.Sentry.init(Sentry.java:170)
at io.sentry.Sentry.init(Sentry.java:118)
at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:87)
at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:56)
at io.sentry.android.core.SentryInitProvider.onCreate(SentryInitProvider.java:27)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2451)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2421)
at io.sentry.android.core.SentryInitProvider.attachInfo(SentryInitProvider.java:44)
at android.app.ActivityThread.installProvider(ActivityThread.java:7462)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6973) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6744) 
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loopOnce(Looper.java:201) 
at android.os.Looper.loop(Looper.java:288) 
at android.app.ActivityThread.main(ActivityThread.java:7872) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) 
Turns out the manual had forgotten to mention the auto configuration.
Add this line to your Manifest:
<meta-data android:name="io.sentry.auto-init" android:value="false" />
and proceed with the tutorial.
For Reference:
https://github.com/getsentry/sentry-kotlin-multiplatform/issues/45

Appsflyer Crash : Fatal Exception: java.lang.NoSuchMethodError for MultipleInstallBroadcastReceiver.java line 43

I am getting a Crash which is reported in Crashlytics for com.appsflyer.MultipleInstallBroadcastReceiver.onReceive in MultipleInstallBroadcastReceiver.java class
This Crash is been reported for few users in all the android verisons
Fatal Exception: java.lang.NoSuchMethodError: No virtual method 藡(Landroid/content/Context;Landroid/content/Intent;)V in class Lcom/appsflyer/AppsFlyerLib; or its super classes (declaration of 'com.appsflyer.AppsFlyerLib' appears in /data/app/com.rapido.passenger-1/base.apk)
at com.appsflyer.MultipleInstallBroadcastReceiver.onReceive(MultipleInstallBroadcastReceiver.java:43)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3112)
at android.app.ActivityThread.-wrap18(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1627)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:165)
at android.app.ActivityThread.main(ActivityThread.java:6375)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)
From the stack trace it seems to be an obfuscation issue (looking at the method name 藡)
What is the SDK version being used? Are there any proGuard (or other tool) rules configured for AppsFlyer?
If not I would suggest adding a -keep class com.appsflyer.** { *; } rule.
If you do not wish to share any additional information publicly, you can open a ticket with support#appsflyer.com, with the SDK version, any obfuscation related information and a link to this thread.

java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/commons/logging/LogFactory

Similar questions have need asked already. But this one seems to be more complicated than previous ones because of changes in compatibility of Android Platforms.
Here is my error log from Pixel and Pixel2 which are signed up for Android Beta Program
08-16 13:20:53.146 9630-9630/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: me.project.android.dev, PID: 9630
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/commons/logging/LogFactory;
at com.amazonaws.util.VersionInfoUtils.<clinit>(VersionInfoUtils.java:41)
at com.amazonaws.util.VersionInfoUtils.c(VersionInfoUtils.java:77)
at com.amazonaws.ClientConfiguration.<clinit>(ClientConfiguration.java:43)
//project specific class reference removed
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
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)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.commons.logging.LogFactory" on path: DexPathList[[zip file "/data/app/me.project.android.dev-0SPRJnc8-4voauRU7Y20zQ==/base.apk"],nativeLibraryDirectories=[/data/app/me.project.android.dev-0SPRJnc8-4voauRU7Y20zQ==/lib/arm64, /data/app/me.project.android.dev-0SPRJnc8-4voauRU7Y20zQ==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.amazonaws.util.VersionInfoUtils.<clinit>(VersionInfoUtils.java:41) 
at com.amazonaws.util.VersionInfoUtils.c(VersionInfoUtils.java:77) 
at com.amazonaws.ClientConfiguration.<clinit>(ClientConfiguration.java:43) 
//project specific class reference removed
at android.os.Handler.handleCallback(Handler.java:873) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:193) 
at android.app.ActivityThread.main(ActivityThread.java:6669) 
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) 
Same code when ran on Devices running Android 7.0 and below, it works perfectly fine.
I tried adding dependency to my project too
implementation "commons-logging:commons-logging:1.2"
Adding this dependency makes the app work in Pixel and Pixel but then it crashes in all other devices with Exception saying
org.apache.commons.logging.impl.LogFactoryImpl does not extend or implement org.apache.commons.logging.LogFactory
I tried doing all the changes in ProGuard already. Here is my proguard configuration
-keep class org.apache.commons.logging.impl.LogFactoryImpl
-keep class org.apache.commons.logging.LogFactory
-keepnames class org.apache.commons.logging.impl.* {*;}
-keepnames class org.apache.commons.logging.*
-keepclassmembers class org.apache.commons.logging.impl.* {*;}
-keepclassmembers class org.apache.commons.logging.*
-keepnames interface org.apache.commons.logging.impl.* {*;}
-keepnames interface org.apache.commons.logging.*
Still causing the crash.
This issue is related to Amazon AWS SDK - https://github.com/aws/aws-sdk-android/issues/476
Is there any workaround till AWS updates their SDK to fix this issue?
Add this below line in manifest file.
<uses-library android:name ="org.apache.http.legacy" android:required ="false"/>
This is an AWS SDK bug that appears to be solved in version 2.6.30 of the SDK:
Fixed a bug where getting a logger using Apache Commons Logging would
crash starting Android 9.0 (Pie / API Level 28). See pull #521. Now,
Apache Commons Logging would be used if it's being added as a
dependency, otherwise android.util.Log will be used.
to fix this issue I had the dependency
implementation "commons-logging:commons-logging-api:1.1"
in gradle file.
An alternative workaround is to add the commons-logging library as a .jar file to your libs/ folder instead of using implementation. Make sure that implementation fileTree(include: ['*.jar'], dir: 'libs') is in your dependencies.
Sources of commons-logging-1.2.jar:
Maven Repository
Apache Commons Logging
Credit: Dale Lim -
https://github.com/aws/aws-sdk-android/issues/265#issuecomment-411978696
/*Apache Commons Logging would crash starting Android 9.0 (Pie / API Level 28).*/
//try this
testImplementation 'commons-logging:commons-logging:1.2'
// in manifest <application> s
<uses-library android:name="org.apache.http.legacy" android:required="false" />
/* if this files 'commons-logging:commons-logging:1.2' fails to download then
download this file manual from http://commons.apache.org/proper/commons-
logging/download_logging.cgi and paste it lib folder*/

Facebook Account Kit Collision with Google play services gradle

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`

NoSuchFieldException when using SugarORM (big dependency)

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 )

Categories

Resources