Greetings, fellow colleagues! TLDR: I am facing a...
# android
d
Greetings, fellow colleagues! TLDR: I am facing a rather niche issue after updating AGP from 8.3.2 to 8.8.2 in our multimodule project, which we use to release a certain SDK. This issue is possibly related to a newer R8 being bundled with newer AGP. The details are in a thread message. Thank you!
🧵 2
c
Sound like an issue with #C19FD9681 . Better move to this channel. Also, long code snippets should go to the thread in here to not clutter he main thread. Put a tl;dr and the rest in the thread.
d
Ok, I'll edit it now, thanks.
We have
isMinifyEnabled
set to
true
in our library modules because we only expose the API relevant to our customers. One of the components being published is this:
Copy code
object LoggerProvider {

    @JvmStatic
    var logger: Logger = StubLogger()
}
It is intended to be used, for example, like this:
Copy code
private val myLoggerFromThatSdk = LoggerProvider.logger
And it was before up until our update from AGP 8.3.2 to 8.8.2. Also, if you perform a command + click on
.logger
part, you will see this:
Copy code
public object LoggerProvider {
    @kotlin.jvm.JvmStatic public final var logger: io.scanbot.sdk.util.log.Logger /* compiled code */
}
Meaning that it was recognized as Kotlin class. Also, at this point, if you click
Decompile to Java
, the code would look like this:
Copy code
@Metadata(
   mv = {2, 1, 0},
   k = 1,
   xi = 48,
   d1 = {"\u0000\u0014\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0006\bÆ\u0002\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003R$\u0010\u0004\u001a\u00020\u00058\u0006@\u0006X\u0087\u000e¢\u0006\u0014\n\u0000\u0012\u0004\b\u0006\u0010\u0003\u001a\u0004\b\u0007\u0010\b\"\u0004\b\t\u0010\n¨\u0006\u000b"},
   d2 = {"Lio/scanbot/sdk/util/log/LoggerProvider;", "", "<init>", "()V", "logger", "Lio/scanbot/sdk/util/log/Logger;", "getLogger$annotations", "getLogger", "()Lio/scanbot/sdk/util/log/Logger;", "setLogger", "(Lio/scanbot/sdk/util/log/Logger;)V", "Sources of scanbot-sdk-android.core-base.main"}
)
public final class LoggerProvider {
   @NotNull
   public static final LoggerProvider INSTANCE = new LoggerProvider();
   @NotNull
   private static Logger logger = (Logger)(new StubLogger());

   private LoggerProvider() {
   }

   @NotNull
   public static final Logger getLogger() {
      return logger;
   }

   public static final void setLogger(@NotNull Logger var0) {
      Intrinsics.checkNotNullParameter(var0, "<set-?>");
      logger = var0;
   }

   /** @deprecated */
   // $FF: synthetic method
   @JvmStatic
   public static void getLogger$annotations() {
   }
}
However, after the update to this new AGP, the line
LoggerProvider.logger
gives a compilation error at
logger
part. If you click it, you see this decompiled class (not a Kotlin one - Java at once!):
Copy code
public final class LoggerProvider {
    @NotNull
    public static final LoggerProvider INSTANCE = new LoggerProvider();
    @NotNull
    private static Logger logger = new StubLogger();

    private LoggerProvider() {
    }

    @NotNull
    public static final Logger getLogger() {
        return logger;
    }

    public static final void setLogger(@NotNull Logger var0) {
        Intrinsics.checkNotNullParameter(var0, "<set-?>");
        logger = var0;
    }
}
Note the metadata and this method being absent:
Copy code
/** @deprecated */
   // $FF: synthetic method
   @JvmStatic
   public static void getLogger$annotations() {
   }
I suspect a newer, more strict R8 is being bundled with this newer AGP, but I wasn't able to find any mention of any relevant info or discussions online about this. If anyone knows anything - I'd be very grateful.
Sound like an issue with #C19FD9681 . Better move to this channel.
As far as I understand, R8 is a part of the Android project. @Chrimaeon could you, maybe, share more insight on your idea of the core of this issue?
c
I didn’t really read your post. Just saw AGP and Logger and thought you have an issue with the Gradle logger.
🙂 1
z
@Den Drobiazko maybe it is related to how AGP treats
minifyEnabled
starting with AGP 8.4.0? we had a similar issue back when we upgraded AGP from 8.2.2 to 8.7.3 https://developer.android.com/build/releases/past-releases/agp-8-4-0-release-notes#library-classes-shrunk
t
If you didn't figure it out yet, honestly first thing I would try is going up to AGP 8.9 or 8.10 to see if more R8 adjustments have landed since the issue showed up. But agree its pretty hard to track everything that has changed in the default R8 version used across the AGP versions.