Android App works in debug but not in release - android

I'm developing an Android app and I have a problem when I run the app in release mode. If I start the app in debug mode I get this type of message in the Logcat (the app doesn't start):
E/AndroidRuntime: FATAL EXCEPTION: GoogleApiHandler
Process: it.planner, PID: 27326
java.lang.SecurityException: In order to use mock mode functionality app it.planner must be selected as the mock location
application in developer settings.
at android.os.Parcel.readException(Parcel.java:2008)
at android.os.Parcel.readException(Parcel.java:1954)
at com.google.android.gms.internal.zzeu.zzb(Unknown Source:10)
at com.google.android.gms.internal.zzcfa.zzbj(Unknown Source:9)
at com.google.android.gms.internal.zzcfd.zzbj(Unknown Source:13)
at com.google.android.gms.internal.zzcfk.zzbj(Unknown Source:2)
at com.google.android.gms.internal.zzcee.zza(Unknown Source:4)
at com.google.android.gms.common.api.internal.zzm.zzb(Unknown Source:8)
at com.google.android.gms.common.api.internal.zzc.zza(Unknown Source:6)
at com.google.android.gms.common.api.internal.zzbo.zzb(Unknown Source:9)
at com.google.android.gms.common.api.internal.zzbo.zzaiw(Unknown
Source:82)
at com.google.android.gms.common.api.internal.zzbo.onConnected(Unknown
Source:16)
at com.google.android.gms.common.internal.zzac.onConnected(Unknown
Source:2)
at com.google.android.gms.common.internal.zzn.zzakr(Unknown Source:130)
at com.google.android.gms.common.internal.zze.zzw(Unknown Source:64)
at com.google.android.gms.common.internal.zzi.zzaks(Unknown Source:51)
at com.google.android.gms.common.internal.zzh.handleMessage(Unknown
Source:270)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loop(Looper.java:166)
at android.os.HandlerThread.run(HandlerThread.java:65) E/iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
Obviously, if I select the mock location in Developer Options, the app starts and works fine.
If I install the release apk and I try to start the app, the app doesn't start and I get this kind of messagge in Logcat:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: it.planner, PID: 29448
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:2054)
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:2077)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:678)
at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:632)
at it.planner.Home.mainMenu(Home.java:374)
at it.planner.Home.computeGeolocation(Home.java:487)
at it..planner.Home.access$100(Home.java:80)
at it.planner.Home$3$1.onLocationResult(Home.java:344)
at com.google.android.gms.internal.zzcff.zzu(Unknown Source:4)
at com.google.android.gms.common.api.internal.zzci.zzb(Unknown Source:8)
at com.google.android.gms.common.api.internal.zzcj.handleMessage(Unknown
Source:16)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7377)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963)
There is no possibility to select the mock location once the app is in release mode, so it doesn't want to start. I've been dealing with this problem for many days. I also tried with minifyEnabled false in the Gradle file but it doesn't work.
The gradle file is the following:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
debuggable true
}
}
sourceSets {
main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] }
debug {
manifest.srcFile 'src/main/AndroidManifest.xml'
}
}

This issue is probably because of the Fragment transaction was not committed using the proper API. try to find
transaction.commit();
and replace it with
transaction.commitAllowingStateLoss();
Some more discussion is here: https://github.com/OneBusAway/onebusaway-android/issues/529#issuecomment-224974339

Related

App crashes in release apk which run correctly in debug mode

I have tested my app in debug mode. I have made debuggable as true in release build type in build.gradle file. When I run and test it it gives me following error
2022-10-20 13:17:16.300 26285-26285/com.metamagics.patientsapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.metamagics.patientsapp, PID: 26285
java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List com.metamagics.pulsepatientsapp.d.h.a()' on a null object reference
at com.metamagics.pulsepatientsapp.fragments.a.V1(:487)
at com.metamagics.pulsepatientsapp.fragments.a$f.c(:1657)
at com.metamagics.pulsepatientsapp.utilities.b.b(:129)
at com.metamagics.pulsepatientsapp.utilities.b.onPostExecute(:10)
at android.os.AsyncTask.finish(AsyncTask.java:771)
at android.os.AsyncTask.access$900(AsyncTask.java:199)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8057)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:620)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1011)
I am not able to understand the issue, if anyone knows a better way to identify the error, I will be thankful.
If you debug a release build, it will still be minified according to your build.gradle file. Try to first set minifyEnabled = false for your release configuration. Probably the Stacktrace gives you the reason of your error. If not you might need to configure your proguard rules if minify is needed.

Android: Internal error in Cloud Firestore (24.0.2)

