W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
可以通過Gradle 或者 Maven添加對(duì) Android Devtools for Apache Weex 的依賴, 也可以直接對(duì)源碼依賴.
dependencies {
implementation 'com.taobao.android:weex_inspector:0.24.2.11'
}
或者
<dependency>
<groupId>com.taobao.android</groupId>
<artifactId>weex_inspector</artifactId>
<version>0.24.2.11</version>
<type>pom</type>
</dependency>
或者
需要復(fù)制inspector目錄到你的app的同級(jí)目錄, 然后在工程的 ?settings.gradle
? 文件下添加? include ":inspector"
?, 此過程可以參考playground源碼的工程配置及其配置, 然后在app的?build.gralde
?中添加依賴.
dependencies {
compile project(':inspector')
}
dependencies {
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.okhttp:okhttp-ws:2.3.0'
...
}
最簡單方式就是復(fù)用Playground的相關(guān)代碼,比如掃碼和刷新等模塊, 但是掃碼不是必須的, 它只是與app通信的一種形式, 二維碼里的包含DebugServer IP及bundle地址等信息,用于建立App和Debug Server之間的連接及動(dòng)態(tài)加載bundle. 在Playground中給出了兩種開啟debug模式的范例.
public class MyApplication extends Application {
public void onCreate() {
super.onCreate();
initDebugEnvironment(true, "xxx.xxx.xxx.xxx"/*"DEBUG_SERVER_HOST"*/);
//WXSDKEngine.reload();
}
}
private void initDebugEnvironment(boolean enable, String host) {
WXEnvironment.sRemoteDebugMode = enable;
WXEnvironment.sRemoteDebugProxyUrl = "ws://" + host + ":8088/debugProxy/native";
}
這種方式最直接, 在代碼中直接hardcode了開啟調(diào)試模式, 如果在SDK初始化之前調(diào)用甚至連?WXSDKEngine.reload()
?都不需要調(diào)用, 接入方如果需要更靈活的策略可以將?initDebugEnvironment(boolean enable, String host)
?和?WXSDKEngine.reload()
?組合在一起在合適的位置和時(shí)機(jī)調(diào)用即可.(如果不是初始化之前調(diào)用,n那么每次調(diào)用initDebugEnvironment后必須調(diào)用WXSDKEngine.reload()刷新Weex引擎)
攔截方式:
if (WXEnvironment.isApkDebugable()) {
String devToolUrl = uri.getQueryParameter("_wx_devtool");
if (!TextUtils.isEmpty(devToolUrl)) {
WXEnvironment.sRemoteDebugProxyUrl = devToolUrl;
WXEnvironment.sDebugServerConnectable = true;
WXSDKEngine.reload(XXXXX.getApplication(), false);
}
}
public class RefreshBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (IWXDebugProxy.ACTION_DEBUG_INSTANCE_REFRESH.equals(intent.getAction())) {
//Do something
}
}
}
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: