android - 这是什么意思 <uses-sdk tools :overrideLibrary ="com.google.android.gms"/> in Android

标签 android android-studio

我正在使用 Android Studio 1.0.2,其中我有以下 build.gradle。

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

如果我不在 AndroidManifest.xml 中写这个,Android Studio 会给我一个错误.

<uses-sdk tools:overrideLibrary="com.google.android.gms" />

早于最新版本的 Android Studio。我必须写这个

<uses-sdk tools:node="replace" />

这到底是什么 <uses-sdk tools:node="replace" /><uses-sdk tools:overrideLibrary="com.google.android.gms" /> .

最佳答案

根据 http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger

tools:overrideLibrary marker

A special marker that can only be used with uses-sdk declaration to override importing a library which minimum SDK version is more recent than that application's minimum SDK version. Without such a marker, the manifest merger will fail. The marker will allow users to select which libraries can be imported ignoring the minimum SDK version.

并根据http://www.reddit.com/r/androiddev/comments/297xli/howto_use_the_v21_support_libs_on_older_ve

Version 0.11 of the Android Gradle Plugin turned on a new Manifest Merger by default, and it allows us to do some nifty stuff (read more about it here). In the manifest above, I'd included a uses-sdk node that simply specifies a tools:node attribute. This specific configuration tells the manifest processor to replace any attributes from uses-sdk nodes in lower-priority manifests (such as library manifests) with the attributes in the uses-sdk node with the tools:node="replace" attribute. Since Gradle also inserts minSdkVersion and targetSdkVersion from your build.gradle into this uses-sdk node, that's all we really need to add. Now you should be able to run your application on any device supported by your minSdkVersion, while taking advantage of the neat new views and utilities in the support lib!

关于android - 这是什么意思 <uses-sdk tools :overrideLibrary ="com.google.android.gms"/> in Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27590907/

相关文章:

android - 如何从 Firebase Storage 下载文件到 Android 的 External_Storage

Android Studio Leanback 隐藏状态栏

android-studio - 如何在 Android Studio 中将 "run project"工具栏更改为默认值

java - 为什么 PendingIntent 会被触发?

android - 在哪里可以找到 Xamarin Android 在 Visual Studio 中创建的 keystore 的默认位置?

android - Fragment 将所有导航控制委托(delegate)给 Activity 是个好主意吗?

Android创建联系人问题

android - 如何获取安卓:layout_gravity ="bottom" to work in LinearLayout

java - 对象化后端和客户端之间的 Key/Ref 往返 [无 GWT]

android - 将android应用程序中布局的背景颜色与kotlin进行比较