android largeheap 的版本条件

android version condition for largeheap

我正在尝试在 AndroidManifest 文件中使用 largeheap: true,我找到了这个答案 Enable android:largeHeap in Android 4, and disable it in Android 2.3

但问题是我总是遇到错误

/*/android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml:38:28-41: AAPT: No resource found that matches the given name (at 'largeHeap' with value '@values/bools').

/*/android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml:32: error: Error: No resource found that matches the given name (at 'largeHeap' with value '@values/bools').

我创建了 2 个文件 bools.xml */android/app/src/main/res/values/bools.xml 中的第一个 价值 <bool name="largeheap">true</bool> */android/app/src/main/res/values-v23/bools.xml 中的第二个值为 <bool name="largeheap">false</bool>(对于 api 23 及以上)

不确定我遗漏了什么,为什么 AndroidManifest 找不到与行 android:largeHeap="@bool/largeheap"

匹配的资源

除了 AndroidManifest 文件中的 android:largeHeap="@bool/largeheap" 之外,我还需要做什么吗?

谢谢。

根据你的错误,我可以看到 android 抱怨 @values/bools 而你的问题显示了另一行:android:largeHeap="@bool/largeheap".

我创建了一个新的应用程序项目并复制了您的案例。这对我有用:

AndroidManifest.xml中使用这个:

android:largeHeap="@bool/largeheap"

并确保您的 bools.xml 看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <bool name="largeheap">true</bool>
</resources>

之后还尝试清理并重建您的项目。