Android Question clipboard error

carycai

Member
Licensed User
Longtime User
I try to use clipboard library according to url :https://www.b4x.com/android/forum/threads/clipboard-library.7382/,and i got the error below:

if you can help me fix out this problem,thanks in advance.

B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 382)
java.lang.RuntimeException: java.lang.ClassCastException: b4a.util.BClipboard cannot be cast to anywheresoftware.b4a.ObjectWrapper
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at autoapp.cary.main._activity_create(main.java:382)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
    at autoapp.cary.main.afterFirstLayout(main.java:115)
    at autoapp.cary.main.access$000(main.java:28)
    at autoapp.cary.main$WaitForLayout.run(main.java:93)
    at android.os.Handler.handleCallback(Handler.java:808)
    at android.os.Handler.dispatchMessage(Handler.java:101)
    at android.os.Looper.loop(Looper.java:166)
    at android.app.ActivityThread.main(ActivityThread.java:7425)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Caused by: java.lang.ClassCastException: b4a.util.BClipboard cannot be cast to anywheresoftware.b4a.ObjectWrapper
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:415)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:454)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:454)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:148)
    ... 14 more
 

carycai

Member
Licensed User
Longtime User
I declard the clipboard in the function sub,and found the error gone.So the result is ,don't declard the var in Globals or Process_Globals.

Dim cp As BClipboard
If(cp.hasText=True) Then
setClipBoard(cp.getText)
cp.clrText
End If
 
Upvote 0

carycai

Member
Licensed User
Longtime User
Seems like you have a view with the same name as the BClipboard object.

These are all the modules' name,and the libraries.I didn't find the same name with BClipboard.
 

Attachments

  • module.JPG
    44 KB · Views: 247
  • lib.JPG
    76.2 KB · Views: 275
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…