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