2016-08-17 77 views
0

所以recenlty我已经得到这个错误我的项目之一:清单合并失败

Error:Execution failed for task ':ListViewAnimations-core-slh:processDebugAndroidTestManifest'. 
> java.lang.RuntimeException: Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 7 declared in library [android - AS:StickyListHeaders:unspecified] D:\Android\MDS\UPLOAD\android - AS\ListViewAnimations-core-slh\build\intermediates\exploded-aar\android - AS\StickyListHeaders\unspecified\AndroidManifest.xml 
    Suggestion: use tools:overrideLibrary="se.emilsjolander.stickylistheaders" to force usage 

下面是同一清单文件:

<manifest package="com.example.listviewanimations.slh" xmlns:android="http://schemas.android.com/apk/res/android"> 

    <application android:allowBackup="true"> 
    </application> 

</manifest> 

这里是摇篮文件:

apply plugin: 'android-library' 

dependencies { 
    compile fileTree(dir: 'libs', include: '*.jar') 
    compile project(':ListViewAnimations-core') 
    compile project(':StickyListHeaders') 
} 

android { 
    compileSdkVersion 21 
    buildToolsVersion "22.0.1" 

    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_7 
     targetCompatibility JavaVersion.VERSION_1_7 
    } 

    sourceSets { 
     main { 
      manifest.srcFile 'AndroidManifest.xml' 
      java.srcDirs = ['src'] 
      resources.srcDirs = ['src'] 
      aidl.srcDirs = ['src'] 
      renderscript.srcDirs = ['src'] 
      res.srcDirs = ['res'] 
      assets.srcDirs = ['assets'] 
     } 

     // Move the tests to tests/java, tests/res, etc... 
     instrumentTest.setRoot('tests') 

     // Move the build types to build-types/<type> 
     // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 
     // This moves them out of them default location under src/<type>/... which would 
     // conflict with src/ being used by the main source set. 
     // Adding new build types or product flavors should be accompanied 
     // by a similar customization. 
     debug.setRoot('build-types/debug') 
     release.setRoot('build-types/release') 
    } 
} 

这是怎么发生的?我错过了什么? 非常感谢!

+0

什么是'minSdkVersion'在'build.gradle'文件?您需要将其更改为至少7,如错误消息所述。 –

+0

@ Code-Apprentice实际上我找不到这一行!我已经添加了gradle文件! –

+0

[Manifest合并失败:uses-sdk:minSdkVersion 8不能小于]的可能重复(http://stackoverflow.com/questions/24718824/manifest-merger-failed-uses-sdkminsdkversion-8-cannot-be-smaller) –

回答

1

如果您不知道Android Studio如何为Android应用程序创建清单文件,则此错误消息可能有点误导。在这种情况下,了解在生成清单文件时使用的app/build.gradle中有很多变量是很重要的。具体而言,错误消息引用了minSdkVersion值。您应该打开app/build.gradle并找到包含此变量的行。然后将其值更改为7或更大。事实上,目前许多应用程序使用的至少16

的值修改build.gradle如下:

android { 
    compileSdkVersion 21 
    buildToolsVersion "22.0.1" 

    defaultConfig { 
     minSdkVersion 7 // This can be any number greater than 7 
    } 
    // ... 
} 
+0

我很笨,但我找不到线!我已经在问题中添加了我的Gradle文件,请你指出!非常感谢。 –

+0

@jeet没问题。它看起来像你的'build.gradle'文件没有它。你是从某处复制这个文件还是由某种工具生成的?它看起来与我熟悉的'build.gradle'文件不同,它是在您开始一个新项目时由Android Studio生成的。 –

+0

谢谢。我实际上从网站上购买了这个模板来启动我的开发,现在看来我已经放慢了速度! –