android - list 合并失败 : uses-sdk:minSdkVersion 1 cannot be smaller than version 14 declared in library

标签 android gradle android-gradle-plugin google-play-services android-manifest

在过去的 5-7 个小时里,我一直在搜索 SO 和其他 android 博客,以消除一个错误,但未能成功。 在 Android Studio 中,我导入了一个旧的 eclipse 项目,但是错误“Manifest merger failed”仍然存在

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 14 declared in library [com.google.android.gms:play-services:11.0.4] C:\Users\.android\build-cache\857c11d37cd8661c3d52cb060657f8bf3635bb7a\output\AndroidManifest.xml
    Suggestion: use tools:overrideLibrary="com.google.android.gms.play_services" to force usage

当我检查在 build.gradle 中提及 minSdkVersion 然后我得到 Gradle build finished with 227 error(s) in 1m 30s 253ms 一些错误是:

    Z:\#1 ready\others\UVPlayermasterpart1\HoppingBird\app\build\intermediates\res\merged\debug\values-ldltr-v21\values-ldltr-v21.xml
    Z:\#1 ready\others\UVPlayermasterpart1\HoppingBird\app\build\intermediates\res\merged\debug\values-v21\values-v21.xml
Error:(17) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.
Error:(19) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large.Inverse'.
Error:(280) Error retrieving parent for item: No resource found that matches the given name '@android:style/Theme.Material.Light.DialogWhenLarge.NoActionBar'.
Error:(27) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.SearchResult.Subtitle'.
Error:(106, 21) No resource found that matches the given name: attr 'android:colorAccent'.
.
.
.
.Error:(203, 21) No resource found that matches the given name: attr 'android:overlapAnchor'.
.
.

在 list 文件中使用 overrideLibrary 无效。

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion "26.0.2"

    defaultConfig {
        applicationId "bb.hoppingbird"
        //minSdkVersion 14
        //targetSdkVersion 19
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:19.1.0'
    compile 'com.google.android.gms:play-services:+'
}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="bb.hoppingbird"
    android:versionCode="1"
    android:versionName="1.0">

    <supports-screens
        android:xlargeScreens="true"
        android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:anyDensity="false" />

    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name">

        <activity
            android:name="bb.hoppingbird.MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="landscape"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            android:configChanges="orientation">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- Ads Using Google Play Services SDK -->
        <meta-data android:name="com.google.android.gms.version"
               android:value="@integer/google_play_services_version"/>

        <activity android:name="com.google.android.gms.ads.AdActivity"
             android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
    </application>

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.RESTART_PACKAGES"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />

</manifest>

非常感谢您的回答。 谢谢

最佳答案

你应该改变:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion "26.0.2"

    defaultConfig {
        applicationId "bb.hoppingbird"
        //minSdkVersion 14
        //targetSdkVersion 19
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:19.1.0'
    compile 'com.google.android.gms:play-services:+'
}

到:

apply plugin: 'com.android.application'
repositories {
    maven { url 'https://maven.google.com' }
}
android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"

    defaultConfig {
        applicationId "bb.hoppingbird"
        minSdkVersion 14
        targetSdkVersion 26
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:26.1.0'
    compile 'com.google.android.gms:play-services:11.4.2'
}

更新: 请按照以下说明操作:

关于android - list 合并失败 : uses-sdk:minSdkVersion 1 cannot be smaller than version 14 declared in library,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46918951/

相关文章:

java - 如何扩展ConnectionService?

java - 如何自定义Android评级栏形状并编号1-10?

java - 访问 fragment 内的 TextView 会给出 NullPointerException

android - 如何即时更新编辑器操作按钮显示?

gradle - 在 Gradle 中,如何以编程方式排除然后强制依赖?

java - 如何生成多项目合一的 Gradle 项目?

android - 尽管存在资源,但Android资源链接失败

android - 在 Gradle 中生成声明名称不带任何后缀的 APK

android - 如何修复 ".gradle\nodejs\node-v6.7.0-win-x64\node.exe' '以非零退出值 1 完成”

android - OneSignal 和 Gradle 错误