Iam using Firestore 24.0.2, and it was working well, but now i surprised that it is not working, and the app crash when opening MainActivity after Splash Activity.
I tried to remove some dependencies and the problem still exist.
So, After the app run:
First -> Splash Screen shown with some code from Firebase RemoteConfig, and it works well.
Second -> It moves to Main Activity which has Fragments that use Firestore, after less than one second from show Main Activity, the app crash, with java.lang.RuntimeException: Internal error in Cloud Firestore (24.0.2)
I've seen a lot of threads and questions on Stack Overflow, GitHub, and more sites, and no solution worked for me.
Full Crash Code:
java.lang.RuntimeException: Internal error in Cloud Firestore (24.0.2).
at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$3(AsyncQueue.java:539)
at com.google.firebase.firestore.util.AsyncQueue$$ExternalSyntheticLambda3.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8633)
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: android.database.sqlite.SQLiteException: not an error (code 0 SQLITE_OK[0])
at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor.lambda$executeAndReportResult$1(AsyncQueue.java:330)
at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$$ExternalSyntheticLambda0.run(Unknown Source:4)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(AsyncQueue.java:234)
at java.lang.Thread.run(Thread.java:923)
Caused by: android.database.sqlite.SQLiteException: not an error (code 0 SQLITE_OK[0])
at android.database.sqlite.SQLiteConnection.nativeRegisterLocalizedCollators(Native Method)
at android.database.sqlite.SQLiteConnection.setLocaleFromConfiguration(SQLiteConnection.java:647)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:387)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:226)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:737)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:284)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:251)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:1392)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:1337)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:980)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:444)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:387)
at com.google.firebase.firestore.local.SQLitePersistence.start(SQLitePersistence.java:138)
at com.google.firebase.firestore.core.ComponentProvider.initialize(ComponentProvider.java:139)
at com.google.firebase.firestore.core.FirestoreClient.initialize(FirestoreClient.java:272)
at com.google.firebase.firestore.core.FirestoreClient.lambda$new$0$com-google-firebase-firestore-core-FirestoreClient(FirestoreClient.java:109)
at com.google.firebase.firestore.core.FirestoreClient$$ExternalSyntheticLambda17.run(Unknown Source:8)
at com.google.firebase.firestore.util.AsyncQueue.lambda$enqueue$2(AsyncQueue.java:441)
at com.google.firebase.firestore.util.AsyncQueue$$ExternalSyntheticLambda6.call(Unknown Source:2)
at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor.lambda$executeAndReportResult$1(AsyncQueue.java:327)
at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$$ExternalSyntheticLambda0.run(Unknown Source:4) 
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462) 
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(AsyncQueue.java:234) 
at java.lang.Thread.run(Thread.java:923) 
I have tried many available answers like disable minify enable as false, which in not a right approach. Adding a line in pro-guard finally resolved the issue after 2 days of hard work.
-keep class io.grpc.** {*;}
I just had to revert to Firestore 24.0.0 and it stopped.
In my case, I forgot to put await on every Firebase.initializeApp().
await Firebase.initializeApp(name: 'noPersist', options: options);
await Firebase.initializeApp();
FirebaseDatabase.instance.setPersistenceEnabled(true);
As of today i ran into this issue and solved it by adding this little block of code to my andriod/app/build_gradle
release {
signingConfig signingConfigs.release
shrinkResources false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

Flutter Firestore doesn't retrieve any data in released android apk

I have tried to develop a flutter application that uses firestore and firebase auth for authentication.
In debug mode, when I test the application it retrieves data from firestore and show it. and firebase auth also work properly.
But in release mode, Firestore doesn't retrieve any data and shows an error given below.
but Firebase auth perfectly works in release mode application.
I catch the error in release mode by using android studio build variant feature.
Thank you for reading.
E/io.grpc.internal.S1: [Channel<1>: (firestore.googleapis.com)] Uncaught exception in the SynchronizationContext. Panic!
java.lang.ExceptionInInitializerError
at m1.j.Q(Unknown Source:22)
at io.grpc.internal.D.Q(Unknown Source:4)
at io.grpc.internal.k1.A(:3)
at io.grpc.internal.a1.run(:2)
at k1.t1.a(Unknown Source:24)
at k1.t1.execute(:2)
at io.grpc.internal.K1.b(Unknown Source:9)
at io.grpc.internal.u0.a(:10)
at io.grpc.internal.u0.run(Unknown Source:38)
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:919)
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: o1.a.values []
at java.lang.Enum.enumValues(Enum.java:270)
at java.lang.Enum.access$000(Enum.java:61)
at java.lang.Enum$1.create(Enum.java:277)
at java.lang.Enum$1.create(Enum.java:275)
at libcore.util.BasicLruCache.get(BasicLruCache.java:63)
at java.lang.Enum.getSharedConstants(Enum.java:289)
at java.lang.Class.getEnumConstantsShared(Class.java:2428)
at java.util.EnumMap.getKeyUniverse(EnumMap.java:755)
at java.util.EnumMap.<init>(EnumMap.java:138)
at m1.v.<clinit>(:1)
at m1.j.Q(Unknown Source:22) 
at io.grpc.internal.D.Q(Unknown Source:4) 
at io.grpc.internal.k1.A(:3) 
at io.grpc.internal.a1.run(:2) 
at k1.t1.a(Unknown Source:24) 
at k1.t1.execute(:2) 
at io.grpc.internal.K1.b(Unknown Source:9) 
at io.grpc.internal.u0.a(:10) 
at io.grpc.internal.u0.run(Unknown Source:38) 
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:919) 
Caused by: java.lang.NoSuchMethodException: o1.a.values []
at java.lang.Class.getMethod(Class.java:2072)
at java.lang.Class.getDeclaredMethod(Class.java:2050)
at java.lang.Enum.enumValues(Enum.java:267)
W/Firestore: (23.0.1) [Z]: (3a36b20) Stream closed with status: o1{code=INTERNAL, description=Panic! This is a bug!, cause=java.lang.ExceptionInInitializerError
at m1.j.Q(Unknown Source:22)
at io.grpc.internal.D.Q(Unknown Source:4)
at io.grpc.internal.k1.A(:3)
at io.grpc.internal.a1.run(:2)
at k1.t1.a(Unknown Source:24)
at k1.t1.execute(:2)
at io.grpc.internal.K1.b(Unknown Source:9)
at io.grpc.internal.u0.a(:10)
at io.grpc.internal.u0.run(Unknown Source:38)
This is a common error with Firestore. The problem is with the minifyEnabled and shrinkResources fields in android/app/build.gradle.
You should be able to solve this by changing your release build type in android/app/build.gradle as follows:
buildTypes {
...
release {
...
signingConfig signingConfigs.release
minifyEnabled false
shrinkResources false
}
}
Of course this is not an ideal "solution" as the app-size becomes larger. But the Firebase team says they can't help because we use flutter which isn't officially supported...
Here are related issues:
https://github.com/FirebaseExtended/flutterfire/discussions/5708#discussioncomment-925997
https://github.com/FirebaseExtended/flutterfire/issues/1412

java.lang.IncompatibleClassChangeError caused by R8 (AGP 7.0.0-beta02) [duplicate]

Tested Environment / Dependencies
Android Studio: Android Studio Arctic Fox Beta 2 and Bumblebee Canary 1
AGP: 7.1.0-alpha01
Firebase Analytics: com.google.firebase:firebase-analytics-ktx:19.0.0
Firebase Crashlytics: com.google.firebase:firebase-crashlytics-ktx:18.0.0
minifyEnabled: true
Proguard Config specifically for Firebase: None
What's happening
When I build my app with minifyEnabled = true and try to start the app, app crashes right after it launches with the following crash log:
2021-05-29 22:30:37.652 16541-16541/com.my.app.package.name E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.my.app.package.name, PID: 16541
java.lang.IncompatibleClassChangeError: Class j$.util.concurrent.i implements non-interface class e.a (declaration of 'j$.util.concurrent.i' appears in /data/app/~~xxxx==/com.my.app.package.name--xxxxxx==/base.apk!classes2.dex)
at com.google.firebase.components.x.<init>(:37)
at com.google.firebase.components.x.b(:44)
at com.google.firebase.components.n.t(:219)
at com.google.firebase.components.n.j(:138)
at com.google.firebase.components.n.<init>(:91)
at com.google.firebase.components.n.<init>(:45)
at com.google.firebase.components.n$b.e(:360)
at com.google.firebase.c.<init>(:427)
at com.google.firebase.c.p(:299)
at com.google.firebase.c.o(:267)
at com.google.firebase.c.n(:252)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(:51)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2388)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2358)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(:45)
at android.app.ActivityThread.installProvider(ActivityThread.java:7242)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6783)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6700)
at android.app.ActivityThread.access$1300(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7660)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Notes
Configuring minifyEnabled = false fixes the issue and app can start as expected.
Maybe it is related or dup of: java.lang.IncompatibleClassChangeError caused by R8 (AGP 7.0.0-beta02).
We had similar crashes in release since AGP 7.0.0-alpha12. The crashes are gone after updating the desugaring library to version 1.1.5.
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
}
More info: https://issuetracker.google.com/issues/189244205

paytm integeration release build crash

After integrating Paytm payments sdk, debug version is working properly but release build is crashing when getting the response from Paytm.
if minifyEnabled false means release build working fine, but must need minifyEnabled is true.
minifyEnabled true means com.pay.project.Paytm.PaytmWebview.a(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:104)
Error Log:
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.pay.project.android.test, PID: 23149 java.lang.NoSuchMethodError:
No static method wrap(Ljava/lang/Object;)Ljava/lang/Object; in class Lorg/b/c;
or its super classes (declaration of 'org.b.c' appears in
/data/app/com.pay.project.android.test-1/base.apk) at com.pay.project.Paytm.PaytmWebview.a(Unknown Source) `at android.os.Handler.handleCallback(Handler.java:822)`at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5774)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:681)
paytm gradel file changes to previous version of paytm, now it working fine.

Categories

Resources