问题描述
清单属性是否可以根据Android SDK版本进行更改?
例如:SDK版本android:largeHeap是true
,而SDK> = 24时false
是<?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>
吗?
pmd {
ignoreFailures = false
ruleSets = [] // Remove defaults
ruleSetFiles = files("path/to/mandaroty/ruleset.xml")
}
解决方法
尝试一下
res / values / bool.xml
<resources>
<bool name="largeheap">true</bool>
</resources>
res / values-v24 / bool.xml
<resources>
<bool name="largeheap">false</bool>
</resources>
Android清单文件:
<application
android:largeHeap="@bool/largeheap"
android:allowBackup="true"
android:icon="@drawable/ic_launcher">
....
</application>
在true
中创建res/values/bool.xml
,在false
中创建res/values-v24/bool.xml
。 Android API级别24,因此-v24
将用于24及更高版本。
答案是否定的。但是您可以合并(覆盖SDK特定的库),例如
<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"/>
...