File size: 1,267 Bytes
4a5ef51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const { withGradleProperties, withProjectBuildGradle } = require("expo/config-plugins");

const CONFIG_BLOCK = `

// Keep release APK native libraries compatible with Android's 16 KB page-size devices.

subprojects { subproject ->

  subproject.plugins.withId("com.android.library") {

    if (subproject.name == "lc3Lib") {

      subproject.android.defaultConfig.externalNativeBuild.cmake.arguments(

        "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"

      )

    }

  }

}

`;

module.exports = function withAndroid16KbPageSize(config) {
  config = withGradleProperties(config, (gradleConfig) => {
    const property = gradleConfig.modResults.find(
      (item) => item.type === "property" && item.key === "reactNativeArchitectures"
    );
    if (property) {
      property.value = "arm64-v8a,x86_64";
    } else {
      gradleConfig.modResults.push({
        type: "property",
        key: "reactNativeArchitectures",
        value: "arm64-v8a,x86_64",
      });
    }
    return gradleConfig;
  });

  return withProjectBuildGradle(config, (gradleConfig) => {
    if (!gradleConfig.modResults.contents.includes(CONFIG_BLOCK.trim())) {
      gradleConfig.modResults.contents += CONFIG_BLOCK;
    }
    return gradleConfig;
  });
};