Android Question Is this possible to create wrapper for crosswalk?

Rajesh kannan MJ

Member
Licensed User
Longtime User
Hi,

I am not a java geek. But just wanted to ask whether it is easier to create wrapper for crosswalk and use it inside the b4a?

Thanks in advance,

Best Regards,

Rajeshkannan MJ
 

DonManfred

Expert
Licensed User
Longtime User
Easier than what?

What is crosswalk?
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Hi,

I am not a java geek. But just wanted to ask whether it is easier to create wrapper for crosswalk and use it inside the b4a?

Thanks in advance,

Best Regards,

Rajeshkannan MJ
Why would you want to use CrossWalk when you have everything you need to develop any type of app and more with B4A?

Walter
 
Upvote 0

Rajesh kannan MJ

Member
Licensed User
Longtime User
https://crosswalk-project.org/ is the crosswalk library. The objective of this library is to provide exclusive webview component to hybrid app creators who create app or games in html5. This webview is webgl enabled and runs any html apps faster than normal webview. Basically, it is a product derived from Chromium,
 
Upvote 0

Rajesh kannan MJ

Member
Licensed User
Longtime User
@walterf25 Yes I agree that we have all features in b4a. But some times, I feel that is very easy to write simple games in html5 with webgl.

So, B4A can embed chromium in it and the html5 will run faster than normal webview.

Moreover, I am sure that in future, html5 apps are going to be normal and will run almost equally faster like native ones. That is why I thought B4A can provide option on it too,

Thank you friends,
 
Upvote 0

Ivan45

Member
Licensed User
Longtime User
I'm trying to use the crosswalk browser as well as the CSS support is a better fit for a product we make. The browser comes with a java wrapper that should be useable from within B4A.

I am however struggling to use it. I have created the following xml file that lives alongside the crosswalk JAR file so I can hook it into the B4A IDE:

B4X:
<root>
  <doclet-version-NOT-library-version>1.00</doclet-version-NOT-library-version>
  
   <class>
  <name>org.xwalk.core.XWalkView</name>
  <shortname>xwalk</shortname>
  <comment>The new web browser</comment>
  <owner>activity</owner>
     
   <method>
  <name>load</name>
  
   <parameter>
    <name>url</name>
  <type>java.lang.String</type>
   </parameter>
  
  <parameter>
    <name>Content</name>
  <type>java.lang.String</type>
  </parameter>
   </method>

   <method>
  <name>getXWalkVersion</name>
   <returntype>java.lang.String</returntype>
  </method>  
  
  </class>

  <version>1.0</version>
  <author></author>
</root>


I also have the following code that gives a constructor not found error:

   Dim arrURL(1) As String
   arrURL(0) = "http://10.0.0.100"

   Dim arrParams(2) As Object
   arrParams(0) = Activity
   arrParams(1) = Null
  
   Dim wb As JavaObject  
   wb.InitializeContext
  
   wb = wb.InitializeNewInstance("org.xwalk.core.XWalkView",arrParams)
   wb.RunMethod("load", arrURL)


If anybody has any pointers on how to get this working it would be much appreciated before I get forced to use Android Studio!
 
Upvote 0

Rajesh kannan MJ

Member
Licensed User
Longtime User
@Ivan45 You can even make things all in simple html and use Intel XDK to make it as app. I am using CLI based android Crosswalk option. It is good and quick. I can create the apk in the CLI itself.
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
I'm trying to use the crosswalk browser as well as the CSS support is a better fit for a product we make. The browser comes with a java wrapper that should be useable from within B4A.

I am however struggling to use it. I have created the following xml file that lives alongside the crosswalk JAR file so I can hook it into the B4A IDE:

B4X:
<root>
  <doclet-version-NOT-library-version>1.00</doclet-version-NOT-library-version>
 
   <class>
  <name>org.xwalk.core.XWalkView</name>
  <shortname>xwalk</shortname>
  <comment>The new web browser</comment>
  <owner>activity</owner>
    
   <method>
  <name>load</name>
 
   <parameter>
    <name>url</name>
  <type>java.lang.String</type>
   </parameter>
 
  <parameter>
    <name>Content</name>
  <type>java.lang.String</type>
  </parameter>
   </method>

   <method>
  <name>getXWalkVersion</name>
   <returntype>java.lang.String</returntype>
  </method> 
 
  </class>

  <version>1.0</version>
  <author></author>
