Release apk android in flutter is crashing on start up - android

I think my issue is because of Cloudfirestore that I am using inside my application. Some devices crash and some not.( S7 samsung verizon android 8.0 crashed, A5 samsung android 6.0 did not crash...). I used logcat to get the logs that are causing the crash and this is the error:
java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev).
at com.google.firebase.firestore.obfuscated.zzgf.zzb(com.google.firebase:firebase-firestore##17.1.1:377)
at com.google.firebase.firestore.obfuscated.zzgk.run(com.google.firebase:firebase-firestore##17.1.1)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5302)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: io.grpc.ManagedChannelProvider$ProviderNotFoundException: No functional channel service provider found. Try adding a dependency on the grpc-okhttp or grpc-netty artifact
at com.google.firebase.firestore.obfuscated.zzgf.zza(com.google.firebase:firebase-firestore##17.1.1:288)
at com.google.firebase.firestore.obfuscated.zzgi.run(com.google.firebase:firebase-firestore##17.1.1)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:153)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:267)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at com.google.firebase.firestore.obfuscated.zzgf$zza.run(com.google.firebase:firebase-firestore##17.1.1:203)
at java.lang.Thread.run(Thread.java:856)
Caused by: io.grpc.ManagedChannelProvider$ProviderNotFoundException: No functional channel service provider found. Try adding a dependency on the grpc-okhttp or grpc-netty artifact
at io.grpc.ManagedChannelProvider.provider(ManagedChannelProvider.java:60)
at io.grpc.ManagedChannelBuilder.forTarget(ManagedChannelBuilder.java:70)
at com.google.firebase.firestore.obfuscated.zzfk.<init>(com.google.firebase:firebase-firestore##17.1.1:101)
at com.google.firebase.firestore.obfuscated.zzm.zza(com.google.firebase:firebase-firestore##17.1.1:1216)
at com.google.firebase.firestore.obfuscated.zzt.run(com.google.firebase:firebase-firestore##17.1.1)
at com.google.firebase.firestore.obfuscated.zzgf.zzc(com.google.firebase:firebase-firestore##17.1.1:309)
at com.google.firebase.firestore.obfuscated.zzgj.call(com.google.firebase:firebase-firestore##17.1.1)
at com.google.firebase.firestore.obfuscated.zzgf.zza(com.google.firebase:firebase-firestore##17.1.1:285)
at com.google.firebase.firestore.obfuscated.zzgi.run(com.google.firebase:firebase-firestore##17.1.1) 
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390) 
at java.util.concurrent.FutureTask.run(FutureTask.java:234) 
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:153) 
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:267) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 
at com.google.firebase.firestore.obfuscated.zzgf$zza.run(com.google.firebase:firebase-firestore##17.1.1:203) 
at java.lang.Thread.run(Thread.java:856) 
so how to resolve such an error in flutter ??

Had the same issue with some phones like Samsung S5. The app started crashing when I tried to open it. Here is a fix that worked for me:
defaultConfig {
...
multiDexEnabled true
ndk {
abiFilters 'x86', 'armeabi-v7a'
}
}
Had to add ndk in android/app/build.gradle file and it worked like a charm.
I hope this can help someone.

you should check first if you have installed the latest cloud_firestore package (0.8.2+3) in your pubspec.yaml
you can upgrade the google services under <yourapp>/android/build.gradle (current version 4.2.0). But be aware that you maybe need to upgrade the other plugins as well to the newest version there.

Related

Running google cloud speech api on Android 4.2

I have a problem running io.grpc:grpc-okhttp on Android 4.2 devices.
I have implemented SpeechClient with Credentials, for running Google cloud speech to text.
On Android 7.1 device I don't have a problem. The problems happen on Android 4.2
So in my starting gradle I had
implementation 'io.grpc:grpc-okhttp:1.35.0'
implementation 'io.grpc:grpc-android:1.35.0'
implementation 'com.google.cloud:google-cloud-speech:1.24.0'
Problems.
First problem was with TLS security for SSL (which is too old on Android 4.2). For this, I added dependency
implementation 'org.conscrypt:conscrypt-android:2.5.1'
and implemented in my DialogFragment (which is running the code)
Security.insertProviderAt(Conscrypt.newProvider(), 1)
After I implemented this, I am getting
Duplicate class org.conscrypt.AbstractConscryptEngine found in modules jetified-conscrypt-android-2.5.1-runtime (org.conscrypt:conscrypt-android:2.5.1) and jetified-conscrypt-openjdk-uber-2.2.1 (org.conscrypt:conscrypt-openjdk-uber:2.2.1)
issues (alot of duplicated classes)
So for fixing this, I added
configurations {
all {
exclude group: "org.conscrypt", module: "conscrypt-openjdk-uber"
}
}
Now I get this error, because com.google.api.client is using Standard.UTF-8 and my device is on Android 17.
com.google.api.gax.rpc.UnauthenticatedException: io.grpc.StatusRuntimeException: UNAUTHENTICATED: Failed computing credential metadata
at com.google.api.gax.rpc.ApiExceptionFactory.createException(ApiExceptionFactory.java:73)
at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:72)
at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:60)
at com.google.api.gax.grpc.ExceptionResponseObserver.onErrorImpl(ExceptionResponseObserver.java:82)
at com.google.api.gax.rpc.StateCheckingResponseObserver.onError(StateCheckingResponseObserver.java:86)
at com.google.api.gax.grpc.GrpcDirectStreamController$ResponseObserverAdapter.onClose(GrpcDirectStreamController.java:149)
at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:426)
at io.grpc.internal.ClientCallImpl.access$500(ClientCallImpl.java:66)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:689)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$900(ClientCallImpl.java:577)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:751)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:740)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:153)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:267)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
Caused by: io.grpc.StatusRuntimeException: UNAUTHENTICATED: Failed computing credential metadata
at io.grpc.Status.asRuntimeException(Status.java:533)
at com.google.api.gax.grpc.GrpcDirectStreamController$ResponseObserverAdapter.onClose(GrpcDirectStreamController.java:149) 
at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:426) 
at io.grpc.internal.ClientCallImpl.access$500(ClientCallImpl.java:66) 
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:689) 
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$900(ClientCallImpl.java:577) 
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:751) 
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:740) 
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) 
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123) 
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390) 
at java.util.concurrent.FutureTask.run(FutureTask.java:234) 
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:153) 
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:267) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 
at java.lang.Thread.run(Thread.java:856) 
Caused by: java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets
at com.google.api.client.util.StringUtils.getBytesUtf8(StringUtils.java:51)
at com.google.api.client.json.webtoken.JsonWebSignature.signUsingRsaSha256(JsonWebSignature.java:571)
at com.google.auth.oauth2.JwtCredentials.refresh(JwtCredentials.java:125)
at com.google.auth.oauth2.JwtCredentials.getRequestMetadata(JwtCredentials.java:163)
at com.google.auth.oauth2.ServiceAccountJwtAccessCredentials.getRequestMetadata(ServiceAccountJwtAccessCredentials.java:365)
at com.google.auth.Credentials.blockingGetToCallback(Credentials.java:112)
at com.google.auth.oauth2.ServiceAccountJwtAccessCredentials.getRequestMetadata(ServiceAccountJwtAccessCredentials.java:341)
at io.grpc.auth.GoogleAuthLibraryCallCredentials.applyRequestMetadata(GoogleAuthLibraryCallCredentials.java:110)
at io.grpc.CallCredentials2.applyRequestMetadata(CallCredentials2.java:58)
at io.grpc.internal.CallCredentialsApplyingTransportFactory$CallCredentialsApplyingTransport.newStream(CallCredentialsApplyingTransportFactory.java:108)
at io.grpc.internal.ForwardingConnectionClientTransport.newStream(ForwardingConnectionClientTransport.java:49)
at io.grpc.internal.InternalSubchannel$CallTracingTransport.newStream(InternalSubchannel.java:671)
at io.grpc.internal.DelayedClientTransport$PendingStream.createRealStream(DelayedClientTransport.java:353)
at io.grpc.internal.DelayedClientTransport$PendingStream.access$300(DelayedClientTransport.java:341)
Question:
How to resolve this issue and run Speech with "ApiStreamObserver?
I tried reverting back "io.grpc:grpc-" libraries to version 1.0 or something, but then I have other problems...
I have resolved this issue and commited example project on Github
https://github.com/DjToMeK27/CloudGoogleSpeechToText/tree/main
What I did in this project
Downloaded https://github.com/GoogleCloudPlatform/android-docs-samples/blob/master/README.md
Changed classes in project SpeechRecognitionClient in android-docs-samples-master\speech
Changed AudioRecord in AudoEmitter.kt to support API 16
Imported org.conscrypt:conscrypt-android:2.5.1 library
Had to exclude group org.conscrypt from google-cloud-speech (in build.gradle)
Added init { Security.insertProviderAt(Conscrypt.newProvider(), 1) } For Android 4.1 to run proper TLS for GRC to work
I downloaded https://github.com/googleapis project
Changed all StandardCharsets found in google-http-client to Charset.forName())
And also changed some tests to work
https://imgur.com/a/iU7yjCZ (files changes)
I have build this project and added .jar files, which I included here
And now it works!

