Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

Annotation

Latest Update Current Stable Release Next Release Candidate Beta Release Alpha Release
October 9, 2019 1.1.0 - - -

Declaring dependencies

To add a dependency on Annotation, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.

Add the dependencies for the artifacts you need in the build.gradle file for your app or module:

dependencies {
    def annotation_version = "1.1.0"
    def annotation_experimental_version = "1.0.0-beta01"

    implementation "androidx.annotation:annotation:$annotation_version"
    // To use the Java-compatible @Experimental API annotation
    implementation "androidx.annotation:annotation-experimental:$annotation_experimental_version"
}

For more information about dependencies, see Add build dependencies.

Annotation-Experimental Version 1.0.0

Annotation-Experimental Version 1.0.0-beta01

October 9, 2019

androidx.annotation:annotation-experimental:1.0.0-beta01 and androidx.annotation:annotation-experimental-lint:1.0.0-beta01 are released with no changes since version 1.0.0-alpha01. Version 1.0.0-beta01 contains these commits.

Annotation-Experimental Version 1.0.0-alpha01

September 18, 2019

androidx.annotation:annotation-experimental:1.0.0-alpha01 and androidx.annotation:annotation-experimental-lint:1.0.0-alpha01 are released. These are the commits included in annotation-experimental 1.0.0-alpha01 and these are the commits included in annotation-experimental-lint 1.0.0-alpha01

New features

  • The Jetpack Experimental annotation library provides a Java-compatible implementation of Kotlin’s experimental API markers. The -lint artifact provides a Lint-based implementation of experimental usage restrictions and enforces restrictions on Java usages of Kotlin’s native experimental API markers.

  • When using the annotation-experimental artifact as a dependency, the Lint rules provided by the annotation-experimental-lint artifact will be enforced automatically.

Version 1.1.0

Version 1.1.0

June 5, 2019

androidx.annotation:annotation:1.1.0 is released with no changes from 1.1.0-rc01.

Version 1.1.0-rc01

May 7, 2019

androidx.annotation:annotation:1.1.0-rc01 is released with no changes from 1.1.0-beta01. The commits included in this version can be found here.

Version 1.1.0-beta01

April 3rd, 2019

androidx.annotation:annotation:1.1.0-beta01 is released. The commits included in this version can be found here.

New features

  • New @InspectablePropertyannotation to support the new view inspection APIs added in Android Q. This annotation can be applied to getters on views or other UI elements. Code generation tools may use it to create companion objects that map property names and attribute IDs to property values without the overhead of reflection.

API changes

  • Breaking change: @ContentView has been changed to a constructor annotation and the @LayoutRes value has been removed. Classes wishing to support @ContentView annotations should add this annotation to a constructor that takes a @LayoutRes int parameter. This fixes an issue when using this annotation in library modules. (b/128352521)

Version 1.1.0-alpha02

March 13, 2019

androidx.annotation:annotation:1.1.0-alpha02 is released. The full list of commits included in this version can be found here.

New features

  • New API restriction scope: RestrictTo.Scope.LIBRARY_GROUP_PREFIX. It restricts usage to code within packages whose groups share the same library group prefix up to the last . (period). For example, because libraries foo.bar:lib1 and foo.baz:lib2 share the prefix foo, they can use each other's APIs that are restricted to this scope. Similarly, for com.foo.bar:lib1 and com.foo.baz:lib2 share the com.foo. prefix and can share APIs restricted to that scope. Library com.bar.qux:lib3 however will not be able to use the restricted API because it only shares the prefix com. and not all the way until the last . (period).

Version 1.1.0-alpha01

January 30, 2019

androidx.annotation:annotation 1.1.0-alpha01 is released.

New features

  • Added a @ContentView annotation that allows you to indicate which layout XML file should be inflated. This is supported in ComponentActivity in its 1.0.0-alpha04 and Fragment in its 1.1.0-alpha04 release as an alternative to using setContentView() or overriding onCreateView(), respectively. (aosp/837619)

Version 1.0.2

Version 1.0.2

February 25, 2019

androidx.annotation:annotation 1.0.2 is released.

Bug fixes

  • Correct the R8/ProGuard rules which are embedded in the jar. These were incorrectly referencing the old android.support.annotation types instead of androidx.annotation. Note: This would have only had an impact on your builds if you were not using getDefaultProguardFile as those default rules also included correct rules for both packages. (aosp/891685)
  • Add a R8/ProGuard rule which explicitly keeps the @Keep annotation itself. This ensures that ProGuard does not remove the annotation from types prior to actually honoring its semantics. Note: This would have only had an impact on your builds if you were not using getDefaultProguardFile as those default rules also included correct rules for both packages. (aosp/903818)