Android Question JavaObject - Seem to i don't understand much here

Culjko

Member
In attach SDK for Ciontek C10 android!

Dim jo As JavaObject = Me
jo.InitializeContext
Dim jo1 As JavaObject = jo.InitializeNewInstance("vpos.apipackage.PosApiHelper", Null) 'This work normaly

*Solution for printing UTF-8 on each printer without converting fonts, work faster then SDK converting
Dim newFont As Typeface
Dim textPrint As String = "Any text"
Dim stingheight As Int = 19

Dim bmp As Bitmap
bmp.InitializeMutable(360,stingheight+5)
Dim DravPage As Canvas
Dim fontsize As Int = 10


bmp.InitializeMutable(360,stingheight+5)
DravPage.Initialize2(bmp)
DravPage.DrawColor(Colors.White)
DravPage.DrawText(textPrint,0.1,stingheight+0.5,Typeface.MONOSPACE,fontsize,Colors.RGB(0,0,0),"LEFT")
Dim bitmap As B4XBitmap = DravPage.Bitmap

Log(jo1.RunMethod("PrintBmp", Array(bitmap)))
When i try like this app crash.
How to use this DSK?
 

Attachments

  • errors.jpg
    errors.jpg
    443.4 KB · Views: 558
Logger connected to: Ciontek CS10
--------- beginning of main
Copying updated assets files (2)
*** Service (starter) Create ***
--------- beginning of system
** Service (starter) Start **
** Activity (main) Create (first time) **
bluetoothadapter
CS10
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
/storage/emulated/0/Android/data/com.ciontek/files
java.lang.UnsatisfiedLinkError: dlopen failed: /data/app/com.ciontek-2/lib/arm/libAndroid.so: has text relocations
at java.lang.Runtime.loadLibrary0(Runtime.java:977)
at java.lang.System.loadLibrary(System.java:1530)
at vpos.apipackage.Print.<clinit>(Print.java:13)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:400)
at java.lang.Class.forName(Class.java:326)
at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(JavaObject.java:274)
at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(JavaObject.java:84)
at com.ciontek.b4xmainpage._button1_click(b4xmainpage.java:142)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:5675)
at android.view.View$PerformClick.run(View.java:22641)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
** Activity (main) Pause event (activity is not paused). **
** Service (starter) Start **
** Activity (main) Create (first time) **
bluetoothadapter
CS10
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
/storage/emulated/0/Android/data/com.ciontek/files
java.lang.UnsatisfiedLinkError: dlopen failed: /data/app/com.ciontek-2/lib/arm/libAndroid.so: has text relocations
at java.lang.Runtime.loadLibrary0(Runtime.java:977)
at java.lang.System.loadLibrary(System.java:1530)
at vpos.apipackage.Print.<clinit>(Print.java:13)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:400)
at java.lang.Class.forName(Class.java:326)
at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(JavaObject.java:274)
at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(JavaObject.java:84)
at com.ciontek.b4xmainpage._button1_click(b4xmainpage.java:142)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:5675)
at android.view.View$PerformClick.run(View.java:22641)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
bluetoothadapter
CS10
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
/storage/emulated/0/Android/data/com.ciontek/files
java.lang.UnsatisfiedLinkError: dlopen failed: /data/app/com.ciontek-2/lib/arm/libAndroid.so: has text relocations
at java.lang.Runtime.loadLibrary0(Runtime.java:977)
at java.lang.System.loadLibrary(System.java:1530)
at vpos.apipackage.Print.<clinit>(Print.java:13)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:400)
at java.lang.Class.forName(Class.java:326)
at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(JavaObject.java:274)
at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(JavaObject.java:84)
at com.ciontek.b4xmainpage._button1_click(b4xmainpage.java:142)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:5675)
at android.view.View$PerformClick.run(View.java:22641)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
 
Upvote 0
I find this in arr

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="vpos.apipackage"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="25" />

