google / google/truth

Before Android12: "NoSuchFieldError: No static field MODULE" from Guava's class-level `@NullMarked` annotations with Truth 1.4.5+

Open
#1,608 8 comments 0 reactions 0 assignees View on GitHub
P3 type=defect
Dominant language
Java
Stars
2.8k
Forks
275
Avg merge
7m
Merged PRs (30d)
4

Description

# TL'DR
I noticed that `connectedDebugAndroidTest` fails when I update truth from 1.4.4 to 1.4.5.

# Environment
- API 26
- GitHub Action

# Workflow
- https://github.com/EventFahrplan/EventFahrplan/actions/runs/18316345087/workflow

# Job
- https://github.com/EventFahrplan/EventFahrplan/actions/runs/18316345087/job/52157513254

# Error
```
> Task :database:connectedDebugAndroidTest
Starting 9 tests on emulator-5554 - 8.0.0
com.google.common.collect.ObjectCountHashMap > initializationError[emulator-5554 - 8.0.0] FAILED
java.lang.NoSuchFieldError: No static field MODULE of type Ljava/lang/annotation/ElementType; in class Ljava/lang/annotation/ElementType; or its superclasses (declaration of 'java.lang.annotation.ElementType' appears in /system/framework/core-oj.jar)
at java.lang.Class.getDeclaredAnnotations(Native Method)
com.google.common.collect.ObjectCountLinkedHashMap > initializationError[emulator-5554 - 8.0.0] FAILED
java.lang.NoSuchFieldError: No static field MODULE of type Ljava/lang/annotation/ElementType; in class Ljava/lang/annotation/ElementType; or its superclasses (declaration of 'java.lang.annotation.ElementType' appears in /system/framework/core-oj.jar)
at java.lang.Class.getDeclaredAnnotations(Native Method)
com.google.common.util.concurrent.ImmediateFuture > initializationError[emulator-5554 - 8.0.0] FAILED
java.lang.NoSuchFieldError: No static field MODULE of type Ljava/lang/annotation/ElementType; in class Ljava/lang/annotation/ElementType; or its superclasses (declaration of 'java.lang.annotation.ElementType' appears in /system/framework/core-oj.jar)
at java.lang.Class.getDeclaredAnnotations(Native Method)
com.google.common.util.concurrent.ListenableFutureTask > initializationError[emulator-5554 - 8.0.0] FAILED
java.lang.NoSuchFieldError: No static field MODULE of type Ljava/lang/annotation/ElementType; in class Ljava/lang/annotation/ElementType; or its superclasses (declaration of 'java.lang.annotation.ElementType' appears in /system/framework/core-oj.jar)
at java.lang.Class.getDeclaredAnnotations(Native Method)
Tests on emulator-5554 - 8.0.0 failed: There was 4 failure(s).
Finished 9 tests on emulator-5554 - 8.0.0
> Task :database:connectedDebugAndroidTest FAILED
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.