Android根据SDK平台版本使用不同的清单

问题描述

清单属性是否可以根据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"/>
    ...

来源:Developer.Android

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...