Android Question Starter - After Clean, First Run Crashes Almost Always

mmieher

Active Member
Licensed User
Longtime User
This is been going on for years. Finally decided to post it. I must have something set up wrong (since 2012).

After cleaning a project, the first run almost always ends in the following after the device displays the view loaded to root, the IDE stops, then ...
B4X:
java.lang.RuntimeException: Unable to create service com.marcsmart.aatimer.starter: java.lang.RuntimeException: java.net.SocketException: Socket closed
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4204)
    at android.app.ActivityThread.access$1500(ActivityThread.java:237)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:223)
    at android.app.ActivityThread.main(ActivityThread.java:7656)
    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)
Caused by: java.lang.RuntimeException: java.net.SocketException: Socket closed
    at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:164)
    at anywheresoftware.b4a.shell.Shell.start(Shell.java:102)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:92)
    at com.marcsmart.aatimer.starter.onCreate(starter.java:34)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4192)
    ... 8 more
Caused by: java.net.SocketException: Socket closed
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.socketRead(SocketInputStream.java:119)
    at java.net.SocketInputStream.read(SocketInputStream.java:176)
    at java.net.SocketInputStream.read(SocketInputStream.java:144)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:248)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:288)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:347)
    at java.io.DataInputStream.readFully(DataInputStream.java:198)
    at java.io.DataInputStream.readInt(DataInputStream.java:389)
    at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:136)
    ... 12 more

Nothing else in log. Unfiltered has volumes of crap in it that only The Erels understand. What socket is it talking about?

I immediately run again (no Clean) and all is fine. Happens in multiple projects (but I clone most at first) and on emulators and real devices.

There is basically nothing in Starter (yet) except the default template stuff.

I think this is a symptom of a more serious illness.
 

MicroDrie

Well-Known Member
Licensed User
Maybe the socket error is the result of an abrupt termination of the connection to B4A Bridge. I use an old telephone with little free memory so I use the same program name. Now I first de-install the B4A programs first, then I clean only the B4A Bridge memory and restart B4A bridge, clean up the project and re-connect B4A bridge and re-run the B4A project and solve any if exist problem.
 
Upvote 0

mmieher

Active Member
Licensed User
Longtime User
Maybe the socket error is the result of an abrupt termination of the connection to B4A Bridge. I use an old telephone with little free memory so I use the same program name. Now I first de-install the B4A programs first, then I clean only the B4A Bridge memory and restart B4A bridge, clean up the project and re-connect B4A bridge and re-run the B4A project and solve any if exist problem.
Thank you. It happens on the emulator too, so I think it is something to do with the Debooger having trouble connecting.
 
Upvote 0

mmieher

Active Member
Licensed User
Longtime User
It is difficult to say why it happens. Does it happen if you create a new project?
I think so. I usually clone something else so am not sure.

It has something to do with "Starter". I can remove Starter, make another service called almost anything else, manually Start it, and all is well. Even if Starter only consists of what is in the original template, which is essentially nothing.
 
Upvote 0

mmieher

Active Member
Licensed User
Longtime User
After removing Starter from the project altogether, I get this about fifty percent of the time when running in debug mode.
Device (emulator or real thing) shows the B4XPages main layout, side, title and navigation bars, then crash.

This is the complete unfiltered log.

java.lang.RuntimeException: java.io.EOFException
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:164)
at anywheresoftware.b4a.shell.Shell.start(Shell.java:102)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:92)
at com.marcsmart.aatimer.main.afterFirstLayout(main.java:97)
at com.marcsmart.aatimer.main.access$000(main.java:17)
at com.marcsmart.aatimer.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
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)
Caused by: java.io.EOFException
at java.io.DataInputStream.readFully(DataInputStream.java:200)
at java.io.DataInputStream.readInt(DataInputStream.java:389)
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:136)
... 12 more


I think perhaps something is wrong with the Manifest, which is an abomination of copy/paste from the forum:
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="30"/>
<supports-screens android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true" 
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
''CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.

