::: warning Considering the package size, Android x86 is not supported for the moment.
:::
The following documents assume that you already have a certain Android development experience.
edit build.gradle
dependencies { ... // weex sdk and fastjson compile 'com.taobao.android:weex_sdk:0.20.0.2@aar' compile 'com.alibaba:fastjson:1.1.46.android' //support library dependencies compile 'com.android.support:recyclerview-v7:23.1.1' compile 'com.android.support:support-v4:23.1.1' compile 'com.android.support:appcompat-v7:23.1.1' }
proguard rules are as follows,recommended reference to the latest source configuration
-keep class com.taobao.weex.bridge.** { *; } -keep class com.taobao.weex.layout.** { *; } -keep class com.taobao.weex.WXSDKEngine { *; } -keep class com.taobao.weex.base.SystemMessageHandler { *; } -dontwarn com.taobao.weex.bridge.**
Add required permissions in your AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Init Weex SDK When Application Create
InitConfig config = new InitConfig.Builder() //imageLib interface .setImgAdapter(new FrescoImageAdapter()) //network lib interface .setHttpAdapter(new InterceptWXHttpAdapter()) .build(); WXSDKEngine.initialize(applicationContext,config);
public class MainActivity extends AppCompatActivity implements IWXRenderListener { WXSDKInstance mWXSDKInstance; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mWXSDKInstance = new WXSDKInstance(this); mWXSDKInstance.registerRenderListener(this); /** * bundleUrl source http://dotwe.org/vue/38e202c16bdfefbdb88a8754f975454c */ String pageName = "WXSample"; String bundleUrl = "http://dotwe.org/raw/dist/38e202c16bdfefbdb88a8754f975454c.bundle.wx"; mWXSDKInstance.renderByUrl(pageName, bundleUrl, null, null,WXRenderStrategy.APPEND_ASYNC); } @Override public void onViewCreated(WXSDKInstance instance, View view) { setContentView(view); } @Override public void onRenderSuccess(WXSDKInstance instance, int width, int height) { } @Override public void onRefreshSuccess(WXSDKInstance instance, int width, int height) { } @Override public void onException(WXSDKInstance instance, String errCode, String msg) { } @Override protected void onResume() { super.onResume(); if(mWXSDKInstance!=null){ mWXSDKInstance.onActivityResume(); } } @Override protected void onPause() { super.onPause(); if(mWXSDKInstance!=null){ mWXSDKInstance.onActivityPause(); } } @Override protected void onStop() { super.onStop(); if(mWXSDKInstance!=null){ mWXSDKInstance.onActivityStop(); } } @Override protected void onDestroy() { super.onDestroy(); if(mWXSDKInstance!=null){ mWXSDKInstance.onActivityDestroy(); } } }
Run app ,start activity, then you will see hello world demo. well done.
Tip: Click QRCode Image in Demo Source Page, your will see compiled bundle js.
Weex supports module-extend、component-extend and adapter-extend