Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Use different manifest depending on SDK Platform Version

Is it possible for manifest properties to change based on Android SDK versions?

eg: have android:largeHeap be true when SDK version < 24 and false when SDK >= 24?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.androidapp">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"

        android:largeHeap="true" 

        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
like image 994
Kiran Rao Avatar asked Jan 25 '23 18:01

Kiran Rao


1 Answers

Try This

res/values/bool.xml

<resources>
    <bool name="largeheap">true</bool>
</resources>

res/values-v24/bool.xml

<resources>
    <bool name="largeheap">false</bool>
</resources>

Android Manifest file:

<application
        android:largeHeap="@bool/largeheap"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher">
                ....
</application>

Make true in res/values/bool.xml and false in res/values-v24/bool.xml. Android API Level 24, so -v24 will be used for 24 and higher versions.

like image 100
chand mohd Avatar answered May 14 '23 23:05

chand mohd