繁体   English   中英

清单合并失败

[英]Manifest Merger Fails

因此,我从我的一个项目中得到了这个错误:

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>

这是Gradle文件:

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')
    }
}

为什么会这样呢? 我错过了什么? 非常感谢!

如果您不知道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
    }
    // ...
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM