简体   繁体   中英

Cordova config.xml preference android-installLocation

 <platform name="android">
    <preference name="android-installLocation" value="auto" />
</platform>

Preference for android install location inside config.xml does not work. It is not passed inside the android manifest xml with prepare or build.

The solution I found in this issue was a plugin that make it possible to pass preferences from the config.cml to the android manifest, that are not passed automatically.

cordova plugin add cordova-custom-config
https://github.com/dpa99c/cordova-custom-config

For future reference:

In your config.xml , inside the <platform name="android"> tag, enter the following lines:

<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest">
    <manifest android:installLocation="auto" />
</edit-config>

Explanation:

  • The tag edit-config is used to modify XML-based configuration files (in this case - app/src/main/AndroidManifest.xml ).
  • To target the manifest tag, we use the XML attribute target="/manifest" .
  • Using the XML attribute mode="merge" , we then merge our own required XML Element with it (in this case - <manifest android:installLocation="auto" /> ).

Details about cordova edit-config here .

Details about android install location here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM