google-ar / arcore-android-sdk

ARCore SDK for Android Studio
https://developers.google.com/ar
Other
4.95k stars 1.22k forks source link

Wrong obfuscation may cause illegal-access-error #943

Closed Feng23 closed 3 years ago

Feng23 commented 4 years ago

SPECIFIC ISSUE ENCOUNTERED

VERSIONS USED

STEPS TO REPRODUCE THE ISSUE

No repro, figured out the issue through static analysis. Class a.a.a is calling a package-private method android/media/Image$Plane."<init>":()V from Android SDK 28.

The caller method from a.a.a

$ javap -c arcore113/classes/a/a/a.class
Compiled from "VisibleImage.java"
public abstract class a.a.a extends android.media.Image$Plane {
  public a.a.a();
    Code:
       0: aload_0
       1: invokespecial #4                  // Method android/media/Image$Plane."<init>":()V
       4: return
}

The callee method is package-private in android sdk 28

$ javap /tmp/android-28/android/media/Image\$Plane.class
Compiled from "Image.java"
public abstract class android.media.Image$Plane {
  android.media.Image$Plane();
  public abstract int getRowStride();
  ...
}

WORKAROUNDS (IF ANY)

Do not obfuscate a.a.a, make the class be in the same package as its super class Image$Plane.

ADDITIONAL COMMENTS

devbridie commented 3 years ago

In case this is still a problem-- https://stackoverflow.com/questions/59991168/duplicate-class-names-in-two-external-third-party-obfuscated-libraries offers a work around that shadows ARCore's duplicated namespace.