pilgr / Paper

Paper is a fast NoSQL-like storage for Java/Kotlin objects on Android with automatic schema migration support.
Apache License 2.0
2.34k stars 234 forks source link

IllegalAccessException since AGP 7.0.2 everytime when Paper.book().read(key, defaultValue) is called after Paper.book().write(key, value) #188

Closed Vall0n closed 2 years ago

Vall0n commented 3 years ago

Hey @pilgr,

first of all thanks for the great library! But I found an issue which breaks my app after upgrading 'com.android.tools.build gradle (agp) to 7.0.2. It is working with agp 7.0.1, so maybe it's not this library but one of the fixes of agp 7.0.2... See agp 7.0.2 changes especially Desugaring and reproducible builds

Or maybe even in the Kryo, kryo-serializers or objenesis libraries... Which actually are not up to date, which maybe causes the issue here. But I'am just guessing.. 😅

Steps to reproduce

If I can support to fix this issue just let me know or if any information is missing.

Best regards,

Josef

pilgr commented 3 years ago

Thanks for very detailed report. It looks very weird and seems like an issue/limitation in AGP. Anyway I'll keep an eye on it.

galonga commented 3 years ago

Hey, I'm having a similar issue starting from using AGP 7.0.2. Looks like R8 / ProGuard is removing some classes and causing errors.

tmcintosh commented 3 years ago

I'm also experiencing this issue as described.

TJHello commented 2 years ago

class PaperTable --------> public class PaperTable

Vall0n commented 2 years ago

This still happens with AGP 7.0.3. Which contains following changes.

I also tried the sugessetd fix from @TJHello (thanks for that!) to make the class public but it doesn't work sadly.

RomanMinenok commented 2 years ago

@pilgr can you prioritize this fix please? I can confirm it's still happening on 7.0.3 AGP version, 7.0.0 is OK though

abalcer-ls commented 2 years ago

It looks like this is an R8 issue. If the -allowaccessmodification flag is present in proguard rules. It changes access of the default constructor to public, but keeps the class PaperTable internal:

# direct methods
.method public constructor <init>()V
    .registers 1

    .line 6
    .local p0, "this":Lio/paperdb/PaperTable;, "Lio/paperdb/PaperTable<TT;>;"
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 7
    return-void
.end method

And it doesn't allow to create instance into the Kryo library. It helped me to make the default constructor private, this does not allow R8 to change access. Making class public helped me also.

hamzaahmedkhan commented 2 years ago

Is this issue fixed now?

pilgr commented 2 years ago

Hey folks, sorry for keeping you waiting for the fix for such a long time. The good news – we have the new fixed version to try out. Please refer to this task for instructions and give your feedback https://github.com/pilgr/Paper/issues/196