I am trying to generate a signed apk of my first react native app I followed the steps in the official site of react native
I tried this command cd android && gradlew assembleRelease and the apk is generated successfully.
but when I am trying to test this apk on my real device using cd android && gradlew installRelease , the app crashes although it works as expected on genymotion emulator.
Am I missing something ?
Any help is appreciated.
Thanks in advance
Update :
I can't debug on my device because I am always getting the red screen says Unable to download JS bundle although I had done all what is mentioned on the official website about running on the device
logcat:
03-15 16:23:13.504 24331-24331/com.kora E/ViewRootImpl: sendUserActionEvent() mView == null
03-15 16:23:13.939 24331-24359/com.kora E/unknown:React: Unable to download JS bundle
java.net.ConnectException: failed to connect to /192.168.1.6 (port 8081) after 5000ms: isConnected failed: ECONNREFUSED (Connection refused)
at libcore.io.IoBridge.isConnected(IoBridge.java:223)
at libcore.io.IoBridge.connectErrno(IoBridge.java:161)
at libcore.io.IoBridge.connect(IoBridge.java:112)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
at java.net.Socket.connect(Socket.java:843)
at com.squareup.okhttp.internal.Platform$Android.connectSocket(Platform.java:190)
at com.squareup.okhttp.Connection.connectSocket(Connection.java:196)
at com.squareup.okhttp.Connection.connect(Connection.java:172)
at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:367)
at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128)
at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328)
at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:245)
at com.squareup.okhttp.Call.getResponse(Call.java:267)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:224)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:195)
at com.squareup.okhttp.Call.access$100(Call.java:34)
at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:162)
at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: libcore.io.ErrnoException: isConnected failed: ECONNREFUSED (Connection refused)
at libcore.io.IoBridge.isConnected(IoBridge.java:208)
at libcore.io.IoBridge.connectErrno(IoBridge.java:161)
at libcore.io.IoBridge.connect(IoBridge.java:112)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
at java.net.Socket.connect(Socket.java:843)
at com.squareup.okhttp.internal.Platform$Android.connectSocket(Platform.java:190)
at com.squareup.okhttp.Connection.connectSocket(Connection.java:196)
at com.squareup.okhttp.Connection.connect(Connection.java:172)
at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:367)
at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128)
at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328)
at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:245)
at com.squareup.okhttp.Call.getResponse(Call.java:267)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:224)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:195)
at com.squareup.okhttp.Call.access$100(Call.java:34)
at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:162)
at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
03-15 16:23:13.944 24331-24331/com.kora E/ViewRootImpl: sendUserActionEvent() mView == null
Thanks to #G. Hamaide for his answer , It worked for me but with a single addition in buildTypes in app/build.gradle, which is adding this line signingConfig signingConfigs.release as mentioned in the official documentation.
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
That's plus what #G. Hamaide mentioned in his answer which is mentioned above.
Change this :
def enableProguardInReleaseBuilds = true
to this :
def enableProguardInReleaseBuilds = false
Then run the steps again to create you APK.
Related
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
Application getting crashed on enabling minifyEnabled true. When I make it false application starts working fine. Do I need to add something to my pro-guard file? I am not able to figure out what is causing an application to crash.
Here is the Gradle code:
debug {
manifestPlaceholders = [crashlyticsApiKey: '', mapApiKey: '']
// Enables code shrinking, obfuscation, and optimization for only
debuggable true
// your project's release build type.
minifyEnabled true
// Enables resource shrinking, which is performed by the
// Android Gradle plugin.
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
buildConfigField "String", "BASE_URL", '"http://"'
signingConfig signingConfigs.debug
}
Logcat Output:
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ExceptionInInitializerError
at l.b.g.f$a.<init>(:372)
at l.b.g.f.<init>(:19)
at l.b.h.m.a(:32)
at l.b.h.m.b(:42)
at l.b.h.b.b(:56)
at l.b.h.g.a(:32)
at l.b.f.a.a(:135)
at l.b.f.b$d.f(:747)
at l.b.f.b.b(:250)
at d.k.a.i.g.a(:36)
at d.k.a.i.g.doInBackground(:17)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.IllegalStateException: Could not read resource entities-xhtml.properties. Make sure you copy resources for l.b.g.i
at l.b.g.i.b(:301)
at l.b.g.i.a(:25)
at l.b.g.i$b.<init>(:53)
at l.b.g.i$b.<clinit>(:34)
at l.b.g.f$a.<init>(:372)
at l.b.g.f.<init>(:19)
at l.b.h.m.a(:32)
at l.b.h.m.b(:42)
at l.b.h.b.b(:56)
at l.b.h.g.a(:32)
at l.b.f.a.a(:135)
at l.b.f.b$d.f(:747)
at l.b.f.b.b(:250)
at d.k.a.i.g.a(:36)
at d.k.a.i.g.doInBackground(:17)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
02-10 15:19:58.687 17254-20516/? E/cjle: *~*~*~ Channel {0} was not shutdown properly!!! ~*~*~*
Make sure to call shutdown()/shutdownNow() and wait until awaitTermination() returns true.
02-10 15:20:25.416 17254-28037/? E/WakeLock: GCM_HB_ALARM release without a matched acquire!
Please let know what is wrong in my code.
Thanks
The error stack indicates this:
Caused by: java.lang.IllegalStateException: Could not read resource entities-xhtml.properties. Make sure you copy resources for l.b.g.i
I think this is because the resource/class l.b.g.i is excluded by ProGuard. You may want to use mappings.txt file (that contains mapping between actual class/method name and its random one generated by proGuard) to decode actual resource name and then force Proguard to keep it, something like this example https://stackoverflow.com/a/5866755/1992013 Hope this helps !
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.
Recently I see an exception in my log that fabric (Beta) tries to check for updates and this is the error:
E/Beta: Error while checking for updates from null
io.fabric.sdk.android.services.network.HttpRequest$HttpRequestException: java.net.MalformedURLException: Protocol not found: null?instance=
I don't know why fabric tries to check for updates with a null URL, but I really want to remove that error.
Verbose stack trace:
E/Beta: Error while checking for updates from null
io.fabric.sdk.android.services.network.HttpRequest$HttpRequestException: java.net.MalformedURLException: Protocol not found: null?instance=7f856ab5-12f8-4723-9e84-569dab8e9760&build_version=1030300&display_version=1.3.3&source=3
at io.fabric.sdk.android.services.network.HttpRequest.encode(HttpRequest.java:722)
at io.fabric.sdk.android.services.network.HttpRequest.get(HttpRequest.java:865)
at io.fabric.sdk.android.services.network.DefaultHttpRequestFactory.buildHttpRequest(DefaultHttpRequestFactory.java:85)
at io.fabric.sdk.android.services.common.AbstractSpiCall.getHttpRequest(AbstractSpiCall.java:137)
at com.crashlytics.android.beta.CheckForUpdatesRequest.invoke(CheckForUpdatesRequest.java:48)
at com.crashlytics.android.beta.AbstractCheckForUpdatesController.performUpdateCheck(AbstractCheckForUpdatesController.java:166)
at com.crashlytics.android.beta.AbstractCheckForUpdatesController.checkForUpdates(AbstractCheckForUpdatesController.java:139)
at com.crashlytics.android.beta.AbstractCheckForUpdatesController.initialize(AbstractCheckForUpdatesController.java:91)
at com.crashlytics.android.beta.Beta.doInBackground(Beta.java:78)
at com.crashlytics.android.beta.Beta.doInBackground(Beta.java:30)
at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:63)
at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:28)
at io.fabric.sdk.android.services.concurrency.AsyncTask$2.call(AsyncTask.java:311)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.net.MalformedURLException: Protocol not found: null?instance=7f856ab5-12f8-4723-9e84-569dab8e9760&build_version=1030300&display_version=1.3.3&source=3
at java.net.URL.<init>(URL.java:176)
at java.net.URL.<init>(URL.java:125)
at io.fabric.sdk.android.services.network.HttpRequest.encode(HttpRequest.java:720)
at io.fabric.sdk.android.services.network.HttpRequest.get(HttpRequest.java:865)
at io.fabric.sdk.android.services.network.DefaultHttpRequestFactory.buildHttpRequest(DefaultHttpRequestFactory.java:85)
at io.fabric.sdk.android.services.common.AbstractSpiCall.getHttpRequest(AbstractSpiCall.java:137)
at com.crashlytics.android.beta.CheckForUpdatesRequest.invoke(CheckForUpdatesRequest.java:48)
at com.crashlytics.android.beta.AbstractCheckForUpdatesController.performUpdateCheck(AbstractCheckForUpdatesController.java:166)
at com.crashlytics.android.beta.AbstractCheckForUpdatesController.checkForUpdates(AbstractCheckForUpdatesController.java:139)
at com.crashlytics.android.beta.AbstractCheckForUpdatesController.initialize(AbstractCheckForUpdatesController.java:91)
at com.crashlytics.android.beta.Beta.doInBackground(Beta.java:78)
at com.crashlytics.android.beta.Beta.doInBackground(Beta.java:30)
at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:63)
at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:28)
at io.fabric.sdk.android.services.concurrency.AsyncTask$2.call(AsyncTask.java:311)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
I solved a lot of errors logs and the exception above by updating the crashlytics library version.
I also have solved this issue updating Crashlytics version in /app/build.gradle file.
I leave here the code of the fix for convenienece:
dependencies {
compile('com.crashlytics.sdk.android:crashlytics:2.9.4#aar') {
transitive = true;
}
}
guys.I got a crash becasue of "java.io.FileNotFoundException: res/drawable-xhdpi-v4/component_tip_loading1.png".
But I unziped my apk and found the resource is existed.
And my build.gradle set minifyEnabled is true, but not set the shrinkResources.
Thanks for any advice.
Caused by: java.io.FileNotFoundException: res/drawable-xhdpi-v4/component_tip_loading1.png
at android.content.res.AssetManager.openNonAssetNative(Native Method)
at android.content.res.AssetManager.openNonAsset(AssetManager.java:405)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2443)