I got this error in my RN application in Android:
06-06 16:37:54.455 7506-7569/system_process E/AudioTrack: Could not
get audio output for session 729, stream type -1, usage 13, sample
rate 48000, format 0x1, channel mask 0x3, flags 0x4 06-06 16:37:54.455
7506-7569/system_process E/SoundPool: Error creating AudioTrack 06-06
16:37:54.924 1286-1286/? E/EGL_emulation: tid 1286:
eglCreateSyncKHR(1669): error 0x3004 (EGL_BAD_ATTRIBUTE) 06-06
16:37:55.190 11821-11894/com.efiat_rn E/unknown:ReactNative: Exception
in native call
java.lang.ClassCastException: com.facebook.react.bridge.ReadableNativeMap cannot be cast to
java.lang.String
at com.facebook.react.bridge.ReadableNativeMap.getString(ReadableNativeMap.java:168)
at com.facebook.react.modules.dialog.DialogModule.showAlert(DialogModule.java:232)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:160)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop(Looper.java:154)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:761) 06-06 16:37:55.191 11821-11894/com.efiat_rn E/unknown:ReactNative: Exception in native
call
java.lang.ClassCastException: com.facebook.react.bridge.ReadableNativeMap cannot be cast to
java.lang.String
at com.facebook.react.bridge.ReadableNativeMap.getString(ReadableNativeMap.java:168)
at com.facebook.react.modules.dialog.DialogModule.showAlert(DialogModule.java:232)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:160)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop(Looper.java:154)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:761)
It runs perfectly fine on iOS version. It don't show me which JS I do wrong. and I have no clue or ideas on how to fix it. It prompts when I launch the application, when I dismiss the error message, I can see a half-load application, but not clickable. Is there any ideas on how can I start the debugging? Thanks.
In ReactNative you are calling a method of the native bridge which requires String parameters. But what you are actually sending is JsonObject.
Example,
const data = {message: "hello"}; // Consider this as your data
if you send this to the bridge, it will create a NativeArray and send it to native layer (But your layer's method expects String).
Now you have to convert the object to String and send it to the native layer
const strData = JSON.stringify(data);
Now send the strData to the native layer
(Comment below if you need more details or you can tell your error
more clearly to get some clear answer)
Related
Our application receives the client's request through AIDL, then executes a processing flow, and finally returns the processing result to the client. When I performed a stress test on the application, I found that the following exception would be thrown every time the complete process was executed about 400 times.
The crash log is:
11-05-06-20-59.583 E CrashHandler.java[101](handleExceptions)[1]Exception: java.lang.RuntimeException: Adding window failed
at android.view.ViewRootImpl.setView(ViewRootImpl.java:652)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:342)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:94)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3518)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2733)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Caused by: android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:623)
at android.view.IWindowSession$Stub$Proxy.addToDisplay(IWindowSession.java:828)
at android.view.ViewRootImpl.setView(ViewRootImpl.java:640)
... 12 more
Through the analysis of the memory, it was found that the Handler object was repeatedly created when the AIDL command was initiated, and the Handler object was not cleaned up in time, resulting in a memory leak.
I have got a problem with sending and receiving SMS from my mobile (Samsung Galaxy S3) which runs LineageOS 14.1-20170405-NIGHTLY-i9300.
Since a few weeks I can't either send or receive messages with the normal android messaging application and also with SMS applications from the Google Play Store.
I really don't know what to do and it seems like nobody else has got this problem...
The logcat says the following after I tried to send a message:
04-08 13:58:50.229 24428-24428/com.android.messaging I/MessagingApp: UI initiated message sending in conversation 3
04-08 13:58:50.365 24428-24635/com.android.messaging I/MessagingAppDataModel: InsertNewMessageAction: inserting new message
04-08 13:58:50.525 24428-24635/com.android.messaging E/MessagingApp: Uncaught exception in background thread Thread[IntentService[ActionService],5,main]
04-08 13:58:50.526 24428-24635/com.android.messaging E/MessagingApp: java.lang.NullPointerException: Uri must not be null
at android.os.Parcel.readException(Parcel.java:1690)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.insert(ContentProviderNative.java:476)
at android.content.ContentResolver.insert(ContentResolver.java:1279)
at com.android.messaging.sms.i.ahJ(SourceFile:879)
at com.android.messaging.sms.i.ahz(SourceFile:888)
at com.android.messaging.datamodel.action.InsertNewMessageAction.KA(SourceFile:378)
at com.android.messaging.datamodel.action.InsertNewMessageAction.IV(SourceFile:171)
at com.android.messaging.datamodel.action.ActionServiceImpl.Ji(SourceFile:305)
at com.android.messaging.datamodel.action.ActionServiceImpl.onHandleIntent(SourceFile:267)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:68)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)
04-08 13:58:50.545 24428-24428/com.android.messaging E/AndroidRuntime: FATAL EXCEPTION: IntentService[ActionService]
Process: com.android.messaging, PID: 24428
java.lang.NullPointerException: Uri must not be null
at android.os.Parcel.readException(Parcel.java:1690)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.insert(ContentProviderNative.java:476)
at android.content.ContentResolver.insert(ContentResolver.java:1279)
at com.android.messaging.sms.i.ahJ(SourceFile:879)
at com.android.messaging.sms.i.ahz(SourceFile:888)
at com.android.messaging.datamodel.action.InsertNewMessageAction.KA(SourceFile:378)
at com.android.messaging.datamodel.action.InsertNewMessageAction.IV(SourceFile:171)
at com.android.messaging.datamodel.action.ActionServiceImpl.Ji(SourceFile:305)
at com.android.messaging.datamodel.action.ActionServiceImpl.onHandleIntent(SourceFile:267)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:68)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)
Does anybody know what I have to do now?
I really have no idea...
Thank you in advance!
This question already has answers here:
NetworkOnMainThreadException [duplicate]
(5 answers)
Closed 6 years ago.
My goal is to convert an array of floats to a string array and send it to a remote server in my house via a POST request. I am not using sockets.
URL url = new URL("http:// (destination of the remote server) : (port)");
URLConnection connection = url.openConnection();
This is how I am writing my getInputStream() and getOutputStream method and every time I run my code my activity crashes.
OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
Everything works but my activity comes to getOutputStream() and it crashes. I tried commenting out the getOutputStream() part then it came to connection.getInputStream() and crashed.
What could be the reason why this isn't working?
StackTrace:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hfad.viscosity/com.hfad.viscosity.ProcessData}: android.os.NetworkOnMainThreadException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2434)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
at android.app.ActivityThread.access$900(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5525)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
Caused by: android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1273)
at java.net.InetAddress.lookupHostByName(InetAddress.java:436)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
at java.net.InetAddress.getAllByName(InetAddress.java:215)
at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:188)
at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:157)
at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:100)
at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:357)
at com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:340)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:433)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:114)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:245)
at com.hfad.viscosity.ProcessData.onCreate(ProcessData.java:110)
at android.app.Activity.performCreate(Activity.java:6272)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
at android.app.ActivityThread.access$900(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5525)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
It appears that you are attempting network activities on the main UI thread for the Activity instead of a background thread. It is required for any activity that involves blocking I/O or heavy processing including network activity to happen on a background thread. You would hence want to use the AsyncTask functionality to achieve this use case.
Refer to this SO question for an example
The second thing is that to perform Internet access from your app you need to provide Internet access permissions to your app. Refer to this other SO question that should help you on how to go about providing this permission.
If you are facing any problems even after performing the above steps, then it is recommended that you post your entire source code (if possible or an equivalent example) so that more folks can help you out.
I know that TransactionTooLargeException occurs when there is a large amount of data being transferred between services in the system. Usually, I would have some kind of control if I were to transfer large amount of data, but in this case, when I'm appying a wallpaper, I don't have that amount of control.
I'm applying a wallpaper by first cropping it with android-image-cropper, and then applying it by
WallpaperManager.setBitmap(bitmap);
...in a separate thread, to avoid overloading the UI thread. Now, when I press "apply wallpaper", and wait for some time, and then return to the homescreen, it works flawlessly, but when I apply the wallpaper and then immediately return to the homescreen, I get the alert that the app has crashed, along with this log:
07-31 18:50:41.611 32720-32720/elementary.elementarywallpapers E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 16385936)
07-31 18:50:41.614 32720-32720/elementary.elementarywallpapers D/AndroidRuntime: Shutting down VM
07-31 18:50:41.621 32720-32720/elementary.elementarywallpapers E/AndroidRuntime: FATAL EXCEPTION: main
Process: elementary.elementarywallpapers, PID: 32720
java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 16385936 bytes
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3752)
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: android.os.TransactionTooLargeException: data parcel size 16385936 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:615)
at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3606)
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3744)
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)
How can I fix this?
I have static values that are deleted after my application is a long time in the background or after opening many different apps, causing that my app crashes.
I think that Android OS is removing data from my app or "killing" it.
Is there any way to keep my app's data to avoid this problem?
NOTE: I can't save this values on SharedPreferences or in a database because there are many HashMaps and ArrayLists, is too much information.
It is necessary that these values are static because I need them available in many classes o my app in any time.
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.proyect/com.proyect.gui.ActivityMenu}: java.lang.NullPointerException: println needs a message
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2266)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2316)
at android.app.ActivityThread.access$600(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1298)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:5225)
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:741)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException: println needs a message
at android.util.Log.println_native(Native Method)
at android.util.Log.v(Log.java:117)
at com.proyect.gui.FragmentMenu.onActivityCreated(FragmentMenu.java:145)
at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1983)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1092)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1234)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2046)
at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:174)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:597)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
at android.app.Activity.performStart(Activity.java:5143)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2239)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2316)
at android.app.ActivityThread.access$600(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1298)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:5225)
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:741)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
Change this:
Log.v("errorTag", e.getMessage());
To this:
String error = e.getMessage();
if(error == null)
error = "It's crashed here";
Log.v("errorTag", error );
OR SIMPLER
Log.v("errorTag", e );
The point is that e.getMessage() is null. So, always check if e.getMessage() is not null before print it