I'm trying to use Android specific code in a JavaFx Project. I wrote a litte game on JavaFX and when I use JavaFX-Ports I can run this Game on my Android Handy. Now I want to display some ads and for this I have to use the FXActivity as a context.
I imported the FXActivity
import javafxports.android.FXActivity;
Then I get this Error:
D:\Martin\Programmieren\fx to android\Trio\src\main\java\net \hagh\Main.java:18:
error: package javafxports.android does not exist
import javafxports.android.FXActivity;
^
1 error
:compileJava FAILED
Now I added the jfxdvk.jar and android.jar (from Android-SDK) to my dependencies and now my build.gradle file looks like:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.0-b9'
}
}
apply plugin: 'org.javafxports.jfxmobile'
mainClassName = 'net.hagh.Main'
dependencies {
compile files("D:/Programmieren/fx to android/dalvik-sdk/rt/lib/ext/jfxdvk.jar", "C:/Users/Martin/AppData/Local/Android/android-sdk/platforms/android-22/android.jar")
}
repositories {
jcenter()
}
The same error as before...
What did I wrong and how can I do it right? I searched long for a solution but there are so many different tutorials and I think most of them are outdated. Can someone give me a correct build.gradle file?
I found this example: https://bitbucket.org/javafxports/samples/src/56e2050ef9e1/HelloPlatform/?at=default and I think this is the right way to do it. But I dont understand how to use the FXActivity in this way
Edit: I opened a new question for this
The Gluon plugin for NetBeans and the HelloPlatform example helped me but now I want to use the Google-Play-Services to show adds. In added this to my build.gradle file:
repositories {
def androidHome = System.getenv("ANDROID_HOME")
maven { url "$androidHome/extras/android/m2repository/" }
maven { url "$androidHome/extras/google/m2repository/"}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services-ads:7.5.0'
}
And in my AndroidManifest.xml I added:
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
And their I get my next error when I try to build the apk-file
:processAndroidResources UP-TO-DATE
C:\Users\Martin\Documents\NetBeansProjects\Trio\build\javafxports\tmp\android\AndroidManifest.xml:27: error: Error: No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').
:processAndroidAndroidResources FAILED
I searched a bit and I found that I should include the google-play-services_lib but I dont know how. Its my first time working with gradle