优化的Andr​​oid清单文件数量最多支持的设备 [英] Optimizing Android manifest file for largest number of supported devices

查看:129
本文介绍了优化的Andr​​oid清单文件数量最多支持的设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,当我上传新的APK文件,我不明白为什么让我的清单文件是有很多的新手机兼容的问题。我在一个全新的宏达电Evo V 测试它,但是由于各种原因,该设备将不会显示在兼容性列表中。

我对编制17 API以最小支持10 API,使应包括绝大多数的手机。

我已经试过什么:

  • 在删除了所有权限;无变化
  • 在试图使WIFI不是必需的;无变化
  • 删除 INSTALLLOCATION 来看看它是否发挥了作用;无变化
  • 甚至试图加入小屏幕的支持,看看它是否会出现;无变化

我读过什么:

  • <一个href="http://developer.android.com/google/play/filters.html">http://developer.android.com/google/play/filters.html
  • <一个href="http://developer.android.com/guide/practices/screens-distribution.html">http://developer.android.com/guide/practices/screens-distribution.html
  • <一个href="http://developer.android.com/guide/practices/compatibility.html">http://developer.android.com/guide/practices/compatibility.html
  • <一个href="http://developer.android.com/guide/topics/manifest/manifest-intro.html">http://developer.android.com/guide/topics/manifest/manifest-intro.html

我的清单文件:

 &LT; XML版本=1.0编码=UTF-8&GT?;
&LT;舱单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
      包=com.somecompany.appname
      安卓版code =10
      机器人:VERSIONNAME =1.0
      机器人:INSTALLLOCATION =preferExternal&GT;

    &LT;! - 对于扩展包下载 - &GT;
    &LT;! - 需要访问Android Market的授权 - &GT;
    &LT;使用-权限的Andr​​oid:名称=com.android.vending.CHECK_LICENSE/&GT;
    &LT;! - 需要从Android Market下载文件 - &GT;
    &LT;使用-权限的Andr​​oid:名称=android.permission.INTERNET对/&GT;
    &LT;! - 必须保持CPU的活,同时下载文件(不保持清醒的屏幕) -  GT;
    &LT;使用-权限的Andr​​oid:名称=android.permission.WAKE_LOCK/&GT;
    &LT;! - 需要轮询网络连接的状态和变化作出反应 - &GT;
    &LT;使用-权限的Andr​​oid:名称=android.permission.ACCESS_NETWORK_STATE/&GT;
    &LT;! - 需要检查是否Wi-Fi已启用 - &GT;
    &LT;使用-权限的Andr​​oid:名称=android.permission.ACCESS_WIFI_STATE/&GT;
    &LT;! - 需要读写共享存储扩展文件 - &GT;
    &LT;使用-权限的Andr​​oid:名称=android.permission.WRITE_EXTERNAL_STORAG​​E/&GT;

    &LT;使用-SDK安卓的minSdkVersion =10机器人:targetSdkVersion =17/&GT;
    &LT;支持屏安卓normalScreens =真/&GT;
    &LT;支持屏安卓largeScreens =真/&GT;
    &LT;支持屏安卓xlargeScreens =真/&GT;

    &LT;兼容屏&GT;
        &LT;屏幕的Andr​​oid:屏幕大小=正常的Andr​​oid版本:screenDensity =MDPI/&GT;
        &LT;屏幕的Andr​​oid:屏幕尺寸=大片机器人:screenDensity =华电国际/&GT;
        &LT;屏幕的Andr​​oid:屏幕尺寸=XLARGE机器人:screenDensity =xhdpi/&GT;
    &LT; /兼容屏&GT;
    &lt;应用机器人:图标=@可绘制/图标机器人:标签=@字符串/ APP_NAME机器人:allowBackup =假&GT;
        &LT;活动机器人:名称=somecompany.appname.SplashScreen
                  机器人:标签=@字符串/ APP_NAME
                  机器人:主题=@安卓风格/ Theme.NoTitleBar
                  机器人:screenOrientation =画像&GT;
            &LT;意向滤光器&gt;
                &lt;作用机器人:名称=android.intent.action.MAIN/&GT;
                &LT;类机器人:名称=android.intent.category.LAUNCHER/&GT;
            &所述; /意图滤光器&gt;
        &LT; /活性GT;
        &LT;活动机器人:名称=somecompany.appname.SoundAndCallActivity机器人:screenOrientation =画像安卓主题=@安卓风格/ Theme.NoTitleBar/&GT;
        &LT;活动机器人:名称=somecompany.appname.MainScreenActivity机器人:screenOrientation =画像安卓主题=@安卓风格/ Theme.NoTitleBar/&GT;
        &LT;活动机器人:名称=somecompany.appname.SettingsActivity机器人:screenOrientation =画像安卓主题=@风格/ Theme.Transparent/&GT;
    &LT; /用途&gt;
