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

Transformer-api breaks MoshiX generated adapters #7798

Open
hrach opened this issue Apr 5, 2023 · 1 comment
Open

Transformer-api breaks MoshiX generated adapters #7798

hrach opened this issue Apr 5, 2023 · 1 comment

Comments

@hrach
Copy link

hrach commented Apr 5, 2023

How frequently does the bug occur?

Always

Description

When we combine MoshiX's Kotlin Compiler plugin with realm using transformer api, our production build misses generated JsonAdapters. Adding a custom rule for R8 adds them back. So the best guess is that realm is somehow blocking Moshi from generating custom rules or removing custom rules, tbh no idea.

Originally reported here: ZacSweers/MoshiX#396

Stacktrace & log output

No response

Can you reproduce the bug?

Always

Reproduction Steps

The reproduction is attached.

moshigradlecrash-full.zip

Version

10.13.3-transformer-api

What Atlas App Services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

MacOS

Build environment

Android Studio version: AS 2022.1.1
Android Build Tools version: AGP's default.
Gradle version: AGP 7.4

@rorbech
Copy link
Collaborator

rorbech commented Apr 12, 2023

I tried to investigate the app/build/outpus/mapping/release/configuration.txt and it seems like the MoshiX defined rules are not picked up when you apply the realm-plugin. After dumping the inputs and outputs of app:mergeReleaseGeneratedProguardFiles with and without applying the realm-plugin it shows that the MoshiX generated rules are not added as inputs when applying the plugin.

Without realm plugin:

> Task :app:mergeReleaseGeneratedProguardFiles
inputs:
        ../moshigradlecrash/app/build/generated/moshix/release/resources/META-INF/proguard/moshi-com.example.moshigradlecrash.Test.pro
outputs:
        ../moshigradlecrash/app/build/intermediates/generated_proguard_file/release/proguard.txt

With realm plugin:

> Task :app:mergeReleaseGeneratedProguardFiles UP-TO-DATE
inputs:
outputs:
        ../moshigradlecrash/app/build/intermediates/generated_proguard_file/release/proguard.txt

I can't find the tasks that actually generates that output, so have a hard time tracing the dependencies. Maybe the files are attached to a task that is somehow not triggered when the new transformer pipeline is in effect. (Or maybe we somehow fail to pick up the resource files.) But the convention about putting the proguard configuration in resource/META-INF/ seems off, so wouldn't expect it to be the way to go and would think that the wiring of generated proguard rules to the mergeReleaseGeneratedProguardFiles should be reworked to match the new transformer API in MoshiX.

As a workaround you could maybe just add the generated proguard configuration to android.buildTypes.release.proguardFiles and add the appropriate task dependencies if you can locate the task that generates it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants