Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalAccessError: Method 'int android.view.View.getWindowAttachCount()' is inaccessible #36

Closed
mlykotom opened this issue Jun 7, 2022 · 0 comments · Fixed by #37
Closed

Comments

@mlykotom
Copy link
Contributor

mlykotom commented Jun 7, 2022

When using Curtains with R8 and the proguard-android-optimize.txt file, it crashes due to missing JavaViewSpy.getWindowAttachCount.

This could be fixed by adding the method to the proguard.

-keepclassmembers class android.view.JavaViewSpy {
    static int windowAttachCount(android.view.View);
}

Stacktrace:

E AndroidRuntime: java.lang.IllegalAccessError: Method 'int android.view.View.getWindowAttachCount()' is inaccessible to class 'android.view.ViewSpyInternalKt' (declaration of 'android.view.ViewSpyInternalKt' appears in /data/app/~~VymduIXOo6hl8tOVtZTVLQ==/com.squareup.curtains.sample-CvXF72T_Jes38DnrA1SIXg==/base.apk)
 E AndroidRuntime: 	at android.view.ViewSpyInternalKt.windowAttachCount(ViewSpyInternal.kt:7)
 E AndroidRuntime: 	at com.example.macrobenchmark.target.ClickTrace$install$1.onRootViewAdded(ClickTrace.kt:7)
 E AndroidRuntime: 	at com.example.macrobenchmark.target.ClickTrace$install$1.onRootViewsChanged(ClickTrace.kt:7)
 E AndroidRuntime: 	at curtains.internal.RootViewsSpy$delegatingViewList$1.add(RootViewsSpy.kt:28)
 E AndroidRuntime: 	at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:350)
 E AndroidRuntime: 	at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:94)
 E AndroidRuntime: 	at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3880)

Steps to reproduce:

  1. Add minification and the default proguard file to the sample app
buildTypes {
    getByName("release") {
      signingConfig = signingConfigs.getByName("debug")
      minifyEnabled(true)
      proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"))
    }
  }
  1. Start the sample and observe the crash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant