-
-
Save amitkrxyz/80039f47394656e6a5163a679de4ead6 to your computer and use it in GitHub Desktop.
Add `usesCleartextTraffic` to AndroidManifest.xml in Expo managed workflow
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
/* | |
* Convert `app.json` to `app.config.js` | |
* Install `@expo/config-plugins` as a devDependency | |
* Copy the `withAndroidApplicationAttributes` config plugin and related `addAttributesToApplication` function to `app.config.js` | |
* Add a `plugins` section to reference the config plugin and specify the attribute to add | |
* Build with `eas build -p android ...` | |
*/ | |
import { AndroidConfig, withAndroidManifest } from "@expo/config-plugins"; | |
function addAttributesToApplication(androidManifest, attributes) { | |
const app = AndroidConfig.Manifest.getMainApplicationOrThrow(androidManifest); | |
app.$ = { ...app.$, ...attributes }; | |
return androidManifest; | |
} | |
function withAndroidApplicationAttributes(config, attributes) { | |
return withAndroidManifest(config, (config) => { | |
config.modResults = addAttributesToApplication( | |
config.modResults, | |
attributes | |
); | |
return config; | |
}); | |
} | |
export default { | |
name: "androidManifestAttributeTest", | |
slug: "androidManifestAttributeTest", | |
version: "1.0.0", | |
plugins: [ | |
[ | |
withAndroidApplicationAttributes, | |
{ | |
"android:usesCleartextTraffic": false, | |
}, | |
], | |
], | |
orientation: "portrait", | |
icon: "./assets/icon.png", | |
splash: { | |
image: "./assets/splash.png", | |
resizeMode: "contain", | |
backgroundColor: "#ffffff", | |
}, | |
updates: { | |
fallbackToCacheTimeout: 0, | |
}, | |
assetBundlePatterns: ["**/*"], | |
ios: { | |
supportsTablet: true | |
}, | |
android: { | |
adaptiveIcon: { | |
foregroundImage: "./assets/adaptive-icon.png", | |
backgroundColor: "#FFFFFF", | |
}, | |
package: "com.example.androidManifestAttributeTest", | |
}, | |
web: { | |
favicon: "./assets/favicon.png", | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment