Android Question Program not running on Android Version 4.2.2

Status
Not open for further replies.

Jiten Shah

Member
Licensed User
B4A : 8.5

There is simple program which connect directly to MySQL database using mysql-connector-java-5.1.34-bin.jar.

This program work with Android Version 6 but not working with 4.2.2

Debug Log shows following error
java.lang.NumberFormatException: Invalid double: "Version"
java.lang.RuntimeException: Unable to create service b4a.example.starter: java.lang.RuntimeException: java.io.FileNotFoundException: /storage/emulated/0/Android/data/b4a.example/files/virtual_assets/1.bal: open failed: ENOENT (No such file or directory)

Mainfest file:
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="16"/>
<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.DarkTheme)
 
Last edited:

jimmyF

Active Member
Licensed User
Longtime User
You might want to show us some of your start up code otherwise we have no idea.
What do you have in Starter Service_Create for one?
 
Upvote 0

Jiten Shah

Member
Licensed User
You might want to show us some of your start up code otherwise we have no idea.
What do you have in Starter Service_Create for one?

B4X:
#Region  Service Attributes
   #StartAtBoot: False
   #ExcludeFromLibrary: True
#End Region

Sub Process_Globals
End Sub

Sub Service_Create
   'need to disable it as reading from large JdbcResultSet will cause network requests to be sent on the main thread.
   'DisableStrictMode
End Sub

Sub Service_Start (StartingIntent As Intent)

End Sub

'Sub DisableStrictMode
'   Dim jo As JavaObject
'   jo.InitializeStatic("android.os.Build.VERSION")
'   If jo.GetField("SDK_INT") > 9 Then
'       Dim policy As JavaObject
'       policy = policy.InitializeNewInstance("android.os.StrictMode.ThreadPolicy.Builder", Null)
'       policy = policy.RunMethodJO("permitAll", Null).RunMethodJO("build", Null)
'       Dim sm As JavaObject
'       sm.InitializeStatic("android.os.StrictMode").RunMethod("setThreadPolicy", Array(policy))
'   End If
'End Sub



Sub Service_TaskRemoved
   'This event will be raised when the user removes the app from the recent apps list.
End Sub

'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
   Return True
End Sub

Sub Service_Destroy

End Sub
 
Last edited:
Upvote 0

Jiten Shah

Member
Licensed User
I checked the path /storage/emulated/0/Android/data/b4a.example/files/virtual_assets/1.bal:
but I did not find anything no directory exist

Is layout file copied separately to device or is part of installation of apk file
 
Upvote 0

Jiten Shah

Member
Licensed User
1. Please use [code]code here...[/code] tags when posting code. - Done

2. Where are the full error messages from the logs? - Attached

3. Are you using JdbcSQL library? - Yes
 

Attachments

  • b4a_log.txt
    6.1 KB · Views: 201
Upvote 0

Jiten Shah

Member
Licensed User
I added these two
#BridgeLogger: True
#DebuggerForceStandardAssets: true

I have uploaded program in Release mode
Still program not able to run.

I have attached Release Debug Log
 

Attachments

  • b4a_log_release.txt
    12.3 KB · Views: 170
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Help us help you.

Question:

Error message:

java.lang.NumberFormatException: Invalid double: "Version"
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.initialParse(StringToReal.java:114)
at java.lang.StringToReal.parseDouble(StringToReal.java:263)
at java.lang.Double.parseDouble(Double.java:295)
at com.thebazaarng.main._activity_create(main.java:349)

Code in Activity_Create:

B4X:
Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   Activity.LoadLayout("main_layout")
   db.Initialize
   Activity.Title = "Version " + a_version
   
'   Wait For (db.Connect) Complete (Success As Boolean)       
End Sub

Answer:

+ operator adds two numbers.
You need to use the concatenation operator:
B4X:
Activity.Title = "Version " & a_version

I recommend you to solve the debugging issues.
 
Upvote 0

Jiten Shah

Member
Licensed User
Thanks to point out my mistake

Even in my phone also it is not working may be I change the code later on

But why compiler is not able to catch this error???
 
Upvote 0
Status
Not open for further replies.
Top