Manifest merger failed : uses-sdk:minSdkVersion 10

2019-01-13 06:01发布

问题:

Got the above error after downloading L preview release version in Android Studio, when my project had minSdkVersion 19.

Furthermore, when setting mindSdkVersion as below:

defaultConfig {
....
          minSdkVersion 'L'
....
    }

I get dozens of errors as below, regarding resources from AppCompat-v7-21 :

/home/user/workspace/project/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0-rc1/res/values-v21/values.xml
Error:Error retrieving parent for item: No resource found that matches the given name '@android:TextAppearance.Material.SearchResult.Subtitle'.

So I have 2 questions:

  1. Why does AS complain about minSdkVersion ? I presume because AppCompat-v7 21 supports only L release; but why ? Also, will it support only L release when it is going to be officially released in autumn too ? Because that would be a problem... Or is it just a temporary restriction in order for apps not be be pushed to Play Store, as specified in the Google I/O 2014 Keynote ?
  2. Why does AppCompat-v7 21 complain about those errors, as I already set mindSdkVersion to L ?

回答1:

compileSdkVersion 'android-L'

BOOM. Done.

LAST EDIT: As of Android 5.0 release, this is no longer an issue, just target API level 21 directly.

Edit for clarity: Indeed as David_E specified below, this solution only works for L version, if you try to deploy the app on a device below L (ex <=4.4.4) it will complain of OLD_SDK. In order for the app to work pre-L you still need to use the old v20 support lib + app compat + targetVersionSdk and compileVersionSdk

dependencies {

        compile 'com.android.support:appcompat-v7:20.+'
        compile 'com.android.support:support-v4:20.+'
    }

    android {
        compileSdkVersion 20
        buildToolsVersion '20'

        defaultConfig {
            applicationId "com.example.application"
            minSdkVersion 10
            targetSdkVersion 20
            versionCode 1
            versionName "1.0"
        }
}


回答2:

The answer stated here may not work properly, as it will make your app only work for Android L.

In order to conserve the backward compatibility with older Android OS versions, change the gradle dependecy

From:

compile 'com.android.support:appcompat-v7:+'

To:

compile 'com.android.support:appcompat-v7:20.+'

Note that the error complains about com.android.support:appcompat-v7:21.0.0-rc1, the reason for that is that using appcompat-v7:+ will tell gradle to import the latest dependency of the appcompat-v7 library, unfortunately this latest version is only working for Android L, so we have to point to a previous version.

Hopefully Google will fix this in the near future.



回答3:

The way that worked for me was to install the Android Studio Beta (Not Preview Release, the Beta was launched today as part of IO).

Uninstall the preview release and install the Beta and open your project. It will ask you to use project SDK or Studio SDK, use Android Studio's SDK.

Go to your projects local.properties file and where you have sdk.dir ensure that any backslashes () are doubled up .e.g. \.

Go to Project Structure > SDK and ensure this pointing to the Android SDK on my Pc it was C:\Program Files(x86)\Android\android-studio\SDK.

Then in your projects and any libraries you have build.gradle files where you have

compile 'com.android.support:support-v4 Change it to compile 'com.android.support:support-v4:20+

Resync the gradle files and all fixed



回答4:

To force working with a working version Just change the gradle dependencies like this:

dependencies {
    compile 'com.android.support:gridlayout-v7:19.0.1'
    compile 'com.android.support:appcompat-v7:19+'
    ...
}

was:

compile 'com.android.support:appcompat-v7:+'

N.B.

I updated Tools & Extras in the SDK manager.

after the project was broken I fixed it as shown above.

For now I do not update android L & 4.4W (enough bugs for today :-( )



回答5:

Thanks David for your answer!

I had to change

compile 'com.android.support:support-v13:+'

To:

compile 'com.android.support:support-v13:20.+'

And everything work perfect now.



回答6:

Just in addition: The other answers here did not fix the problem for me, but I found an alternate way to fix the android-l problem on Android Studio 0.8.0. After I did change the dependencies in the build.gradle, the problem sadly kept occuring, that the code would say OLD_SKD. I'm using a Galaxy S2.

Apart from changing all things to :19+:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19+'
    compile 'com.android.support:support-v4:19+'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.android.support:mediarouter-v7:19+'
}

It still would not work, so I had to move back everywhere possible:

android {
    compileSdkVersion 19
    buildToolsVersion '19.1'
    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 19
        versionCode 1
        versionName '1.0'
    }

Now the app works again on the phone. I should probably get a new mobile, but for now, I hope this may help someone.