【问题标题】:uses-library in AndroidManifest.xmlAndroidManifest.xml 中的使用库
【发布时间】:2010-08-09 00:35:26
【问题描述】:

我目前在我的 AndroidManifest.xml 中有这个

使用库 android:name="com.google.android.maps" android:required = "false"

google map api 的指定要求不是强制性的。 (这使我能够在非 google-api 模拟器上安装我的应用程序)

但是,这仅适用于 API 级别 7,平台 2.1 不适用于 API 级别 4、平台 1.6

我在编译时收到一条错误消息-“在包'android'中找不到属性'required”的资源标识符

但是,当我在这里查看文档时: http://developer.android.com/guide/topics/manifest/uses-feature-element.html

从第 4 级开始引入了“必需”属性。

谁能帮帮我!


谢谢艾琳

我认为不可能在 uses-library 标记中包含必需的属性。

有没有办法在 java 代码中而不是在 AndroidManifest.xml 中包含使用库??

【问题讨论】:

    标签: android


    【解决方案1】:

    Android 文档似乎已更新:

    属性:

    android:required
        Boolean value that indicates whether the application requires the library specified by android:name:
    
            "true": The application does not function without this library. The system will not allow the application on a device that does not have the library.
            "false": The application can use the library if present, but is designed to function without it if necessary. The system will allow the application to be installed, even if the library is not present. If you use "false", you are responsible for checking at runtime that the library is available.
    
            To check for a library, you can use reflection to determine if a particular class is available.
    
        The default is "true".
    
        Introduced in: API Level 7.
    

    http://developer.android.com/guide/topics/manifest/uses-library-element.html

    【讨论】:

      【解决方案2】:

      uses-library 没有 required 属性。来自Android docs

      <uses-library android:name="string" />
      

      您应该将其用于 Google 地图。来自Google's docs:

      <uses-library android:name="com.google.android.maps" />
      

      具有required 属性的是uses-feature

      <uses-feature android:glEsVersion="integer"
                    android:name="string"
                    android:required=["true" | "false"] />
      

      【讨论】:

      • 是的,你是对的,但我能够为 Platform 2.1 设置必需的属性
      • @TS.xy 你不应该这样做。
      • 感谢 Aillyn,有没有办法在 java 代码中而不是在 AndroidManifest.xml 中包含使用库??
      • @TS.xy 不确定这是否可能
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-07-03
      • 2015-01-18
      • 1970-01-01
      • 2012-10-28
      • 2022-10-20
      • 1970-01-01
      • 2012-05-28
      相关资源
      最近更新 更多