Kiran Rao
Kiran Rao

Reputation: 321

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>

Upvotes: 7

Views: 2619

Answers (2)

chand mohd
chand mohd

Reputation: 2550

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.

Upvotes: 10

Ali
Ali

Reputation: 529

The answer is no. But you can merge (override SDK specific libraries) them like

  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.example.app"
          xmlns:tools="http://schemas.android.com/tools">
  <uses-sdk tools:overrideLibrary="com.example.lib1, com.example.lib2"/>
    ...

source: Developer.Android

Upvotes: 1

Related Questions