任务'Project:processDebugManifest'的Gradle执行失败

use*_*889 3 android compilation gradle android-studio

我开始在Android上使用谷歌播放服务API,并在阅读了几个教程并做了几个方法后,我总是有同样的错误.

Gradle: Execution failed for task ':Teste:processDebugManifest'.
> java.lang.RuntimeException (no error message)
Run Code Online (Sandbox Code Playgroud)

要导入google play库,我将goggle-play-service_lib的粘贴复制到我的项目中,包括jar文件到我的项目结构.(我正在使用Android Studio)

最后它看起来像这样:

App AndroidManifest.xml

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

    <uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="16" />

    <permission
            android:name="com.metyou1.permission.MAPS_RECEIVE"
            android:protectionLevel="signature"/>
    <uses-permission android:name="com.metyou1.permission.MAPS_RECEIVE"/>

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

    <uses-feature
            android:glEsVersion="0x00020000"
            android:required="true"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.teste.FullscreenActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/app_name"
            android:theme="@style/FullscreenTheme" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <meta-data
                android:name="com.google.android.maps.v2.API_KEY"
                android:value="MYKEY"/>
    </application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

App build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android'

dependencies {
    compile project(':google-play-services_lib')
    compile files('libs/android-support-v4.jar')
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 16
    }
}
Run Code Online (Sandbox Code Playgroud)

google-play-services_lib build.gradle

buildscript {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android-library'

dependencies {
    compile files('libs/google-play-services.jar')
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            res.srcDirs = ['res']
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

有人可以帮帮我吗?

谢谢 ;)

Luk*_*sen 6

经过几个小时的调试后,我得到了解决方案......

[AndroidManifest.xml:3, AndroidManifest.xml:3] Main manifest has <uses-sdk android:minSdkVersion='7'> but library uses minSdkVersion='8'
Run Code Online (Sandbox Code Playgroud)

使用gradlew时出现错误消息 - 所以你需要在你的清单中将你的minSdkVerison设置为8,一切都应该正常工作

(不要忘记将项目的build.gradle编辑为minSdkVersion 8 - 我刚刚失去了半个小时但现在正在工作)

  • 但是,如果我仍然想使用minSdkVersion 7怎么办?如果我对ap​​i级别进行运行时检查,并且仅在8或更高级别时调用库,我猜我应该没问题.但它没有建立. (3认同)