JavaFX Android端口 - Google Play服务 [英] JavaFX Android Port - Google Play Services
问题描述
我已经在JavaFX上写了一个小游戏并将其成功移植到Android。现在我想包含一些Google广告。为此,我创建了一个PlatformService和AndroidPlatformProvider,如此示例中所示。我为Netbeans使用了Gluon插件
我将其添加到了我的build.gradle文件中:
<$ p $ repositories {
def androidHome = System.getenv(ANDROID_HOME)
maven {url$ androidHome / extras / android / m2repository /}
maven { url$ androidHome / extras / google / m2repository /}
}
依赖关系{
编译fileTree(包括:''.jar'],dir:'libs')
编译'com.google.android.gms:play-services-ads:7.5.0'
}
在我的AndroidManifest.xml中添加了:
< meta-data android:name =com。 google.android.gms.versionandroid:value =@ integer / google_play_services_version/>
当我尝试构建apk文件时,他们会得到我的下一个错误
:processAndroidResources UP-TO-DATE C:\ Users \Martin\Documents\NetBeansProjects\Trio\build\javafxports\\ \\ tmp \android\AndroidManifest.xml:27:错误:错误:找不到与给定名称相匹配的资源(值为'@ integer / google_play_services_version')。 :processAndroidAndroidResources FAILED
我搜索了一下,发现我应该包含google-play-services_lib as一个图书馆,但我不知道如何。它是我第一次使用gradle
在Android SDK Manager中,我安装了最新的Play Services和Repository
这不是一个完整的解决方案,但只是一个解决方法...
你对google-play-services_lib :它包含一个包含所有服务的胖罐子。如果您只是将此jar复制到您的libs文件夹中,则不需要任何依赖关系,但可以这样做:
dependencies {
//编译fileTree(包括:['* .jar'],dir:'libs')
//编译'com.google.android.gms:play-services-ads:7.5.0'
androidcompile文件('libs / google-play-services.jar')
}
如果你看看google-play -services_lib文件夹中,还可以找到 res / values
文件夹,其中包含 version.xml
文件。你有什么你在找什么。所以现在你可以找到编辑这个文件的值:
<?xml version =1.0encoding =utf-8 >?;
<资源>
< integer name =google_play_services_version> 7571000< / integer>
< /资源>
并替换AndroidManifest.xml中的字符串:
< meta-data android:name =com.google.android.gms.versionandroid:value =7571000/>
但是由于您需要这些资源以及jar,所以我认为这是更好的方法将资源内容放到你的android / res文件夹中。
现在你应该可以构建你的apk。
I have written a little game on JavaFX and ported it successfully to Android. Now I want to include some Google Ads. For this I created a PlatformService and AndroidPlatformProvider like in this example shown. I'm using the Gluon plugin for Netbeans
I 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 as a library but I dont know how. Its my first time working with gradle
In the Android SDK Manager I installed the newest Play Services and the Repository
This is not a complete solution, but just a workaround...
You are right about the google-play-services_lib: it contains a fat jar with all the services. If you just copy this jar to your libs folder, you won't need any of the dependencies but this:
dependencies {
// compile fileTree(include: ['*.jar'], dir: 'libs')
// compile 'com.google.android.gms:play-services-ads:7.5.0'
androidCompile files('libs/google-play-services.jar')
}
Now, you can build your project, but you'll still need the meta-data on the manifest file.
If you have a look at google-play-services_lib folder, you'll also find a res/values
folder, with a version.xml
file. There you have what you are looking for. So now you can find the value editing this file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="google_play_services_version">7571000</integer>
</resources>
and replacing the string on AndroidManifest.xml:
<meta-data android:name="com.google.android.gms.version" android:value="7571000" />
But since you will need those resources as well as the jar, I think it's a better approach copying all the res content into your android/res folder.
Now you should be able to build your apk.
这篇关于JavaFX Android端口 - Google Play服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!