Unable to instantiate application - java.lang.ClassNotFoundException: Didn't find class "com.xxxxx.App" on path: /data/app/com.xxxxx-1.apk

This is the error everytime I run the app:
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate application com.xxxxx.App: java.lang.ClassNotFoundException: Didn't find class "com.xxxxx.App" on path: /data/app/com.xxxxx-1.apk
at android.app.LoadedApk.makeApplication(LoadedApk.java:509)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4657)
at android.app.ActivityThread.access$1400(ActivityThread.java:159)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1376)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5419)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.xxxxx.App" on path: /data/app/com.xxxxx-1.apk
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:64)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newApplication(Instrumentation.java:992)
at android.app.LoadedApk.makeApplication(LoadedApk.java:504)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4657) 
at android.app.ActivityThread.access$1400(ActivityThread.java:159) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1376) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:176) 
at android.app.ActivityThread.main(ActivityThread.java:5419) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:525) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) 
at dalvik.system.NativeStart.main(Native Method)
Here some info:
JavaVersion.VERSION_1_8 (I cannot use 1.7 because of a library)
buildToolsVersion '24.0.0'
compileSdkVersion & target 24 (also tried 23)
gradle 2.2.0-alpha4 (also tried with 2.1.0)
I have instant run disabled.
I have a class named App that extends Application, so in AndroidManifest.xml I have <application android:name="com.xxxxx.App"
Please don't mark this question as duplicate, because I have already tried all the solutions given, but I cannot get rid of this error.
 
