0

I have already read about this question but my case I think is different: IllegalMonitorStateException on wait() call

I'm using java on Android studio. The error I get it is the following:

MiniatureAnnotations: Problem annotating via GMS.
    java.lang.IllegalMonitorStateException: object not locked by thread before wait()
        at java.lang.Object.wait(Native Method)
        at java.lang.Object.wait(Object.java:422)
        at jaw.a(PG:20)
        at hnt.b(PG:115)
        at com.google.android.apps.messaging.shared.datamodel.action.GenericWorkerQueueAction.b(PG:81)
        at eqs.run(PG:1)
        at yya.run(PG:3)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at yws.run(PG:4)
        at java.lang.Thread.run(Thread.java:764)

I'm not using a lock on an object but synchronized the method. Such as:

public synchronized static boolean send(Repository repository, Context context) {
   //  code... [I do not use wait or notify]
}

or:

 public static synchronized void checkWorkers(Context context) {
        WorkManager workManager = WorkManager.getInstance(context);
        ListenableFuture<List<WorkInfo>> senderWorker = workManager.getWorkInfosByTag(tagSenderWorker);
        if (senderWorker.isCancelled()) {
            PeriodicSmsWorker.initializePeriodicSmsWorker(context, REPLACE_POLICY);
            updateCheckSenderWorker();
    } else if (System.currentTimeMillis() - LAST_CHECK_SENDER_WORKER > MAX_TIME_WORKER_INACTIVE) {
        updateCheckSenderWorker();
        PeriodicSmsWorker.initializePeriodicSmsWorker(context, REPLACE_POLICY);
    }
}

Why am I getting IllegalMonitorStateException if I do not use wait or notify?

Edit1: disable Dexguard based on: How to disable Dexguard?

in gradle app:

buildTypes {
        release {
            //minifyEnabled false
            minifyEnabled rootProject.ext.enableDexGuardPlugin
            //proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
dependencies {
    ...
    apply plugin: 'com.android.application'
    if(rootProject.ext.enableDexGuardPlugin) {
        apply plugin: 'dexguard'
    }
}

gradle project:

 ext {
        roomVersion = '2.2.0-beta01'
        archLifecycleVersion = '2.2.0-alpha03'
        coreTestingVersion = "2.1.0-rc01"
        enableDexGuardPlugin = false
    }

However I have the same error.

AM13
  • 661
  • 1
  • 8
  • 18

1 Answers1

3

The offensive invocation of wait() is made from the method jaw.a. If you cannot find its real name, then disable DexGuard, rebuild and run your application again. The stack trace should show the exact place where wait() without synchronized is invoked.

Alexei Kaigorodov
  • 13,189
  • 1
  • 21
  • 38