1.关于assets目录,可以选择把source.set这段注释掉,或者在修改如下代码
variant.mergeAssets.doLast {
def sourceDir = "${buildDir}/../../../../.."
copy {
from "${sourceDir}/vivo_assets/vivounionsdk"
into "${buildDir}/intermediates/merged_assets/${variant.dirName}/out/vivounionsdk"
}
copy {
from "${sourceDir}/vivo_assets/supplierconfig.json"
into "${buildDir}/intermediates/merged_assets/${variant.dirName}/out/"
}
//这里是gradle3.4以上的版本需要改成这样,否则js文件不会复制过去
copy{
from "${sourceDir}"
include "res/**"
include "src/**"
include "jsb-adapter/**"
into outputDir
}
copy {
from "${sourceDir}/main.js"
from "${sourceDir}/project.json"
into outputDir
}
}
2.虚拟返回按键监听:
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
Log.d(TAG, "dispatchKeyEvent:" + event.getKeyCode());
//拦截返回键
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK){
//判断触摸UP事件才会进行返回事件处理
if (event.getAction() == KeyEvent.ACTION_UP) {
onBackPressed();
}
//只要是返回事件,直接返回true,表示消费掉
return true;
}
return super.dispatchKeyEvent(event);
}