指定额外的XML的摇篮,产生AndroidManifest [英] Specifying extra XML for gradle-generated AndroidManifest

查看:204
本文介绍了指定额外的XML的摇篮,产生AndroidManifest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以指定摇篮生成AndroidManifest额外的XML领域。用的情况下,特别是,我有一个使用谷歌地图的应用程序,并且根据<一href="https://developers.google.com/maps/documentation/android/start#installing_the_google_maps_android_v2_api">their文档,应用程序必须注明:

Is it possible to specify extra XML fields for gradle-generated AndroidManifest. The use case, specifically, is that I have an app that uses google maps, and according to their documentation, the app must specify:

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

在AndroidManifest。如果你再尝试测试这个程序有摇篮,你会得到:

in the AndroidManifest. If you then try to test this app with gradle, you'll get:

$ ./gradlew connectedCheck
<snip>
:myapp:processTestTestManifest
[manifestMerge1694110764542760523.xml:1, manifestMerge678902239503841223.xml:15] Main manifest has <uses-feature android:glEsVersion='0x00010000'> but library uses glEsVersion='0x00020000'
Note: main manifest lacks a <uses-feature android:glEsVersion> declaration, and thus defaults to glEsVersion=0x00010000.

我现在的(相关)项目结构是:

My current (relevant) project structure is:

myapp/AndroidManifest.xml
myapp/project.properties
myapp/res/
myapp/src/com/magic/package/Foo.java
myapp/tests/java/com/magic/package/test/FooTest.java

在换句话说,传统的项目结构,除了测试/ 。我也试着用添加任意AndroidManifest.xml中以的myapp /测试/ ,虽然<一href="http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Basics-and-Configuration">the文档说不是,只是作为一个测试。不过,我没有运气。

In other words, the legacy project structure except for tests/. I've also tried with adding an arbitrary AndroidManifest.xml to myapp/tests/, even though the doc says not to, just as a test. However, I had no luck.

我的 buid.gradle 是这样的:

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

apply plugin: 'android'

repositories {
    mavenCentral()
}

dependencies {
    compile project('stuff')
}

android {
    compileSdkVersion 17
    buildToolsVersion "17"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 17
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        instrumentTest.setRoot('tests')
    }
}

如果我删除使用特征,该测试将运行,但我想避免这种情况,如果可能的话。

If I remove the uses-feature, the tests will run, but I'd like to avoid that, if possible.

推荐答案

这是不可能提供自定义的属性,但它看起来像合并被打破。我得看看吧。

It's not possible to provide custom attribute but it looks like the merge is broken. I'll have to look into it.

更新:谷歌错误针对这个,这已经通过新的清单合并固定。而从清单合并用户指南

Updated: Per google bug filed for this, this has been fixed via the new manifest merger. And from manifest merger user guide

这个新的合并中引入了插件的0.10版本。截至0.11,这个工具是默认使用的摇篮插件。

This new merger was introduced in version 0.10 of the plugin. As of 0.11, this tool is used by default by the gradle plugin.

这篇关于指定额外的XML的摇篮,产生AndroidManifest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