Skip to content

Confusion about how the plugin starts d8 #793

Closed

Description

@lyubomyr-shaydariv

As I'm not a real Android developer, I only recently discovered the use of d8 for me, and fortunately the plugin supports it. However, I'm not really sure whether I'm doing it all right, but I'm really confused about how the plugin manages the invocation of d8. From what I see in the source code, the plugin invokes d8 by starting the JVM directly passing the -jar parameter referencing the d8.jar file from the build tools lib directory. I don't really know why it was designed like that, but I also see that the original JAR file in any build tools version I installed lacks the manifest file, therefore the JVM started by the plugin crashes on start with the following output:

[INFO] Convert classes to Dex : PROJECT_PATH/target
[INFO] no main manifest attribute, in ANDROID_SDK_PATH/build-tools/VERSION/lib/d8.jar

Build tools provide the d8 tool as a runner script, so switching from java -jar ANDROID_SDK_PATH/build-tools/VERSION/lib/d8.jar to ANDROID_SDK_PATH/build-tools/VERSION/d8 would do the job. While trying to figure out the core issue, I also made some minor changes to the plugin by adding a temporary d8UseRunner configuration option that switches the plugin to the "runner"/"launcher" mode that starts d8 with its dedicated script. The changes are far from being perfect, of course, but they seem to build a proper APK file for me.

I have a few questions:

  • Is my Android SDK merely broken in any way? (I tested it on two machines with Windows and Linux Mint, but neither worked properly).
  • Did something change in the Android SDK and android-maven-plugin+d8 worked together nicely earlier?
  • Is there something that I'm missing?

Thanks.

Activity

  1. mosabua commented on Aug 25, 2020

    @mosabua
    Member

    I have not tested the plugin for a while or cut any releases. I know it used to work with d8 but the Android SDK has always been changing and breaking things so I would not be surprised if it does not currently work. Unfortunately I also do not have the time to look into this.

  2. lyubomyr-shaydariv commented on Aug 25, 2020

    @lyubomyr-shaydariv
    ContributorAuthor

    @mosabua

    I know it used to work with d8 but the Android SDK has always been changing and breaking things so I would not be surprised if it does not currently work.

    I used to believe that the Android SDK is constantly stable and does not change things like that, but as far as I can see they changed the behavior and the Main-Class entry was removed from the manifest in build-tools;29.0.1.

    I would appreciate further code/design review in my changes.

  3. william-ferguson-au commented on Nov 14, 2020

    @william-ferguson-au
    Contributor

    We would generally invoke the Java class directly rather than invoke via a shell script as this keeps it platform agnostic.
    I have submitted #796 to do just that.

  4. lyubomyr-shaydariv commented on Nov 14, 2020

    @lyubomyr-shaydariv
    ContributorAuthor

    @william-ferguson-au thank you!

    Just wondering: would it be worth having a platform-independent shell-script runner? Sometimes shell scripts may have more than just starting an external JAR.

  5. william-ferguson-au commented on Nov 14, 2020

    @william-ferguson-au
    Contributor

    Possibly and I take your point.
    Personally I try and avoid shell scripts because they just add another layer of complexity. Best to just invoke the app directly.

  6. lyubomyr-shaydariv commented on Nov 14, 2020

    @lyubomyr-shaydariv
    ContributorAuthor

    @william-ferguson-au got it, I hope they won't change it like that in the future. Thanks!

    Closing this one in favor of #796.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions