Skip to content

Commit 5ccb882

Browse files
committed
Add manifestPath userConfig.
`react-native link` often fails due to the wrong manifest being used when you use a debug manifest.
1 parent 03ea65e commit 5ccb882

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

local-cli/core/__fixtures__/android.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,25 @@ exports.valid = {
2020
},
2121
};
2222

23+
exports.userConfigManifest = {
24+
src: {
25+
main: {
26+
'AndroidManifest.xml': manifest,
27+
com: {
28+
some: {
29+
example: {
30+
'Main.java': mainJavaClass,
31+
'ReactPackage.java': fs.readFileSync(path.join(__dirname, './files/ReactPackage.java')),
32+
},
33+
},
34+
},
35+
},
36+
debug: {
37+
'AndroidManifest.xml': fs.readFileSync(path.join(__dirname, './files/AndroidManifest-debug.xml')),
38+
},
39+
},
40+
};
41+
2342
exports.corrupted = {
2443
src: {
2544
'AndroidManifest.xml': manifest,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<manifest
2+
xmlns:android="http://schemas.android.com/apk/res/android">
3+
</manifest>

local-cli/core/__tests__/android/getProjectConfig.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ describe('android::getProjectConfig', () => {
1515
flat: {
1616
android: mocks.valid,
1717
},
18+
multiple: {
19+
android: mocks.userConfigManifest,
20+
},
1821
noManifest: {
1922
android: {},
2023
},
@@ -43,6 +46,16 @@ describe('android::getProjectConfig', () => {
4346
expect(getProjectConfig(folder, userConfig)).not.toBe(null);
4447
expect(typeof getProjectConfig(folder, userConfig)).toBe('object');
4548
});
49+
50+
it('multiple', () => {
51+
const userConfig = {
52+
manifestPath: 'src/main/AndroidManifest.xml'
53+
};
54+
const folder = 'multiple';
55+
56+
expect(getProjectConfig(folder, userConfig)).not.toBe(null);
57+
expect(typeof getProjectConfig(folder, userConfig)).toBe('object');
58+
});
4659
});
4760

4861
it('should return `null` if android project was not found', () => {

local-cli/core/android/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ exports.projectConfig = function projectConfigAndroid(folder, userConfig) {
2929

3030
const sourceDir = path.join(folder, src);
3131
const isFlat = sourceDir.indexOf('app') === -1;
32-
const manifestPath = findManifest(sourceDir);
32+
const manifestPath = userConfig.manifestPath
33+
? path.join(sourceDir, userConfig.manifestPath)
34+
: findManifest(sourceDir);
3335

3436
if (!manifestPath) {
3537
return null;
@@ -97,7 +99,9 @@ exports.dependencyConfig = function dependencyConfigAndroid(folder, userConfig)
9799
}
98100

99101
const sourceDir = path.join(folder, src);
100-
const manifestPath = findManifest(sourceDir);
102+
const manifestPath = userConfig.manifestPath
103+
? path.join(sourceDir, userConfig.manifestPath)
104+
: findManifest(sourceDir);
101105

102106
if (!manifestPath) {
103107
return null;

0 commit comments

Comments
 (0)