# KeepRules

[View Source](https://cs.android.com/search?q=file:com/android/build/api/dsl/KeepRules.kt+class:com.android.build.api.dsl.KeepRules) Added in 7.3.0


```
interface KeepRules
```

<br />

*** ** * ** ***

DSL object for external library dependencies keep rules configurations.

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `@https://docs.gradle.org/current/javadoc/org/gradle/api/Incubating.html [ignoreAllExternalDependencies](https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/KeepRules#ignoreAllExternalDependencies(kotlin.Boolean))(ignore: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` **This function is deprecated.** Renamed to ignoreFromAllExternalDependencies |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `@https://docs.gradle.org/current/javadoc/org/gradle/api/Incubating.html [ignoreExternalDependencies](https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/KeepRules#ignoreExternalDependencies(kotlin.Array))(vararg ids: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` **This function is deprecated.** Renamed to ignoreFrom |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/KeepRules#ignoreFrom(kotlin.Array)(vararg ids: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Ignore keep rules from listed external dependencies. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `@https://docs.gradle.org/current/javadoc/org/gradle/api/Incubating.html https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/KeepRules#ignoreFromAllExternalDependencies(kotlin.Boolean)(ignore: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Ignore keep rules from all the external dependencies. |

| ### Public properties |
|---|---|
| `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/SetProperty.html<https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html>` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/KeepRules#files()` **This property is deprecated.** Use keepRules source folder instead |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/KeepRules#ignoreFromAllExternalDependencies()` Ignore keep rules from all the external dependencies. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/KeepRules#includeDefault()` This flag will include default keep rules that enables shrinking, obfuscation, and optimization of bytecode when `optimization.enable` is on. |

## Public functions

### ignoreAllExternalDependencies

Added in 7.3.0 Deprecated in 8.4.0

```
@Incubating
fun [ignoreAllExternalDependencies](https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/KeepRules#ignoreAllExternalDependencies(kotlin.Boolean))(ignore: Boolean): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Renamed to ignoreFromAllExternalDependencies, use this instead:
>
> ```
> ignoreFromAllExternalDependencies
> ```

### ignoreExternalDependencies

Added in 7.3.0 Deprecated in 8.4.0

```
@Incubating
fun [ignoreExternalDependencies](https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/KeepRules#ignoreExternalDependencies(kotlin.Array))(vararg ids: String): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Renamed to ignoreFrom, use this instead:
>
> ```
> ignoreFrom
> ```

### ignoreFrom

Added in 8.4.0

```
fun ignoreFrom(vararg ids: String): Unit
```

Ignore keep rules from listed external dependencies. External dependencies can be specified via GAV coordinates(e.g. "groupId:artifactId:version") or in the format of "groupId:artifactId" in which case dependencies are ignored as long as they match groupId \& artifactId.

### ignoreFromAllExternalDependencies

Added in 8.4.0

```
@Incubating
fun ignoreFromAllExternalDependencies(ignore: Boolean): Unit
```

Ignore keep rules from all the external dependencies.

## Public properties

### files

Added in 8.13.0 Deprecated in 9.6.0-alpha03

```
val files: SetProperty<File>
```

> [!CAUTION]
> **This property is deprecated.**   
> Use keepRules source folder instead

Keep rules files set

### ignoreFromAllExternalDependencies

Added in 9.6.0-alpha03

```
var ignoreFromAllExternalDependencies: Boolean
```

Ignore keep rules from all the external dependencies.

### includeDefault

Added in 9.6.0-alpha03

```
var includeDefault: Boolean
```

This flag will include default keep rules that enables shrinking, obfuscation, and optimization of bytecode when `optimization.enable` is on.

Default value is true. When merging the values from build types and product flavors, if any have this as false, it will be false in the eventual variant.

It's the equivalent of using `getDefaultProguardFile("proguard-android-optimize.txt")`