【问题标题】:Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 14 declared in library清单合并失败:uses-sdk:minSdkVersion 1 不能小于库中声明的版本 14
【发布时间】:2017-10-24 19:52:12
【问题描述】:

过去 5-7 小时我一直在搜索 SO 和其他 android 博客以摆脱一个错误,但不能。 在 Android Studio 中,我导入了一个旧的 eclipse 项目,但错误“清单合并失败”仍然存在

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 在 1m 30s 253ms 内完成了 227 个错误,一些错误是:

    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'.
.
.

并且在清单文件中使用 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>

我会很感激你的回答。 谢谢

【问题讨论】:

  • this Qestion 的可能重复项
  • 首先将 minSdkVersion 设置为 9 并使用旧版本的 Google Play 服务,例如 8.+。确保您已在 SDK 管理器中下载了 Google Repo。 /// + 表示“使用最新”,最新的 Google Play 服务是 11.4.2 版本,它需要支持库 26.1.0,而后者又需要编译 SDK 版本 26 和最小 SDK 版本 14。这对你来说太多了现在。
  • 也许在 Android Studio 中创建一个新项目会更容易,因为您只有一个活动。
  • @SudhirPradhan 如果可以,请发布完整的错误日志
  • @DimaKozhevin 请再看一遍 我更新了一些错误,可以帮助我们找到问题。谢谢。

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


【解决方案1】:

你应该改变:

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

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

【讨论】:

  • 我已经检查过了。但这个错误仍然存​​在。所以我注释掉了这些行。谢谢。
  • @SudhirPradhan 当您尝试我的回答时,您无法收到此错误uses-sdk:minSdkVersion 1 cannot be smaller than version 14 declared in library [com.google.android.gms:play-services:11.0.4]
  • 确实如此..因为我已经检查过了..当我使用 minsdkversion 时,我得到了一堆全新的错误
  • @SudhirPradhan 我为您留下了几个链接作为更新。我希望他们能帮助你。
  • 我已经更新了一些错误的问题..请参阅..我也使用 com.google.android.gms:play-services:11.4.2 检查但没有用
【解决方案2】:

如果您在项目中使用 AppCompatActivity,那么您需要更改 minSdkVersion 14 for com.android.support:appcompat-v7:26.1.0 在 build.gradel 文件中

    minSdkVersion 14
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"

【讨论】:

    【解决方案3】:

    任何来自 libGDX 的人,在您的 game-project/android/build.gradle 中将您的 minSdkVersion 从 14 更改为 16。例如:

    defaultConfig {
    // other config options...
        minSdkVersion 16
    }
    

    【讨论】:

      猜你喜欢
      • 2017-12-18
      • 1970-01-01
      • 2014-12-02
      • 1970-01-01
      • 1970-01-01
      • 2020-12-31
      • 1970-01-01
      • 2015-07-24
      • 2019-11-26
      相关资源
      最近更新 更多