Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
454 views
in Technique[技术] by (71.8m points)

android - Disable dependency permissions

I'm facing the following problem at the moment:

I have developed app 'A' which uses permissions 1, 2, 3 and uses an 3rd party library 'B' as a dependency (added using maven & gradle).

Library 'B' uses the permissions 4 and 5. Now when building the app, the manifest merger adds the permissions 4 and 5 to app 'A'.

How can I prevent this and only have the permissions 1, 2 and 3 in the final manifest?

My first guess would be using one of the manifest merger markers as seen here: http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger#TOC-Markers

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to use Selector

Each tools:node or tools:attr declaration can be augmented by a tools:selector attribute which is contextual information on whether or not the merging strategy should be applied to the current lower priority XML description. For instance, this is useful when removing a permission only if coming for one particular library as opposed to any library:

<permission
      android:name="permissionOne"
      tools:node="remove"
      tools:selector="com.example.lib1">

It would be next according your initial requirements

<!--suppress AndroidDomInspection -->
<uses-permission
    tools:node="removeAll"/>

but keep in mind that all other <uses-permissions/> will be removed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...