How do I use tools:overrideLibrary in a build.gradle file?

前端 未结 9 1783
慢半拍i
慢半拍i 2020-11-28 18:00

I\'m using the leanback libraries, which require Android 17 or later. However my app supports a minSDK of 16, so I get a build error from gradle saying

Erro         


        
相关标签:
9条回答
  • 2020-11-28 18:22

    As library requires minSdkVersion 17 then you can change the same in build.gradle(Module:Application) file:

    defaultConfig {
            minSdkVersion 17 
            targetSdkVersion 25
    }
    

    and after that building the project should not throw any build error.

    0 讨论(0)
  • 2020-11-28 18:23

    As soulution for all libraries we can match sdk version of them so no unexpected event may happen

    subprojects { 
    afterEvaluate {project -> 
        if (project.hasProperty("android")) { 
            android { 
                compileSdkVersion 28 
                buildToolsVersion '28.0.3'
                defaultConfig {
                    //It's kinda tricking android studio but anyway it works
                    minSdkVersion 17
                }
            } 
        } 
        if (project.hasProperty("dependencies")) {
            dependencies {
                implementation 'com.android.support:support-core-utils:28.0.0'
                implementation 'com.android.support:appcompat-v7:28.0.0'
                implementation 'com.google.android.gms:play-services-base:16.1.0'
            }
        }
    } 
    }
    

    Remove libraries that you do not use in your project (gms) and make sure that sdk version matches your app level gradle data

    0 讨论(0)
  • 2020-11-28 18:23

    Use overrideLibrary when the minSdk is declared in build.gradle instead of in AndroidManifest.xml

    If you are using Android Studio:

    add <uses-sdk tools:overrideLibrary="android.support.v17.leanback"/> to your manifest, don't forget to include xmlns:tools="http://schemas.android.com/tools" too.

    0 讨论(0)
  • 2020-11-28 18:28

    use this code in manifest.xml

    <uses-sdk
    android:minSdkVersion="16"
    android:maxSdkVersion="17"
    tools:overrideLibrary="x"/>
    
    0 讨论(0)
  • 2020-11-28 18:29

    I just changed minSdkVersion="7" in C:\MyApp\platforms\android\CordovaLib\AndroidManifest.xml and it worked.

    Steps:

    1. Path: C:\MyApp\platforms\android\CordovaLib\AndroidManifest.xml
    2. Value: <uses-sdk android:minSdkVersion="7"/>
    3. Ran command in new cmd prompt:

      C:\MyApp>phonegap build android --debug [phonegap] executing 'cordova build android --debug'... [phonegap] completed 'cordova build android --debug'

    0 讨论(0)
  • 2020-11-28 18:32

    just changed only android:minSdkVersion="16" and it's work perfect C:\MyApp\platforms\android\CordovaLib\AndroidManifest.xml

    0 讨论(0)
提交回复
热议问题