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.