编辑 (2016-12-21)
在 Bryan 建议使用构建工具 25.0.1 之后,我的解决方案不再出现构建错误:
<compatible-screens>
<!-- all small size screens -->
<screen android:screenSize="small" android:screenDensity="ldpi" />
<screen android:screenSize="small" android:screenDensity="mdpi" />
<screen android:screenSize="small" android:screenDensity="hdpi" />
<screen android:screenSize="small" android:screenDensity="xhdpi" />
<screen android:screenSize="small" android:screenDensity="xxhdpi" />
<screen android:screenSize="small" android:screenDensity="xxxhdpi" />
<!-- all normal size screens -->
<screen android:screenSize="normal" android:screenDensity="ldpi" />
<screen android:screenSize="normal" android:screenDensity="mdpi" />
<screen android:screenSize="normal" android:screenDensity="hdpi" />
<screen android:screenSize="normal" android:screenDensity="xhdpi" />
<screen android:screenSize="normal" android:screenDensity="xxhdpi" />
<screen android:screenSize="normal" android:screenDensity="xxxhdpi" />
但是...
在新版本中,一些设备未出现在受支持的设备列表(Google Play 控制台)中:Google Pixel、Nexus 5x、Google Pixel XL、Nexus 6、Nexus 6P。
这就是为什么我的新解决方案看起来像这样:
<!-- just handsets allowed-->
<compatible-screens>
<!-- all small size screens -->
<screen android:screenSize="small" android:screenDensity="ldpi" /> <!-- 120 -->
<screen android:screenSize="small" android:screenDensity="mdpi" /> <!-- 160 -->
<screen android:screenSize="small" android:screenDensity="hdpi" /> <!-- 240 -->
<screen android:screenSize="small" android:screenDensity="280" /> <!-- Workaround -->
<screen android:screenSize="small" android:screenDensity="xhdpi" /> <!-- 320 -->
<screen android:screenSize="small" android:screenDensity="360" /> <!-- Workaround -->
<screen android:screenSize="small" android:screenDensity="420" /> <!-- Workaround Google Pixel, Nexus 5x -->
<screen android:screenSize="small" android:screenDensity="xxhdpi" /> <!-- 480 -->
<screen android:screenSize="small" android:screenDensity="560" /> <!-- Workaround Google Pixel XL, Nexus 6, Nexus 6P -->
<screen android:screenSize="small" android:screenDensity="xxxhdpi" /> <!-- 640 -->
<!-- all normal size screens -->
<screen android:screenSize="normal" android:screenDensity="ldpi" /> <!-- 120 -->
<screen android:screenSize="normal" android:screenDensity="mdpi" /> <!-- 160 -->
<screen android:screenSize="normal" android:screenDensity="hdpi" /> <!-- 240 -->
<screen android:screenSize="normal" android:screenDensity="280" /> <!-- Workaround -->
<screen android:screenSize="normal" android:screenDensity="xhdpi" /> <!-- 320 -->
<screen android:screenSize="normal" android:screenDensity="360" /> <!-- Workaround -->
<screen android:screenSize="normal" android:screenDensity="420" /> <!-- Workaround Google Pixel, Nexus 5x -->
<screen android:screenSize="normal" android:screenDensity="xxhdpi" /> <!-- 480 -->
<screen android:screenSize="normal" android:screenDensity="560" /> <!-- Workaround Google Pixel XL, Nexus 6, Nexus 6P -->
<screen android:screenSize="normal" android:screenDensity="xxxhdpi" /> <!-- 640 -->
</compatible-screens>
旧:
根据 Bryan 的回答,我的清单 sn-p 如下所示:
<!-- just handsets allowed-->
<compatible-screens>
<!-- all small size screens -->
<screen android:screenSize="small" android:screenDensity="ldpi" /> <!-- approximately 120 dpi -->
<screen android:screenSize="small" android:screenDensity="mdpi" /> <!-- approximately 160 dpi -->
<screen android:screenSize="small" android:screenDensity="hdpi" /> <!-- approximately 240 dpi -->
<screen android:screenSize="small" android:screenDensity="280" /> <!-- Workaround -->
<screen android:screenSize="small" android:screenDensity="xhdpi"/> <!-- approximately 320 dpi -->
<screen android:screenSize="small" android:screenDensity="360" /> <!-- Workaround -->
<screen android:screenSize="small" android:screenDensity="420" /> <!-- Workaround -->
<screen android:screenSize="small" android:screenDensity="480" /> <!-- Workaround -->
<screen android:screenSize="small" android:screenDensity="560" /> <!-- Workaround -->
<screen android:screenSize="small" android:screenDensity="640" /> <!-- Workaround -->
<!-- all normal size screens -->
<screen android:screenSize="normal" android:screenDensity="ldpi" /> <!-- approximately 120 dpi -->
<screen android:screenSize="normal" android:screenDensity="mdpi" /> <!-- approximately 160 dpi -->
<screen android:screenSize="normal" android:screenDensity="hdpi" /> <!-- approximately 240 dpi -->
<screen android:screenSize="normal" android:screenDensity="280" /> <!-- Workaround -->
<screen android:screenSize="normal" android:screenDensity="xhdpi"/> <!-- approximately 320 dpi -->
<screen android:screenSize="normal" android:screenDensity="360" /> <!-- Workaround -->
<screen android:screenSize="normal" android:screenDensity="420" /> <!-- Workaround -->
<screen android:screenSize="normal" android:screenDensity="480" /> <!-- Workaround -->
<screen android:screenSize="normal" android:screenDensity="560" /> <!-- Workaround -->
<screen android:screenSize="normal" android:screenDensity="640" /> <!-- Workaround -->
</compatible-screens>
无法使用 Bryan 的解决方案,因为我遇到了编译错误:“AAPT: String types not allowed (at 'screenDensity' with value 'xxxhdpi')”
它适用于(较新的)设备,例如 Google Pixel (2.6 * 160 dp = 416 dp -> 420dp -> explanation:) / Pixel XL (3.5 * 160 dp = 560 dp) 或三星 Galaxy S6 (4.0 * 160 dp = 640 dp)。
dp 值在此处描述:https://material.io/devices/
我认为这是可行的,因为我上面提到的设备出现在 Google Play 控制台的“支持的设备”列表中。