The issue not depending on the code (I used the
JdbcSQLExample.zip)
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
#AdditionalJar: mysql-connector-java-8.0.15.jar
#BridgeLogger: true
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private ProgressBar1 As ProgressBar
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("1")
End Sub
Sub Activity_Click
ProgressBar1.Visible = True
Wait For (CallSub(Starter, "ListAnimals")) Complete (Result As Boolean)
Log("Completed. Success: " & Result)
ProgressBar1.Visible = False
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
Public mysql As JdbcSQL
Private driver As String = "com.mysql.jdbc.Driver"
Private jdbcUrl As String = "jdbc:mysql://192.168.0.6/test"
Private Username As String = "username"
Private Password As String = "password"
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 Connect As ResumableSub
mysql.InitializeAsync("mysql", driver, jdbcUrl, Username, Password)
Wait For MySQL_Ready (Success As Boolean)
If Success = False Then
Log("Check unfiltered logs for JDBC errors.")
End If
Return Success
End Sub
Sub CloseConnection
mysql.Close
End Sub
Sub ListAnimals As ResumableSub
Wait For (Connect) Complete (Success As Boolean)
If Success Then
Try
Dim sf As Object = mysql.ExecQueryAsync("mysql", "SELECT id, name FROM animals WHERE id > ?", Array(300))
Wait For (sf) mysql_QueryComplete (Success As Boolean, Crsr As JdbcResultSet)
If Success Then
Do While Crsr.NextRow
Log($"Id: ${Crsr.GetInt("id")}, Name: ${Crsr.GetString("name")}"$)
Loop
Crsr.Close
End If
Catch
Success = False
Log(LastException)
End Try
CloseConnection
End If
Return Success
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
JAVA:
C:\Program Files\Java\jdk1.8.0_211\bin
i tried with:
mysql-connector-java-8.0.15.jar
mysql-connector-java-8.0.14.jar
mysql-connector-java-8.0.13.jar
mysql-connector-java-8.0.12.jar
mysql-connector-java-8.0.11.jar
Manifest:
'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="28"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
Error:
B4A Versione: 8.80
Analisi del Codice. (0.00s)
Building folders structure. (0.08s)
Compilazione del codice. (0.01s)
Compilazione del codice di layouts (0.00s)
Organizzazione Librerie. (0.00s)
Generazione file R. (0.15s)
Compilazione del codice Java prodotto. (2.92s)
Conversione byte code - ottimizzazione dex. Error
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Translation has been interrupted
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:692)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:315)
at com.android.dx.command.dexer.Main.runDx(Main.java:293)
at com.android.dx.command.dexer.Main.main(Main.java:249)
at com.android.dx.command.Main.main(Main.java:94)
Caused by: java.lang.InterruptedException: Too many errors
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:684)
... 4 more