&LT; /舱单&GT;
 

解决方案

我想发布此问题和的答案,因为我发现这是这么折腾找出在第一。然而,这种改变支持的设备我的号码从499到1968年。希望这将有助于更多的人在未来,因为它似乎是一个不起眼的话题。

技术1:为什么越来越多的设备将不会出现的原因是因为谷歌的过滤器更积极,当您使用&LT;兼容屏&GT; 标记。就我而言,我没有足够的不同的屏幕大小和密度的组合,所以它过滤掉所有那些我离开了(见下面技术2)。

如果你不是只使用&LT;支持屏/&GT; 标签,那么你将使你的应用程序可以通过更多的设备中。所以,请你帮个忙,并删除所有其它标签的&LT;兼容屏&GT;

您可以使用的简易模式是这样的:

 &LT;支持屏安卓largeScreens =真正的机器人:normalScreens =真正的机器人:smallScreens =真正的机器人:anyDensity =真正的&GT;&LT; /支持屏&GT;
 

原创文章:

  

谷歌播放滤镜的应用如果设备屏幕尺寸和   密度不符合任何屏幕配置(声明由   画面元素),在兼容屏的元素。

     

注意:通常情况下,你不应该使用这个清单元素。运用   这个元素可以极大地减少对潜在用户群的   应用,通过排除屏幕尺寸和密度的所有组合   您还没有上市。而应该使用   支持屏清单元素(在上述表1),以   启用屏幕兼容模式的屏幕配置有   未占用替代资源

技术2::您可以使用的另一个技巧就是要更加的的具体的与你的&LT;兼容屏&GT; 标签,并摆脱了&LT的,支持屏/&GT; 标签。您可以在您的应用程序的要求,也对最新的设备分配数量的基础这些决定。

在下面的例子中,我不想支持小屏幕或正常的,大的,或XLARGE屏幕的 LDPI 密度,所以我离开了他们。

 &LT;兼容屏&GT;
    &LT;! - 一切正常尺寸的屏幕 - &GT;
    &LT;屏幕的Andr​​oid:屏幕大小=正常的Andr​​oid版本:screenDensity =MDPI/&GT;
    &LT;屏幕的Andr​​oid:屏幕大小=正常的Andr​​oid版本:screenDensity =华电国际/&GT;
    &LT;屏幕的Andr​​oid:屏幕大小=正常的Andr​​oid版本:screenDensity =xhdpi/&GT;
    &LT;! - 所有的大尺寸屏幕 - &GT;
    &LT;屏幕的Andr​​oid:屏幕尺寸=大片机器人:screenDensity =MDPI/&GT;
    &LT;屏幕的Andr​​oid:屏幕尺寸=大片机器人:screenDensity =华电国际/&GT;
    &LT;屏幕的Andr​​oid:屏幕尺寸=大片机器人:screenDensity =xhdpi/&GT;
    &LT;! - 所有XLARGE尺寸屏幕 - &GT;
    &LT;屏幕的Andr​​oid:屏幕尺寸=XLARGE机器人:screenDensity =MDPI/&GT;
    &LT;屏幕的Andr​​oid:屏幕尺寸=XLARGE机器人:screenDensity =华电国际/&GT;
    &LT;屏幕的Andr​​oid:屏幕尺寸=XLARGE机器人:screenDensity =xhdpi/&GT;
&LT; /兼容屏&GT;
 

I am having issues getting my Manifest file to be compatible with a lot of the newer phones when I upload a new APK file and I don't understand why. I am testing it on a brand new HTC Evo V, but for whatever reason, that device won't show up in the compatibility list.

I'm compiling against API 17 with a minimum support of API 10, so that should encompass a large majority of the phones.

