embed crosswalk in android studio

iedmrc picture iedmrc · Feb 28, 2015 · Viewed 18.3k times · Source

I'm new about android programming and android studio. I researched crosswalk embed API for my project and tried to embed it in android studio. But I couldn't be succesfull. Even I don't know exactly how can embed an API that has gradle file or not.

Maybe there is a problem with gradle system? In brief, how can I embed crosswalk-webview to my project with android studio step by step? Thanks a lot you.

Answer

Rubber Duck picture Rubber Duck · Mar 9, 2015

Following: https://diego.org/2015/01/07/embedding-crosswalk-in-android-studio/

  1. Open AndroidStudio to project view in app folder edit build.gradle:

    repositories {
    maven {
    url 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'}}
    
    
    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'org.xwalk:xwalk_core_library:10.39.235.15'}
    
  2. sync project.

  3. add this view in layout xml.

    <org.xwalk.core.XWalkView
    android:id="@+id/xwalkWebView"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#000000"
    />
    
  4. In activity or fragment:

    import org.xwalk.core.XWalkPreferences;
    import org.xwalk.core.XWalkView;
    
  5. in onCreate:

    XWalkView xWalkWebView=(XWalkView)findViewById(R.id.xwalkWebView);
    xWalkWebView.clearCache(true);
    xWalkWebView.load("http://...", null);
    // turn on debugging
    XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true);
    

I've successfully used WebRTC in XWalkView on android 4.3 and 4.4 after failing with the out of the box WebView. I think the android 5 Lollipop is up to par with latest chromium.