question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Illegal onEvent method - ProGuard

See original GitHub issue

I am receiving this error:

Illegal onEvent method, check for typos

The error appears to be caused by a method name changing in my compile process by ProGuard. Here is a sample of the log I created to test:

methodName=onEvent modifierString= methodName=onEvent$3884d48a modifierString=$3884d48a skipMethodVerificationForClasses={}

The solution is to check for the $ character at the start of the modifierString.

This diff solves the issue:

@@ -91,7 +91,7 @@ class SubscriberMethodFinder {
                             } else if (modifierString.equals("Async")) {
                                 threadMode = ThreadMode.Async;
                             } else {
-                                if (skipMethodVerificationForClasses.containsKey(clazz)) {
+                                if (skipMethodVerificationForClasses.containsKey(clazz) || modifierString.startsWith("$")) {
                                     continue;
                                 } else {
                                     throw new EventBusException("Illegal onEvent method, check for typos: " + method);

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
sdeffcommented, Apr 20, 2015

I had an similar issue and I contacted the creator of ProGuard/DexGuard and he sent me a ‘workaround’ for this.

Just add: -keepclassmembers,includedescriptorclasses class ** { public void onEvent*(**); }

To your config file to prevent ProGuard/DexGuard’s optimization step to add a suffix to the method name.

0reactions
cs-victor-nascimentocommented, Jan 26, 2016

Stumbled upon this recently. This should be in the wiki of the project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ProGuard Java Optimizer and Obfuscator / Bugs / #585 Is it possible ...
Illegal onEvent method onEventAsync$xxxxx(fx f). and in EventBus. ThreadMode threadMode; if (modifierString.length() == 0) { threadMode = ThreadMode.
Read more >
EventBus and Proguard: Could not dispatch event
If you use a non public (package private) onEvent method you will need to update your progaurd config as follows:
Read more >
Diff - 7f9be1cbfaafe9f92f3c073a7b48bbfaa12230ba^2 ... - Google Git
IllegalStateException { method public java.lang.String getDiagnosticInfo(); } @@ -15368,6 +15383,14 @@ method public abstract void onEvent(android.media.
Read more >
ProGuard Manual: Troubleshooting - Guardsquare
You are trying to process class files compiled for a recent version of Java that your copy of ProGuard doesn't support yet. You...
Read more >
[jsoup] Caused by: java.lang.IllegalStateException: Could not ...
해결법은 proguard-ruls.pro 파일을 열고 난독화 예외 코드를 추가해야한다. □proguard-rules.pro 파일. -keep class org.jsoup.**. 모든 클래스의 예외 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found