blob: ec1efb58fa19727b849067388af048b77b0303ce [file]
<html devsite="true">
<head>
<title>Keep</title>
{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %}
{% include "_shared/_reference-head-tags.html" %}
</head>
<body>
<div itemscope="" itemtype="http://developers.google.com/ReferenceObject">
<meta itemprop="name" content="Keep">
<meta itemprop="path" content="androidx.annotation">
<meta itemprop="language" content="JAVA">
</div>
<div id="header-block">
<div>
<h1>Keep</h1>
</div>
<div id="metadata-info-block">
<div id="source-link"><a href="https://cs.android.com/search?q=file:androidx/annotation/Keep.kt+class:androidx.annotation.Keep&amp;ss=androidx/platform/frameworks/support" class="external">View Source</a></div>
</div>
</div>
<div id="refdoc-switcher-placeholder"></div>
<p>
<pre>@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.annotation/-retention/index.html">Retention</a>(value&nbsp;=&nbsp;AnnotationRetention.BINARY)<br>@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.annotation/-target/index.html">Target</a>(allowedTargets&nbsp;=&nbsp;[AnnotationTarget.FILE,&nbsp;AnnotationTarget.ANNOTATION_CLASS,&nbsp;AnnotationTarget.CLASS,&nbsp;AnnotationTarget.ANNOTATION_CLASS,&nbsp;AnnotationTarget.CONSTRUCTOR,&nbsp;AnnotationTarget.FUNCTION,&nbsp;AnnotationTarget.PROPERTY_GETTER,&nbsp;AnnotationTarget.PROPERTY_SETTER,&nbsp;AnnotationTarget.FIELD])<br>@<a href="https://developer.android.com/reference/java/lang/annotation/Target.html">Target</a>(value&nbsp;=&nbsp;[ElementType.PACKAGE,&nbsp;ElementType.TYPE,&nbsp;ElementType.ANNOTATION_TYPE,&nbsp;ElementType.CONSTRUCTOR,&nbsp;ElementType.METHOD,&nbsp;ElementType.FIELD])<br>public annotation <a href="/reference/androidx/annotation/Keep.html">Keep</a></pre>
</p>
<hr>
<p>Denotes that the annotated element should not be removed when the code is minified at build time. This is typically used on methods and classes that are accessed only via reflection so a compiler may think that the code is unused.</p>
<p>Do not use this within library code. As a best practice, minification should be able to remove all library code for libraries that are added as dependencies but not used. For library code, consider instead using conditional keep rules. E.g.: -if ... -keep ...</p>
<p>Example:</p>
<pre class="prettyprint">@Keep<br>public void foo() {<br> ...<br>}</pre>
<h2>Summary</h2>
<div class="devsite-table-wrapper">
<table class="responsive">
<colgroup>
<col width="40%">
<col>
</colgroup>
<thead>
<tr>
<th colspan="100%"><h3>Public constructors</h3></th>
</tr>
</thead>
<tbody class="list">
<tr>
<td>
<div><code><a href="/reference/androidx/annotation/Keep.html#Keep()">Keep</a>()</code></div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="list">
<h2>Public constructors</h2>
<div class="api-item"><a name="Keep--"></a><a name="keep"></a>
<div class="api-name-block">
<div>
<h3 id="Keep()">Keep</h3>
</div>
</div>
<pre class="api-signature no-pretty-print">public&nbsp;<a href="/reference/androidx/annotation/Keep.html#Keep()">Keep</a>()</pre>
</div>
</div>
</body>
</html>