</root>


I also have the following code that gives a constructor not found error:

   Dim arrURL(1) As String
   arrURL(0) = "http://10.0.0.100"

   Dim arrParams(2) As Object
   arrParams(0) = Activity
   arrParams(1) = Null
 
   Dim wb As JavaObject 
   wb.InitializeContext
 
   wb = wb.InitializeNewInstance("org.xwalk.core.XWalkView",arrParams)
   wb.RunMethod("load", arrURL)


If anybody has any pointers on how to get this working it would be much appreciated before I get forced to use Android Studio!
Have you added the jar file to the additional library folder, and have you added the #AdditionalJar method to B4A?
 
Upvote 0

Ivan45

Member
Licensed User
Longtime User
I have added the jar file to the additional library folder, but haven't added a #AdditionalJar method. I better look that up! I have decompiled the crosswalk wrapper and various error messages suggest that B4A can see the jar file but it falls over when I try to instantiate the crosswalk class. Looking at the decompiled jar file I need to be pasing one of the the following two sets of arguments and I'm not quite sure what these are in B4A terms.

public XWalkView(Context context, AttributeSet attrs)

or

public XWalkView(Context context, Activity activity)

Im not sure the previous reply about using the Intel XDK will work for me as the app needs to run in immersive mode.
 
Upvote 0

Rajesh kannan MJ

Member
Licensed User
Longtime User
@Ivan45 Could you please share your jar file? Or can you point me where to download the jar file. I also want to try that. Though I am not great coder in Java, I love to do this,
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
I have added the jar file to the additional library folder, but haven't added a #AdditionalJar method. I better look that up! I have decompiled the crosswalk wrapper and various error messages suggest that B4A can see the jar file but it falls over when I try to instantiate the crosswalk class. Looking at the decompiled jar file I need to be pasing one of the the following two sets of arguments and I'm not quite sure what these are in B4A terms.

public XWalkView(Context context, AttributeSet attrs)

or

public XWalkView(Context context, Activity activity)

Im not sure the previous reply about using the Intel XDK will work for me as the app needs to run in immersive mode.
you can pass the Context with this:
B4X:
Sub GetContext As JavaObject
   Return GetBA.GetField("context")
End Sub

Sub GetBA AsJavaObject
Dim jo AsJavaObject
Dim cls AsString = Me
cls = cls.SubString("class ".Length)
jo.InitializeStatic(cls)
Return jo.GetFieldJO("processBA")
End Sub
 
Last edited:
Upvote 0

Rajesh kannan MJ

Member
Licensed User
Longtime User
@walterf25 can you please tell me how to pass the "this" value to InitializeNewInstance

I am following this reference too https://gist.github.com/butelo/9365587

I need to do the following things,

xWalkWebView = new XWalkView(this.getApplicationContext(), this);
xWalkWebView.loadUrl("file:///android_asset/www/index.html");

with your help, I am able to get the context. But how to send "this" in array please?

Thank you,
 
Upvote 0

Ivan45

Member
Licensed User
Longtime User
I'm having another look at this.. How do I pass the activity as an object to the java wrapper I have? The context part is sorted as per other peoples help but I cannot get the activity as an object without getting the following error as activity always appears to be a BALayout which doesn't work.

The error I'm getting.
java.lang.IllegalArgumentException: argument 2 should have type java.lang.Object[], got anywheresoftware.b4a.BALayout

This is what the wrapper is expecting.
public XWalkView(Context context, Activity activity)

Any help would be appreciated!
 
Upvote 0

Rajesh kannan MJ

Member
Licensed User
Longtime User
Unless someone creates wrapper for xWalk (crosswalk) it seems not possible to use it in another way directly.

@Erel @walterf25 @DonManfred are such people who can do this. But they do not have time for it.

I hope in a year or so, I can see the Crosswalk wrapper soon here.

BTW, @Ivan45 I am now using Eclipse to do the work with Crosswalk. It is easy there. I do not like Android Studio, because it is slower in my system.

Suppose if you get any solution, kindly share,
 
Upvote 0

Ivan45

Member
Licensed User
Longtime User
I'm begining to come to the same conclusion. The Crosswalk website lists a number of different development systems that support Crosswalk so it's a matter of picking one that's not going to take forever to learn how to use!

I will spend a little more time on it and if I get anywhere I will post it.
 
Upvote 0
Top