adding play-services-maps dependancy auto adds glE

2019-07-05 18:05发布

I'd like to integrate with Google Play Services Maps module.

Since the maps manifest declare:

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

Gradle's manifest merger adds this block to the resulting manifest making my app not supported on devices running OpenGL 1.0, however my Maps feature is not mandatory, and I do want to support these devices.

I've tried adding to my own manifest one of these:

<uses-feature
    android:glEsVersion="0x00010000"
    android:required="false" />

or

<uses-feature
    android:glEsVersion="0x00010000"
    android:required="false"
    tools:replace="glEsVersion,required" />

or

<uses-feature
    android:glEsVersion="0x00010000"
    android:required="false"
    tools:node="remove"
    tools:replace="glEsVersion,required"/>

But nothing works, either it automatically chooses the one with the highest value (2.0), or it adds both blocks to the resulting manifest, still making my app require 2.0

1条回答
疯言疯语
2楼-- · 2019-07-05 18:41

I was able to solve it using build.gradle hacks, by manually overriding the merged manifest source.

However I would prefer a more elegant way using Gradle's manifest merger tools (tools:node, tools:replace, etc.)

I removed the glEsVersion from AndroidManifest, and added the following to my build.gradle:

    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            output.processManifest.doLast {
                def manifestOutFile = output.processManifest.manifestOutputFile
                def newFileContents = manifestOutFile.getText('UTF-8').replace("android:glEsVersion=\"0x00020000\"", "android:glEsVersion=\"0x00010000\"")
                manifestOutFile.write(newFileContents, 'UTF-8')
            }    
        }
    }
查看更多
登录 后发表回答