2

I try to port a simple JavaFX application to Android by generating an apk-file with Gradle.

But unfortunately the installation of my generated app to an android device is always failing with the following error: "INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113.".

Project Structure

src
|-main
  |-java
    |-app
      |-main
        |-MainApp.java
  |-resources
    |-app
      |-css
        |-main.css

MainApp.java

public class MainApp extends Application
{
    @Override
    public void start(Stage primaryStage)
    {
        try
        {
        primaryStage.setTitle("TestAppFX");

            Button btn = new Button("Exit Application");
            btn.setOnAction(new EventHandler<ActionEvent>() {
                @Override
                public void handle(ActionEvent event)
                {
                    System.exit(0);
                }
            });

            StackPane root = new StackPane();
            root.getChildren().add(btn);

            primaryStage.setScene(new Scene(root, 300, 250));
            primaryStage.show();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public static void main(String[] args)
    {
        launch(args);
    }
}

gradle.build

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.3.10'
    }
}

apply plugin: 'org.javafxports.jfxmobile'

mainClassName = 'app.main.MainApp'

repositories {
    jcenter()
}

jfxmobile {
    android {
        compileSdkVersion = 25
        androidSdk = 'C:/Program Files (x86)/Entwicklung/Android_SDK'
        applicationPackage = 'org.javafxports.ensemble'
    }
}

Used software/emulators:

  • Eclipse Oxygen.2
  • Gradle 4.4.1 (with Android SDK 25; also tried SDK 21 and Gradle 2.2.0)
  • Android Studio 3.0.1

Used emulators in Android Studio:

  • Lollipop x86 (SDK 21)
  • Lollipop x86_64 (SDK 21)

and also tried

  • Nougat x86 (SDK 25)
  • Nougat x86_64 (SDK 25)

with the image of the Nexus 4 or 5(X).

Ok, so I already tried a lot of things but that leads me only to other problems so I hope anyone can help me getting forward:

1) I found a thread where users suggested to add

splits {
    abi {
        enable true
        reset()
        include 'x86', 'armeabi-v7a'
        universalApk true
    }
}

to the android section of the build.gradle file. But Gradle just leaves me with the message that a function "splits" is not known. I found out that it would be neccessary to add the following command under the "buildscript" section:

apply plugin: 'com.android.library'

2) But Gradle didn't know the plugin, so I searched again and found a blog post which suggested to add following lines to the repositories and dependencies section:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'    
    }
}

After adding this Gradle says "Failed to apply plugin [id 'com.android.library']. Gradle version 2.2 is required. Current version is 4.4.1. If using the gradle wrapper, try editing the distributionUrl." If I install Gradle 2.2 instead of 4.4.1 I get the error that some component is not available anymore. I don't think that this step is getting me further, but I can be wrong of course..

3) If I change the version numbers of the plugin "gradle" in the classpath according to the related last stable release version (found here *) to 2.3.3 I get the following error: "Failed to apply plugin [id 'org.javafxports.jfxmobile']. Could not create an instance of type org.javafxports.jfxmobile.plugin.JFXMobileExtension_Decorated. Could not generate a proxy class for class org.javafxports.jfxmobile.plugin.android.AndroidExtension."

4) If I use API 21 (Lollipop) as suggested from the developers of Gradle on GitHub by setting compileSdkVersion to 21 and download the sdk via Android Studio I get the following error: "Could not find org.javafxports:dalvik-sdk:8.60.9." So I set it back to API 25. The project page also says that dalvik-sdk 8.60.9 is currently the basis for the javafx plugin.

I hope you're still with me ;). If not let me know, so I can try to explain the matter more precisely. I don't know what to do to make Gradle generate a valid apk file so if you have any suggestions, please let me know!


*) You can see the current versions of the different plugins (android, javafx). Just follow the path specified in the attribute "classpath", e.g.: https://jcenter.bintray.com/org/javafxports/jfxmobile-plugin.

Nighty42
  • 420
  • 1
  • 6
  • 20
  • 1
    I take you don't have a real device to deploy your app, and you are testing only in an emulator. In that case, [this](https://stackoverflow.com/a/44544233/3956070) is a possible solution. – José Pereda Dec 28 '17 at 19:11
  • Thanks José for your answer. I develop an open source mobile app with JavaFX. The Gluon Mobile plugin you suggest I should use, seems to be shareware for free users so I have to get used to a nag screen, right? If so, that's not really an option for me, because I don't want to spent money for the development of an open source app. Additionally in my understanding Gluon Mobile is just the product which is based on the javafx mobile plugin I mentioned in my original post (source: http://docs.gluonhq.com/javafxports/). – Nighty42 Dec 28 '17 at 22:51
  • There are free licences for open source projects. The answer I referred above was about running a Gluon Mobile app on an Android emulator. – José Pereda Dec 28 '17 at 22:59
  • Gluon Mobile seems nice - they already did a really good job. I will test it out a little bit more. Unfortunately my test app on Android is a little bit slow though it doesn't have to handle complex logic or UIs yet. – Nighty42 Jan 03 '18 at 16:57

0 Answers0