-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Android build for Detox e2e (#8362)
- Loading branch information
1 parent
854d620
commit 63889c0
Showing
8 changed files
with
131 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# How to Run Detox Tests | ||
|
||
## Android | ||
|
||
### Install Dependencies | ||
|
||
From the root directory, run the following command to install the necessary dependencies: | ||
|
||
```sh | ||
npm install | ||
``` | ||
|
||
### Inject Detox Settings | ||
|
||
To inject the Detox settings into your project, navigate to the `detox` directory and run the following command: | ||
|
||
```sh | ||
npm run inject-detox-settings | ||
``` | ||
|
||
### Update `minSdkVersion` for `react-native-image-picker` | ||
|
||
On macOS machines, update the `minSdkVersion` of `react-native-image-picker` to 23 by running the following command from the root directory: | ||
|
||
```sh | ||
sed -i '' 's/minSdkVersion 21/minSdkVersion 23/' ./node_modules/react-native-image-picker/android/build.gradle | ||
``` | ||
|
||
### Build detox android app | ||
|
||
From the `detox` folder run: | ||
|
||
``` | ||
npm run e2e:android-build | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
/* eslint-disable no-console */ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// Paths to files | ||
const androidManifestPath = path.resolve( | ||
__dirname, | ||
'../android/app/src/debug/AndroidManifest.xml', | ||
); | ||
const settingsGradlePath = path.resolve(__dirname, '../android/settings.gradle'); | ||
|
||
// Detox code to add to settings.gradle | ||
const detoxSettings = ` | ||
include ':detox' | ||
project(':detox').projectDir = new File(rootProject.projectDir, '../detox/node_modules/detox/android') | ||
`; | ||
|
||
// Updated AndroidManifest.xml content | ||
const updatedManifest = `<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
package="com.mattermost.rnbeta"> | ||
<application | ||
android:usesCleartextTraffic="true" | ||
tools:targetApi="28" | ||
tools:ignore="GoogleAppIndexingWarning"> | ||
<activity | ||
android:name="androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity" | ||
android:exported="true" | ||
tools:node="replace"/> | ||
<activity | ||
android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity" | ||
android:exported="true" | ||
tools:node="replace"/> | ||
<activity | ||
android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity" | ||
android:exported="true" | ||
tools:node="replace"/> | ||
</application> | ||
</manifest>`; | ||
|
||
// Update AndroidManifest.xml | ||
function updateAndroidManifest() { | ||
try { | ||
fs.writeFileSync(androidManifestPath, updatedManifest, 'utf-8'); | ||
console.log('AndroidManifest.xml updated successfully.'); | ||
} catch (err) { | ||
console.error(`Failed to update AndroidManifest.xml: ${err.message}`); | ||
} | ||
} | ||
|
||
// Update settings.gradle | ||
function updateSettingsGradle() { | ||
try { | ||
const content = fs.readFileSync(settingsGradlePath, 'utf-8'); | ||
if (content.includes("include ':detox'")) { | ||
console.log('Detox settings already present in settings.gradle.'); | ||
return; | ||
} | ||
fs.writeFileSync(settingsGradlePath, content + detoxSettings, 'utf-8'); | ||
console.log('settings.gradle updated successfully.'); | ||
} catch (err) { | ||
console.error(`Failed to update settings.gradle: ${err.message}`); | ||
} | ||
} | ||
|
||
// Run updates | ||
updateAndroidManifest(); | ||
updateSettingsGradle(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters