mirror of
https://github.com/status-im/react-native.git
synced 2025-02-20 21:28:08 +00:00
Summary: `react-native link` often fails due to the wrong manifest being used when you use a debug manifest. `findManifest` returns `debug/AndroidManifest.xml` instead of `main/AndroidManifest.xml`. And the debug manifest usually does not have the package name defined so `projectConfigAndroid` throws a cryptic "Cannot read property 'replace' of undefined" error. This fixes the issue by throwing a more user friendly error and providing a `manifestPath` userConfig. This is mostly based on comments to #10050. Closes https://github.com/facebook/react-native/pull/13373 Differential Revision: D4945690 Pulled By: shergin fbshipit-source-id: b177f916fd4799c873d2515c18cbb87bef3203f0
69 lines
1.4 KiB
JavaScript
69 lines
1.4 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const manifest = fs.readFileSync(path.join(__dirname, './files/AndroidManifest.xml'));
|
|
const mainJavaClass = fs.readFileSync(path.join(__dirname, './files/Main.java'));
|
|
|
|
exports.valid = {
|
|
src: {
|
|
'AndroidManifest.xml': manifest,
|
|
main: {
|
|
com: {
|
|
some: {
|
|
example: {
|
|
'Main.java': mainJavaClass,
|
|
'ReactPackage.java': fs.readFileSync(path.join(__dirname, './files/ReactPackage.java')),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
exports.userConfigManifest = {
|
|
src: {
|
|
main: {
|
|
'AndroidManifest.xml': manifest,
|
|
com: {
|
|
some: {
|
|
example: {
|
|
'Main.java': mainJavaClass,
|
|
'ReactPackage.java': fs.readFileSync(path.join(__dirname, './files/ReactPackage.java')),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
debug: {
|
|
'AndroidManifest.xml': fs.readFileSync(path.join(__dirname, './files/AndroidManifest-debug.xml')),
|
|
},
|
|
},
|
|
};
|
|
|
|
exports.corrupted = {
|
|
src: {
|
|
'AndroidManifest.xml': manifest,
|
|
main: {
|
|
com: {
|
|
some: {
|
|
example: {},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
exports.noPackage = {
|
|
src: {
|
|
'AndroidManifest.xml': manifest,
|
|
main: {
|
|
com: {
|
|
some: {
|
|
example: {
|
|
'Main.java': mainJavaClass,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|