您的位置:首页 > 移动开发 > Android开发

Rract Native Android 修改请求地址

2015-12-07 13:55 417 查看

Rract Native Android 修改请求地址

注 这中方式 是吧 bundle 文件下载到 assets 目录下进行编译

在app目录下 build.gradle 文件中

final def TARGET_BUNDLE_DIR = 'app/src/main/assets/'
final def TARGET_BUNDLE_FILE = 'index.android.bundle'
final def DOWNLOAD_URL = 'http://localhost:8081/index.android.bundle?platform=android&dev=false&minify=true'

task downloadJSBundle << {
def dir = new File(TARGET_BUNDLE_DIR)
if (!dir.exists()) {
dir.mkdirs()
}
def f = new File(TARGET_BUNDLE_DIR + TARGET_BUNDLE_FILE)
if (f.exists()) {
f.delete()
}
try {
new URL(DOWNLOAD_URL).withInputStream{ i -> f.withOutputStream{ it << i }}
} catch (Exception e) {
e.printStackTrace()
}

}

preBuild.dependsOn downloadJSBundle
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android native