Skip to content
/ Seal Public
forked from 2BAB/Seal

A Gradle Plugin for Prechecking AndroidManifest.xml.

License

Notifications You must be signed in to change notification settings

Mike-bel/Seal

 
 

Repository files navigation

Seal

Download Hex.pm

Seal is a gradle plugin to do precheck of Android Manifest.

English | 中文说明

Conflict / Warning When Manifest Merge

As we all know, Android provides a tool names AndroidManifest Merger to manage manifests-merge. But these rules are not enough for some situation like below:

  1. Warning: AndroidManifest.xml already defines debuggable (in http://schemas.android.com/apk/res/android); using existing value in manifest.

That's because some out-of-date libraries set debuggable at AndroidManifest, but now we use build.gradle to do it.

  1. Multiple entries with same key: @android:theme=REPLACE and android:theme=REPLACE / Multiple entries with same key: @android:allowBackup=REPLACE and android:allowBackup=REPLACE.

There is a library which defined android:allowBackup=true conflicts with yours (android:allowBackup=false). You wanna to override it using tools:replace="android:allowBackup", but find that tools:replace="android:allowBackup" is also present at lib's manifest, finally the conflict shows above. (Also see this)

...

All of these are what we face with, and Seal trying to solve.

Quick Start

  1. Compile&apply Seal plugin:
// project's build.gradle
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.1'
        classpath 'me.xx2bab.gradle:seal-manifest-precheck-plugin:1.0.0'
    }
}

...

// app's build.gradle
apply plugin: 'seal'

  1. Configurations:
def projectRoot = project.getRootProject().rootDir.absolutePath

// Folders may include AndroidManifest.xml files
// 1. For gradle plugin 2.3.0 or higher, build-cache is default choice,
// 2. But we should make sure snapshot-libs will be checked too.
// 3. Free to add your folders for more customization 
def manifestPath = [
        // for AAR of Release
        // see note below
        projectRoot + '/build-cache', 
        // for AAR of SNAPSHOT
        projectRoot + '/app/build/intermediates/exploded-aar'
]

def removeAttrs = [
        'android:debuggable'
]

def replaceValues = [
        'android:allowBackup'
]


seal {
    enabled = true
    manifests = manifestPath

    appAttrs {
        enabled = true
        attrsShouldRemove = removeAttrs
    }

    appReplaceValues {
        enabled = true
        valuesShouldRemove = replaceValues
    }
}

Note: If build-cache is enable, Seal recommends that custom build cache folder placed in the Project Folder.

//gradle.properties
android.buildCacheDir=./build-cache
...

Sample

before:

<application
        android:allowBackup="true"
        android:debuggable="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        tools:replace="android:allowBackup" >
</application>

after:

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
</application>

Changelog

v1.0.0

  • Support Removing Application Attributes
  • Support Removing Application's tools:replace value

License

Copyright 2017 2BAB

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

A Gradle Plugin for Prechecking AndroidManifest.xml.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Groovy 100.0%