错误与Android Studio中创建新的Android项目

问题描述:

我刚刚创建了一个新的项目的Android的Android工作室,我选择了最小的SDK 9(姜饼)和活动NavigationDrawer Activity,一旦选择和创建的项目我出现以下错误:错误与Android Studio中创建新的Android项目

Error:Execution failed for task ':app:processDebugManifest'. 
> Manifest merger failed : uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library [com.android.support:design:26.0.0-alpha1] C:\xxx\xxx\.android\build-cache\bd439271136a9bc6f4bc228104359605401bab70\output\AndroidManifest.xml 
    Suggestion: use tools:overrideLibrary="android.support.design" to force usage 

我没有碰过任何东西或修改的创造了Android工作室本身我已经更新了最新版本的SDK什么。

有什么建议吗?

摇篮:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 26 
    buildToolsVersion "26.0.1" 
    defaultConfig { 
     applicationId "xx.xx.xx.seguros" 
     minSdkVersion 9 
     targetSdkVersion 26 
     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.android.support:appcompat-v7:26.+' 
    compile 'com.android.support:design:26.+' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    testCompile 'junit:junit:4.12' 
} 

发生什么它里面。 Library支持使用最低SDK版本14的设计。因此,如果您的应用程序minimumSdk版本低于此值,则不能使用此库。

你应该使用com.android.support:design:25.+如果使用com.android.support:design:26.0.0-alpha1支持的minSdkVersion 9

。您必须使用minSdkVersion 14

更新您的gradle像这样。

compileSdkVersion 26 
buildToolsVersion "26.0.1" 
defaultConfig { 
    applicationId "xx.xx.xx.seguros" 
    minSdkVersion 14  // Update it to 14 
    targetSdkVersion 26 
    versionCode 1 
    versionName "1.0" 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
} 

希望它能帮助:)

+0

谢谢您的回答!如果我想保持sdk min为9? – Joacer

+0

你应该使用旧的设计库25.0.0也许是有效的。但不确定。 –

+0

好的谢谢,我会试试这个! – Joacer

我已经发现了两个解决方案,以消除此错误,但我不知道哪一个将是最正确的

I)下载版本,为此,你必须使用版本25修改的build.gradle而不是26如下:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "26.0.1" 
    defaultConfig { 
     applicationId "xx.xx.xx.seguros" 
     minSdkVersion 9 
     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.android.support:appcompat-v7:25.+' 
    compile 'com.android.support:design:25.+' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    testCompile 'junit:junit:4.12' 
} 

II)使用tools: overrideLibrary,你必须通过添加以下修改清单:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="es.uv.lisitt.seguros" 
    xmlns:tools="http://schemas.android.com/tools"> 

    <uses-sdk tools:overrideLibrary="android.support.design, android.support.v7.appcompat,android.support.graphics.drawable, android.support.v7.recyclerview, android.support.v4, android.support.mediacompat, android.support.fragment, android.support.coreui, android.support.coreutils, android.support.compat"/> 

    ..... 
</manifest> 

apply plugin: 'com.android.application' 

android { 
compileSdkVersion 26 
buildToolsVersion "26.0.0" //change 
defaultConfig { 
    applicationId "xx.xx.xx.seguros" 
    minSdkVersion 14 //change 
    targetSdkVersion 26 
    versionCode 1 
    versionName "1.0" 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 

} 

希望它有助于

+0

中所说的感谢你的回答!如果我想保持sdk min为9? – Joacer

+0

我认为sdk-9不包括导航抽屉 –

+0

你可以参考[this](http://www.recursiverobot.com/post/59404388046/implementing-the-new-navigation-drawer-in-android) –