Android Question App crash on Android L

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

Just got myself a brand new Nexus5 and installed Android L on it so I can test my app on it.

Just noticed my app crashes when using SSL sockets.

The error that shows is the following:

B4X:
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:b4a.example
Connected - SSL Socket
android.os.NetworkOnMainThreadException
 at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1145)
 at com.android.org.conscrypt.OpenSSLSocketImpl.shutdownAndFreeSslNative(OpenSSLSocketImpl.java:1102)
 at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:398)
 at com.android.org.conscrypt.OpenSSLSocketImpl.waitForHandshake(OpenSSLSocketImpl.java:604)
 at com.android.org.conscrypt.OpenSSLSocketImpl.getInputStream(OpenSSLSocketImpl.java:566)
 at elbarto.android.SocketSSL.getInputStream(SocketSSL.java:136)
 at b4a.example.main._my_ssl_socket_connected(main.java:410)
 at java.lang.reflect.Method.invoke(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:372)
 at anywheresoftware.b4a.BA.raiseEvent2(BA.java:174)
 at anywheresoftware.b4a.BA$3.run(BA.java:319)
 at android.os.Handler.handleCallback(Handler.java:738)
 at android.os.Handler.dispatchMessage(Handler.java:95)
 at android.os.Looper.loop(Looper.java:135)
 at android.app.ActivityThread.main(ActivityThread.java:5070)
 at java.lang.reflect.Method.invoke(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:372)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:836)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:631)
android.os.NetworkOnMainThreadException
** Activity (main) Resume **

It looks like it connects but soon as it connects it comes up with a error.

Anyone know how to fix this?

I really need this working otherwise my whole app is not going to work.
This is working fine on Android 4.4 (and below)

The code I am using is attached.
 

Attachments

  • ssl_socket_example.zip
    17.5 KB · Views: 278

aaronk

Well-Known Member
Licensed User
Longtime User
Now doing this as you suggested (well I think I am) but now got a different error:

B4X:
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:b4a.example
Connected - SSL Socket
java.net.SocketException: Socket is closed
at com.android.org.conscrypt.OpenSSLSocketImpl.checkOpen(OpenSSLSocketImpl.java:248)
at com.android.org.conscrypt.OpenSSLSocketImpl.getInputStream(OpenSSLSocketImpl.java:548)
at elbarto.android.SocketSSL.getInputStream(SocketSSL.java:136)
at b4a.example.main._threadsub1(main.java:502)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.agraham.threading.Threading$1.run(Threading.java:216)
at java.lang.Thread.run(Thread.java:818)
Thread1 Ended
** Activity (main) Pause, UserClosed = true **
** Activity (main) Resume **

Attached is the project.

(If this is a bug with the library, are you able to help me out with a SSL Socket Library that does work correclty. I have posted requests in the wishlist forum and the Libraries developers questions forum but not no reply, and I really need to be able to get this working since my whole app relies on it. Please :) )
 

Attachments

  • ssl_socket_example_updated.zip
    6.6 KB · Views: 277
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
Check the unfiltered logs for any relevant message.
How do I do that?

By the way, the code in post 1 and post 3 both work fine on Android 4.4 (and below) and only getting the issues on Android L
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
On the IDE, on the bottom right side of the screen, click on the tab labeled LOGS and UNCHECK the FILTER box.
Thanks for confirming the location of that filter checkbox..

I ran the same code from post 3 with the filter checkbox un-ticked and here is the log:
(don't think it has helped any)

B4X:
Installing file.
** Activity (main) Pause, UserClosed = false **
[0,anywheresoftware.b4a.b4abridge.main]
PackageAdded: package:b4a.example
Connected - SSL Socket
java.net.SocketException: Socket is closed
 at com.android.org.conscrypt.OpenSSLSocketImpl.checkOpen(OpenSSLSocketImpl.java:248)
 at com.android.org.conscrypt.OpenSSLSocketImpl.getInputStream(OpenSSLSocketImpl.java:548)
 at elbarto.android.SocketSSL.getInputStream(SocketSSL.java:136)
 at b4a.example.main._threadsub1(main.java:502)
 at java.lang.reflect.Method.invoke(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:372)
 at anywheresoftware.b4a.agraham.threading.Threading$1.run(Threading.java:216)
 at java.lang.Thread.run(Thread.java:818)
Thread1 Ended
** Activity (main) Pause, UserClosed = true **
[0,anywheresoftware.b4a.b4abridge.main]
** Activity (main) Resume **
Setting install_non_market_apps has moved from android.provider.Settings.Global to android.provider.Settings.Secure, returning read-only value.
 
Upvote 0
Top