siemaeniu500
siemaeniu500

Reputation: 115

Strange javafx app look on android

I've got a problem with my javafx ported app on android. After first launch it looks like that:

But when i go to home screen and then rejoin to application it looks as it should be.

build.gradle:

buildscript {
    repositories {
         mavenCentral()
        maven {
      url "https://plugins.gradle.org/m2/"
      url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.1.1'

    }
}

apply plugin: 'org.javafxports.jfxmobile'

repositories {
    mavenCentral()
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
}

mainClassName = 'pl.siemaeniu500.wszywka.main.Main'
ext.CHARM_DOWN_VERSION = "2.0.1"

dependencies {
    compile "com.gluonhq:charm-down-common:2.0.1"
    //compile 'com.gluonhq:charm-glisten:3.0.0'
    compile 'com.gluonhq:charm:2.1.1'
    compile files('D:/Android/Sdk/platforms/android-21/android.jar', 'C:/Users/Kamil/Documents/NetBeansProjects/WszywkaSounds/jfxdvk-8.60.8.jar')
    androidRuntime 'com.gluonhq:charm-android:2.1.1'
    iosRuntime 'com.gluonhq:charm-ios:2.1.1'
    desktopRuntime 'com.gluonhq:charm-desktop:2.1.1'
    desktopCompile 'com.github.sarxos:webcam-capture:0.3.10'
}

jfxmobile {



    downConfig {
        version = '3.0.0'
        plugins 'display', 'lifecycle', 'statusbar', 'storage'
    }

    android {
        manifest = 'src/android/AndroidManifest.xml'
        //compileSdkVersion 24
        //buildToolsVersion "24.0.3"
        androidSdk = 'D:/Android/Sdk'
    }
    ios {
        infoPList = file('src/ios/Default-Info.plist')
        forceLinkClasses = [
                'com.gluonhq.**.*',
                'javax.annotations.**.*',
                'javax.inject.**.*',
                'javax.json.**.*',
                'org.glassfish.json.**.*'
        ]
    }
}

main application class:

package pl.siemaeniu500.wszywka.main;

import javafx.application.Application;
import static javafx.application.Application.launch;

import javafx.fxml.FXMLLoader;
import javafx.geometry.Rectangle2D;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Screen;
import javafx.stage.Stage;



/**
 *
 * @author Kamil
 */


public class Main extends Application {





    @Override
    public void start(Stage stage) throws Exception {
        Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
        Parent root = FXMLLoader.load(getClass().getResource("FXML.fxml"));
        Scene scene = new Scene(root, visualBounds.getWidth(), visualBounds.getHeight());
        stage.setScene(scene);
        stage.setMaximized(true);
        //new FXMLController().initialize();
        stage.show();
    }


    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }

}

What can cause that?

Upvotes: 0

Views: 323

Answers (1)

José Pereda
José Pereda

Reputation: 45456

When you set the scene size:

Scene scene = new Scene(root, visualBounds.getWidth(), visualBounds.getHeight());

you are already taking the whole screen on your device, so you don't need to set this:

stage.setMaximized(true);

Removing that line should fix the issue.

As for the build script, you can simplify the dependencies.

In a first step, remove charm-down-common. If you are not using charm glisten you can remove all charm-* dependencies. If you use it, you will use the new version 4+ (uncomment the line below).

dependencies {
    // compile 'com.gluonhq:charm:4.0.1'
    compile files('D:/Android/Sdk/platforms/android-21/android.jar', 'C:/Users/Kamil/Documents/NetBeansProjects/WszywkaSounds/jfxdvk-8.60.8.jar')
    desktopCompile 'com.github.sarxos:webcam-capture:0.3.10'
}

As for the android and jfxdvk jars, those shouldn't be there. The plugin will manage that for you.

dependencies {
    // compile 'com.gluonhq:charm:4.0.1'
    desktopCompile 'com.github.sarxos:webcam-capture:0.3.10'
}

Reload the project (Project root, right click, Reload Project):

and you will see them under Dependencies -> Compile for Android:

Upvotes: 1

Related Questions