<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true" >
</application>

</manifest>
How to add in manifest
 
Upvote 0
I think I find what is problem, I get this message
java.lang.UnsatisfiedLinkError: dlopen failed: /data/app/com.ciontek.ePos-2/lib/arm/libAndroid.so: has text relocations
but when i open apk that library is not in that folder
Ciontek_RAPID_DEBUG.apk\llib\armeabi\libAndroid.so
is that is problem how to place librarly on right place?
 
Upvote 0
It looks like this will work like this, my next question is related to variables how to send them to methods?


Dim vposHelper As JavaObject
Dim IconsFont As B4XFont
Log(vposHelper.InitializeStatic("vpos.apipackage.PosApiHelper")) ' log = (Class) class vpos.apipackage.PosApiHelper
Log(vposHelper.RunMethod("getInstance",Null)) ' log = vpos.apipackage.PosApiHelper@4360004


Log(vposHelper.RunMethod("PrintSetVoltage", Array(75)))

'Dim initPtinter As JavaObject = vposHelper.InitializeNewInstance("java.lang.PrintInitException" ,Array(2,24,24,0x33))
Log(vposHelper.RunMethod("PrintInit", Null)) ' log = 0
Log(vposHelper.RunMethod("PrintCheckStatus", Null)) ' log = 0

Dim textstr As String = "This is single line"
Dim stingheight As Int = 19
Dim bmp As Bitmap

bmp.InitializeMutable(360,stingheight+5)
Dim DravPage As Canvas
Dim fontsize As Int = 10
bmp.InitializeMutable(360,stingheight+5)
DravPage.Initialize2(bmp)
DravPage.DrawColor(Colors.White)
DravPage.DrawText(textstr,0.1,stingheight+0.5,Typeface.MONOSPACE,fontsize,Colors.RGB(0,0,0),"LEFT")
Dim SingleLine As Bitmap = DravPage.Bitmap
vposHelper.RunMethod("PrintBmp", Array As Object(SingleLine)) ' log = java.lang.IllegalArgumentException:
' Expected receiver of type vpos.apipackage.PosApiHelper,
' but got java.lang.Class<vpos.apipackage.PosApiHelper>
'Log(vposHelper.RunMethod("PrintStr", Array("Proba\n")))
'Log(vposHelper.RunMethod("PrintStart",Null))
 
Upvote 0
Manufactur reference:

PrintInit:
Function prototype public int PrintInit(int gray, int fontHeight, int fontWidth, int fontZoom)

Parameter description Gray: the grad density. 1-high density, 2-medium,3-low
Fontheight: font height. 16 or 24
Fontwidth: font width. 16 or 24
Fontzoom: bolt font, 0x00 or 0x33

and
PrintBmp:
Function prototype public int PrintBmp(Bitmap bitmap)
Parameter description bitmap:BMP photo data
 
Upvote 0
(Class) class vpos.apipackage.PosApiHelper
vpos.apipackage.PosApiHelper@4360004
0
0
0
0
Error occurred on line: 131 (B4XMainPage)
java.lang.IllegalArgumentException: Expected receiver of type vpos.apipackage.PosApiHelper, but got java.lang.Class<vpos.apipackage.PosApiHelper>
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:5675)
at android.view.View$PerformClick.run(View.java:22641)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
 
Upvote 0
1
init
successfully
successfully

In the meantime, I started with simpler functions, such as sending a string to the print, but the program remains unresponsive for a while and then reports an error -1002 receive timeout

Dim printer As ciontekPrinter
printer.Initialize(Me,"printer")
printer.PrintString("- - - - - - - - - - - - - - - - - - - - - - - -\n")
printer.PrintStart

user manual reference:
public int PrintInit(int gray, int fontHeight, int fontWidth, int fontZoom)
public int PrintStr(String str)
public int PrintStart()
 

Attachments

Upvote 0
Back
Top