I was having the same error and just cleaning the project solve it for me.
it seems a bug in the new version of android studio.
remove the app from your mobile phone then build => clean project and try installing again
Have you tried running the app on another device/emulator?
I experienced this problem once because I was the 2nd user on the device that I was trying to run it on. If that's the case, you will have to switch to the primary user(owner) every time you wish to run your app.
I was having the same issue, then tried creating the same application class in java instead of kotlin and it worked.

What could be causing a ClassNotFoundException?

So I've been working on an app lately which runs fine on most devices. However, sometimes the app crashes at start up with the following error:
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.mypackage.app/com.mypackage.app.activities.MainPager}:
java.lang.ClassNotFoundException: com.mypackage.app.activities.MainPager
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1995)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
at android.app.ActivityThread.access$600(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:4787)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:115)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException:
com.mypackage.app.activities.MainPager
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1986)
... 12 more
I get that this is because it can't find the class called MainPager. But how is that even possible? I mean, the class should be there.. I put it there myself :) . Why on earth is it not finding it?
EDIT: I think the cause may be that in my manifest I have android:package="com.mypackage.app" defined, but that my launch activity is in the package com.mypackage.app.activities. Currently testing this theory. Still weird that it only happens on some devices, though.
This solution won't work, since I then can't update the APK in Google Play (has to be the same package name in the manifest).
Since ADT update to revision 22 (May 2013) you have to check "Android Private Libraries" check box in Project -> Properties -> Java Build Path -> Order and Export in Eclipse for your older projects to get rid of this exception ...
in the manifest you add Activity name like this
android:name=".activities.MainPager"
because you have given package name
android:package="com.mypackage.app"
Now I am using ART runtime on Nexus 5, and I am getting ClassNotFound for some apps.
You can safely ignore those if that's the case for your users.

Classnotfound exception for working app

I have a strange issue.I developed an android application with scan functionality.I reused some zxing code code for the scanning section. My app is working fine for all the device and emulater too.But after I uploaded it in market I am getting error on scan portion.My error report is
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:2191)
at android.view.View.performClick(View.java:2532)
at android.view.View$PerformClick.run(View.java:9291)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4293)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at android.view.View$1.onClick(View.java:2186)
... 11 more
Caused by: java.lang.ExceptionInInitializerError
at com.imotiva.Menu1.points(Menu1.java:46)
... 14 more
Caused by: java.lang.NoClassDefFoundError: com.qr.decoding.ResultMetadataType
at com.qr.scanning.CaptureActivity.<clinit>(CaptureActivity.java:92)
... 15 more
Still my code code is working in device but the same app in the market don't. Please help me friends...
At last I found the solution for my problem.gtumca-MAC's solution Android update 17 seems incompatible with external Jars worked for me.Created one folder named libs and add my core.jar .Now it's working fine.Thanks all.

NullPointerException "at com.jayway.android.robotium.solo.ViewFetcher.getNonDecorViews"

I am facing this issue in Junit. I have created an Android application that refers the Library project.
I have written an Android Test Project that runs on the Android application project.
I get the following error while running the test cases:
java.lang.NullPointerException
at com.jayway.android.robotium.solo.ViewFetcher.getNonDecorViews(ViewFetcher.java:188)
at com.jayway.android.robotium.solo.ViewFetcher.getAllViews(ViewFetcher.java:112)
at com.jayway.android.robotium.solo.Waiter.clickableItemsExist(Waiter.java:164)
at com.jayway.android.robotium.solo.Waiter.waitForClickableItems(Waiter.java:150)
at com.jayway.android.robotium.solo.Solo.clickOnView(Solo.java:787)
at com.mycompany.myproject.test.LoginActivityInstrumentation.enterSessionPin(LoginActivityInstrumentation.java:149)
com.mycompany.myproject.test.LoginActivityTest.testEnterButtonCase1(LoginActivityTest.java:174)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:186)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:537)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1551)
Can anyone help ?
It got fixed after updating robotium.jar to 3.2.1

Categories

Resources