2016-08-17 108 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

謝謝。我實際上從網站上購買了這個模板來啓動我的開發,現在看來我已經放慢了速度! –