What I've tried:

  • Removed all permissions; no change
  • Tried making WIFI not required; no change
  • Removed installLocation to see if it made a difference; no change
  • Even tried adding small screen support to see if it'd show up; no change

What I've read:

My manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.somecompany.appname"
      android:versionCode="10"
      android:versionName="1.0"
      android:installLocation="preferExternal">

    <!-- For expansion pack downloads -->
    <!-- Required to access Android Market Licensing -->
    <uses-permission android:name="com.android.vending.CHECK_LICENSE" />
    <!-- Required to download files from Android Market -->
    <uses-permission android:name="android.permission.INTERNET" />
    <!-- Required to keep CPU alive while downloading files (NOT to keep screen awake) -->
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <!-- Required to poll the state of the network connection and respond to changes -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!-- Required to check whether Wi-Fi is enabled -->
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <!-- Required to read and write the expansion files on shared storage -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="17"/>
    <supports-screens android:normalScreens="true"/>
    <supports-screens android:largeScreens="true"/>
    <supports-screens android:xlargeScreens="true"/>

    <compatible-screens>
        <screen android:screenSize="normal" android:screenDensity="mdpi" />
        <screen android:screenSize="large" android:screenDensity="hdpi" />
        <screen android:screenSize="xlarge" android:screenDensity="xhdpi" />
    </compatible-screens>                      
    <application android:icon="@drawable/icon" android:label="@string/app_name" android:allowBackup="false">
        <activity android:name="somecompany.appname.SplashScreen"
                  android:label="@string/app_name"
                  android:theme="@android:style/Theme.NoTitleBar"
                  android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="somecompany.appname.SoundAndCallActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar"/>
        <activity android:name="somecompany.appname.MainScreenActivity"   android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar"/>
        <activity android:name="somecompany.appname.SettingsActivity"   android:screenOrientation="portrait" android:theme="@style/Theme.Transparent"/>
    </application>
</manifest>

解决方案

I wanted to post this question and also an answer because I found this to be so frustrating to figure out at first. However, this changed my number of supported devices from 499 to 1968. Hopefully this will help more people in the future since it seems to be an obscure topic.

Technique 1: The reason why more devices wouldn't show up was because Google filters more aggressively when you use the <compatible-screens> tag. In my case, I didn't have enough of the different screen sizes and density combinations, so it filtered out all of the ones I left out (see Technique 2 below).

If you instead ONLY use the <supports-screens /> tags, then you will enable your app to be found by many more devices. So do yourself a favor and remove all of those other tags in the <compatible-screens> block.

You can use a shortform like this:

<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true"></supports-screens>

Quoted from the original article:

Google Play filters the application if the device screen size and density does not match any of the screen configurations (declared by a "screen" element) in the "compatible-screens" element.

Caution: Normally, you should not use this manifest element. Using this element can dramatically reduce the potential user base for your application, by excluding all combinations of screen size and density that you have not listed. You should instead use the "supports-screens" manifest element (described above in table 1) to enable screen compatibility mode for screen configurations you have not accounted for with alternative resources.

Technique 2: Another technique you can use is to be more specific with your <compatible-screens> tag and get rid of the <supports-screens /> tags. You can base those decisions on your app requirements and also on the latest device distribution numbers.

In the example below, I don't want to support small screens or the ldpi densities of the normal, large, or xlarge screens, so I left them out.

<compatible-screens>
    <!-- all normal size screens -->
    <screen android:screenSize="normal" android:screenDensity="mdpi" />
    <screen android:screenSize="normal" android:screenDensity="hdpi" />
    <screen android:screenSize="normal" android:screenDensity="xhdpi" />
    <!-- all large size screens -->
    <screen android:screenSize="large" android:screenDensity="mdpi" />
    <screen android:screenSize="large" android:screenDensity="hdpi" />
    <screen android:screenSize="large" android:screenDensity="xhdpi" />
    <!-- all xlarge size screens -->
    <screen android:screenSize="xlarge" android:screenDensity="mdpi" />
    <screen android:screenSize="xlarge" android:screenDensity="hdpi" />
    <screen android:screenSize="xlarge" android:screenDensity="xhdpi" />
</compatible-screens>

这篇关于优化的Andr​​oid清单文件数量最多支持的设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