Use crosswalk under Android Studio and package with maven dependency library

The first is to create a new module under AS and add the following declaration in the build.gradle file, indicating that the library we need to depend on is obtained from the specified warehouse. After modifying the build file, it needs to be manually synchronized to ensure that the library is obtained correctly.

// download from the specified location

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:22.1.1'

 //Specify the compiled lib, it should be the latest stable version of 12.41.296.9

 compile 'org.xwalk:xwalk_core_library:12.41.296.9'

}

Add the required permissions to the manifest list, if there is no permission, an error will be reported at runtime

<uses-permissionandroid:name="android.permission.ACCESS_FINE_LOCATION"/>

<uses-permissionandroid:name="android.permission.ACCESS_NETWORK_STATE"/>

<uses-permissionandroid:name="android.permission.ACCESS_WIFI_STATE"/>

<uses-permissionandroid:name="android.permission.INTERNET"/>

<uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Using XwalkView in Activity

protectedvoid onCreate(Bundle savedInstanceState){

super.onCreate (savedInstanceState);

//You can get XWalkView by new or by findViewById

XWalkView xWalkView =newXWalkView(this,this);

 setContentView(xWalkView);

//Load the specified address

 xWalkView.load("http://www.baidu.com",null);

}

It can be run after running. If there are no errors in the previous settings, it should be able to run normally, and it can run under the virtual machine and the real machine.

The previous build includes arm and x86, that is, this apk package can be used normally on devices of these two architectures, but the volume is relatively large;

If you need to build a package with a specified architecture, you need to add the following code to the buildl.gradle file, and then generate different apk packages for different architectures in build.

productFlavors {

 armv7 {

 ndk {

 abiFilters "armeabi-v7a", ""

 }

 }

 x86 {

 ndk {

 abiFilters "x86", ""

 }

 }

 }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326077910&siteId=291194637
Recommended