android - 了解工具 :overrideLibrary on Android

标签 android android-manifest

我的主应用有 minSdk="14",Android 版 Facebook SDK v.4.16.1 有 minSdk="15"

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.dmitriev_m.sample_android"
        minSdkVersion 14
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.facebook.android:facebook-android-sdk:4.16.1'
    compile 'com.android.support:appcompat-v7:25.1.0'
}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.dmitriev_m.sample_android">

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="25"
        tools:overrideLibrary="com.facebook, android.support.customtabs" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="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>

这是 documentation 的内容关于合并 AndroidManifest.xml 文件:

By default, when importing a library with a minSdkVersion value that's higher than the main manifest file, an error occurs and the library cannot be imported. To make the merger tool ignore this conflict and import the library while keeping your app's lower minSdkVersion value, add the overrideLibrary attribute to the tag. The attribute value can be one or more library package names (comma-separated), indicating the libraries that can override the main manifest's minSdkVersion.

但我的合并 list 看起来像是应用覆盖了 Facebook SDK 的 list 文件(最小 SDK 为 14):

Merged Manifest, min SDK = 14

运行这个应用程序安全吗?我的意思是,当 Facebook SDK 从 Android API 15 调用方法时,应用程序应该崩溃,不是吗?

最佳答案

是的,如果库调用 API 15 函数而设备只有 API 14,它将崩溃。如果设备是 API15 或更高版本,它仍然可以工作。

不过在这种情况下我不会担心。 14 是 Anroid 3.x。只有极少数 3.x 设备制造 - Android 平板电脑直到 4.0 发布后才开始流行。使用中的 3.x 模型的百分比不到所有设备的 0.1%。如果他们不工作,真的值得花时间和精力来支持他们吗?老实说,我只是将您的 minsdk 提高到 15 或更高。 (提高到 19 只会消除 10% 的全局市场,这将严重偏向亚洲、非洲和南美洲的低收入国家。如果你的主要目标是美国和欧盟,可能不值得支持成本那个)。

关于android - 了解工具 :overrideLibrary on Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42043714/

相关文章:

java - Nougat 7.0.1 上的屏幕方向问题

android - 在不修改应用程序代码的情况下从网页重定向

android - 最多需要一个元素 <application> 命名空间为 '',但找到了 4 个

android - 为什么我的 BroadcastReceiver 收不到来自其他应用程序的广播?

android - Kotlin - @Stable 做什么?

Android 5.0 在 webview 中选择标签为空

java - Android套接字程序

android - 检测Android模拟器何时完全启动

安卓 11 | map 导航的包可见性更改

android - 如何检测是否有前置摄像头,如果有如何够到和使用前置摄像头?