|
@@ -1,6 +1,28 @@
|
1
|
1
|
var fs = require('fs');
|
|
2
|
+
|
2
|
3
|
var MANIFEST_PATH = process.cwd() + '/android/app/src/main/AndroidManifest.xml';
|
|
4
|
+var PACKAGE_JSON = process.cwd() + '/package.json';
|
|
5
|
+
|
|
6
|
+var hasNecessaryFile = fs.existsSync(MANIFEST_PATH) && fs.existsSync(MANIFEST_PATH);
|
|
7
|
+
|
|
8
|
+if (!hasNecessaryFile) {
|
|
9
|
+ throw 'RNFetchBlob could not found link Android automatically, some files could not be found.'
|
|
10
|
+}
|
|
11
|
+
|
|
12
|
+var package = fs.readFileSync(PACKAGE_JSON);
|
|
13
|
+var APP_NAME = package.name;
|
|
14
|
+var VERSION = parseFloat(/\d\.\d+(?=\.)/.exec(package.dependencies['react-native']));
|
|
15
|
+var APPLICATION_MAIN = process.cwd() + '/android/app/src/main/java/com/' + APP_NAME.toLocaleLowerCase() + '/MainApplication.java';
|
|
16
|
+
|
|
17
|
+if(VERSION >= 0.29) {
|
|
18
|
+
|
|
19
|
+ var main = fs.readFileSync(APPLICATION_MAIN);
|
|
20
|
+ main = main.replace('new MainReactPackage()', 'new RNFetchBlobPackage(),\n new MainReactPackage()');
|
|
21
|
+ fs.writeFileSync(APPLICATION_MAIN, main);
|
|
22
|
+
|
|
23
|
+}
|
3
|
24
|
|
|
25
|
+// set file access permission for Android < 6.0
|
4
|
26
|
fs.readFile(MANIFEST_PATH, function(err, data) {
|
5
|
27
|
|
6
|
28
|
if(err)
|