'    -----------------------------------------------------------------------------------------------------------
'    theme shit
'    -----------------------------------------------------------------------------------------------------------
SetApplicationAttribute(android:theme, "@style/LightTheme")
CreateResource(values, colors.xml,
<resources>
   <color name="actionbar">#ff70B5D6</color>
   <color name="statusbar">#ff000000</color>
   <color name="textColorPrimary">#FF696969</color>
   <color name="navigationBar">#ff70B5D6</color>
</resources>
)
CreateResource(values-v20, theme.xml,
<resources>
    <style name="LightTheme" parent="@android:style/Theme.Material.Light">
        <item name="android:colorPrimary">@color/actionbar</item>
        <item name="android:colorPrimaryDark">@color/statusbar</item>
        <item name="android:textColorPrimary">@color/textColorPrimary</item>
        <item name="android:navigationBarColor">@color/navigationBar</item>
        <item name="android:actionBarSize">40dp</item>
    </style>
</resources>
)
CreateResource(values-v14, theme.xml,
<resources>
    <style name="LightTheme" parent="@android:style/Theme.Holo.Light">
       <item name="android:actionBarStyle">@style/CustomActionBarStyle</item>
    </style>
   <style name="CustomActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
       <item name="android:background">@color/actionbar</item>
   </style>
</resources>
)

'    -----------------------------------------------------------------------------------------------------------
'    Firebase AdMob shit
'    -----------------------------------------------------------------------------------------------------------
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)

CreateResourceFromFile(Macro, FirebaseAdMob.FirebaseAds)
'AddReplacement($ADMOB_APP_ID$, ca-app-pub-12673333333~6xxxxxxxxxxxxxxxxx)
AddReplacement($ADMOB_APP_ID$, ca-app-pub-5280477437506677~yyyyyyyyyyyy9)

'    -----------------------------------------------------------------------------------------------------------
'    cleartext shit
'    -----------------------------------------------------------------------------------------------------------
SetApplicationAttribute(android:networkSecurityConfig, @xml/network_security_config)
CreateResource(xml, network_security_config.xml,
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
   <domain includeSubdomains="true">www.marcsmartsoftware.com</domain>
</domain-config>
</network-security-config>
)
 
Upvote 0

mmieher

Active Member
Licensed User
Longtime User
Why the blank post? o_O
Oops. Accident.

A simple new project that would be a meaningful test is easier said than done.

I think it is this now: #SupportedOrientations: unspecified

I was messing with rotating the phone and a post suggested it. I have put back to portrait and the rotate stuff still works.
 
Upvote 0

mmieher

Active Member
Licensed User
Longtime User
Worth trying it with a new project. Create a new project and run it. Does it crash?
Ok. I have started a new Project. FILE, NEW, B4XPages. Copying one little bit at a time from the previous project.

This is intermittently happening. Log "Copy all to clipboard". Emulator (this time)
B4X:
--------- beginning of crash
java.lang.RuntimeException: Unable to create service com.marcsmart.aatimer.starter: java.lang.RuntimeException: java.io.EOFException
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4204)
    at android.app.ActivityThread.access$1500(ActivityThread.java:237)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:223)
    at android.app.ActivityThread.main(ActivityThread.java:7656)
    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)
Caused by: java.lang.RuntimeException: java.io.EOFException
    at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:164)
    at anywheresoftware.b4a.shell.Shell.start(Shell.java:102)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:92)
    at com.marcsmart.aatimer.starter.onCreate(starter.java:34)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4192)
    ... 8 more
Caused by: java.io.EOFException
    at java.io.DataInputStream.readFully(DataInputStream.java:200)
    at java.io.DataInputStream.readInt(DataInputStream.java:389)
    at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:136)
    ... 12 more

Rookie code. I am trying to go back to basics because I now realize I have missed much fundamental stuff.
 

Attachments

  • AATimer3.zip
    24 KB · Views: 81
Upvote 0
Top