Skip to content

Instantly share code, notes, and snippets.

@wodin
Last active January 1, 2023 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wodin/b7393dc2c5c18fd85d522d34785eae10 to your computer and use it in GitHub Desktop.
Save wodin/b7393dc2c5c18fd85d522d34785eae10 to your computer and use it in GitHub Desktop.
Allowing an Android app to be moved to an SD card by the user (untested)
<!-- Need to specify the `installLocation`. Can do this with a config plugin -->
<!-- See `app.json` and `withAndroidManifestAttributes.js` below -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp"
android:installLocation="auto">
...
</manifest>
{
"expo": {
// ...
"plugins": [
[
"./withAndroidManifestAttributes",
{
"android:installLocation": "auto"
}
]
]
}
}
const { withAndroidManifest } = require("@expo/config-plugins");
function addAttributesToApplication(androidManifest, attributes) {
const { manifest } = androidManifest;
manifest.$ = { ...manifest.$, ...attributes };
return androidManifest;
}
module.exports = function withAndroidManifestAttributes(config, attributes) {
return withAndroidManifest(config, (config) => {
config.modResults = addAttributesToApplication(
config.modResults,
attributes
);
return config;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment