How to solve error "java.lang.NoClassDefFoundError: android/app/Activity" while running gradle command "android" (javafxports)?

264 Views Asked by At

Today I started looking at JavaFXPorts. I read this Gluon Documentation.

But... when I run the Step 2.4.3 ("Deploying the project") by clicking on application→run at gradle panel, the first error appeared:

com.gluonhq.charm.down.Platform <clinit>
javafx.platform is not defined. Desktop will be assumed by default.

As I run other->android at gradle panel (I wanted to package it to an apk first, I will attach device if it start working properly) another error appeared:

Process 'command 'C:\Program Files\Java\jdk1.8.0_241\bin\java.exe'' finished with non-zero exit value 1

Caused by: java.lang.NoClassDefFoundError: android/app/Activity
Caused by: java.lang.ClassNotFoundException: android.app.Activity

I am new at JavaFXPorts, as I told at the top.

Can anyone help? Anyone experienced this error too??

Greets MatsG23 :)

The Code (I haven't changed it since project creation) I selected "Gluon Mobile - Single View Project"

Main-Class

public class Test extends MobileApplication {
    public void init() {
        addViewFactory(HOME_VIEW, BasicView::new);
    }
    public void postInit(Scene scene) {
        Swatch.BLUE.assignTo(scene);

        ((Stage) scene.getWindow()).getIcons().add(new 
        Image(Test.class.getResourceAsStream("/icon.png")));
    }
}

BasicView-Class

public class BasicView extends View {
    public BasicView() {
        Label label = new Label("Hello JavaFX World!");
        Button button = new Button("Change the World!");
        button.setGraphic(new Icon(MaterialDesignIcon.LANGUAGE));
        button.setOnAction(e -> label.setText("Hello JavaFX Universe!"));
        VBox controls = new VBox(15.0, label, button);
        controls.setAlignment(Pos.CENTER);
        setCenter(controls);
    }
    protected void updateAppBar(AppBar appBar) {
        appBar.setNavIcon(MaterialDesignIcon.MENU.button(e -> System.out.println("Menu")));
        appBar.setTitleText("Basic View");
        appBar.getActionItems().add(MaterialDesignIcon.SEARCH.button(e -> System.out.println("Search")));
    }
}

Device Information

OS: Microsoft Windows 10 Home

Build: 10.0.18363 Build 18363

Computer: Dell Inspiron 15-3567

RAM: 8 GB

Core: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz[Cores 2] [Logical/Core 2]

0

There are 0 best solutions below