Gluon-mobileを使用したAndroid開発には初めてです。
私はAndroidアプリケーションとGoogle MapViewを統合しようとしています。このため、このGMapsFX Apiを使用してMapviewを作成しました。
私の問題は、アプリケーションがデスクトップ上で円滑に実行されますが、Androidデバイスにアプリケーションをデプロイするときにアプリケーションが終了することです。
はここでここでここで
Gmapsfxの統合がAndroidアプリケーションで正しく機能しないGluon-mobileを使用して構築する
<?xml version="1.0" encoding="UTF-8"?>
<?import com.lynden.gmapsfx.GoogleMapView?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.VBox?>
<VBox alignment="CENTER" prefHeight="566.0" prefWidth="353.0" spacing="10" stylesheets="@Maps.css" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.gluonapplication.views.MapController">
<children>
<Label fx:id="header" layoutX="120.0" layoutY="14.0" text="the Sacred Groves" />
<GoogleMapView fx:id="MapView" layoutX="4.0" layoutY="62.0" prefHeight="525.0" prefWidth="353.0">
<children>
<TextField prefHeight="25.0" prefWidth="173.0" promptText="Enter a Location!" />
</children></GoogleMapView>
</children>
</VBox>
をMapViewのを持っているシーンを作成するメインクラスですFXMLファイルです
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.2.0'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.gluonapplication.Sample'
dependencies {
compile 'com.gluonhq:charm:4.1.0'
androidRuntime 'org.sqldroid:sqldroid:1.0.3'
compileNoRetrolambda 'com.jfoenix:jfoenix:1.0.0'
compile 'com.lynden:GMapsFX:2.11.0'
}
jfxmobile {
downConfig {
version = '3.2.4'
// Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
plugins 'display', 'lifecycle', 'local-notifications', 'runtime-args', 'statusbar', 'storage'
}
android {
manifest = 'src/android/AndroidManifest.xml'
}
}
このプロジェクト
ためbuild.gradleファイルです。
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.gluonapplication;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
/**
*
* @author Guru
*/
public class Sample extends Application{
public static void main(String args[])
{
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception
{
FXMLLoader loader=new FXMLLoader(getClass().getResource("MapsView.fxml"));
VBox box=loader.load();
Scene scene=new Scene(box);
primaryStage.setScene(scene);
primaryStage.show();
}
}
ここで上記FXMLためのコントローラクラスは、事前に
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.gluonapplication.views;
import com.gluonapplication.scenes.Backup;
import com.gluonapplication.scenes.SceneController;
import com.lynden.gmapsfx.*;
import com.lynden.gmapsfx.javascript.object.*;
import com.lynden.gmapsfx.service.directions.*;
import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.fxml.*;
/**
*
* @author Guru
*/
public class MapController implements Initializable, MapComponentInitializedListener, DirectionsServiceCallback,SceneController {
GoogleMap map;
Backup backup=null;
protected DirectionsService directionsService;
protected DirectionsPane directionsPane;
@FXML
protected GoogleMapView MapView;
@Override
public void initialize(URL location, ResourceBundle resources)
{
MapView.addMapInializedListener(this);
}
public void refresh()
{
MapView.relocate(10.876224, 77.021764);
}
@Override
public void mapInitialized() {
MapOptions options = new MapOptions();
options.center(new LatLong(10.876224, 77.021764))
.zoomControl(true)
.zoom(12)
.overviewMapControl(false)
.mapType(MapTypeIdEnum.ROADMAP);
map = MapView.createMap(options);
directionsService = new DirectionsService();
directionsPane = MapView.getDirec();
}
@Override
public void directionsReceived(DirectionsResult dr, DirectionStatus ds)
{
}
@Override
public void setParentScene(Backup backup) {
this.backup=backup;
}
}
感謝です!
この問題を解決するのに役立つすべて私にとってはうまく見えますが、Appはそれ自体を開始するときに終了します。
しかし、罰金デスクトップで動作します。
私はあなたがスタックトレースで確認することができますように、このコールのadb logcat -v threadtimeを実行して、cmdを
04-07 22:07:25.029 31214 31214 W System.err: java.lang.reflect.InvocationTargetException
04-07 22:07:25.030 31214 31214 W System.err: at java.lang.reflect.Method.invoke(Native Method)
04-07 22:07:25.030 31214 31214 W System.err: at javafxports.android.FXDalvikEntity.onGlobalLayout(FXDalvikEntity.java:389)
04-07 22:07:25.030 31214 31214 W System.err: at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:912)
04-07 22:07:25.030 31214 31214 W System.err: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1996)
04-07 22:07:25.030 31214 31214 W System.err: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1134)
04-07 22:07:25.030 31214 31214 W System.err: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6050)
04-07 22:07:25.030 31214 31214 W System.err: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:860)
04-07 22:07:25.030 31214 31214 W System.err: at android.view.Choreographer.doCallbacks(Choreographer.java:672)
04-07 22:07:25.030 31214 31214 W System.err: at android.view.Choreographer.doFrame(Choreographer.java:608)
04-07 22:07:25.030 31214 31214 W System.err: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:846)
04-07 22:07:25.030 31214 31214 W System.err: at android.os.Handler.handleCallback(Handler.java:742)
04-07 22:07:25.030 31214 31214 W System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
04-07 22:07:25.030 31214 31214 W System.err: at android.os.Looper.loop(Looper.java:154)
04-07 22:07:25.030 31214 31214 W System.err: at android.app.ActivityThread.main(ActivityThread.java:5469)
04-07 22:07:25.030 31214 31214 W System.err: at java.lang.reflect.Method.invoke(Native Method)
04-07 22:07:25.030 31214 31214 W System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
04-07 22:07:25.030 31214 31214 W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
04-07 22:07:25.030 31214 31214 W System.err: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'double javafx.scene.Scene.getHeight()' on a null object reference
04-07 22:07:25.031 31214 31214 W System.err: at com.sun.javafx.scene.control.skin.TextFieldSkinAndroid.adjustSize(TextFieldSkinAndroid.java:111)
04-07 22:07:25.031 31214 31214 W System.err: at com.sun.javafx.scene.control.skin.TextFieldSkinAndroid.lambda$showSoftwareKeyboard$643(TextFieldSkinAndroid.java:107)
04-07 22:07:25.031 31214 31214 W System.err: at com.sun.javafx.scene.control.skin.TextFieldSkinAndroid.access$lambda$2(TextFieldSkinAndroid.java)
04-07 22:07:25.031 31214 31214 W System.err: at com.sun.javafx.scene.control.skin.TextFieldSkinAndroid$$Lambda$3.accept(Unknown Source)
04-07 22:07:25.031 31214 31214 W System.err: at com.sun.glass.ui.android.DalvikInput.keyboardSize(DalvikInput.java:72)
04-07 22:07:25.031 31214 31214 W System.err: ... 17 more
04-07 22:07:25.103 31214 31214 W System.err: java.lang.reflect.InvocationTargetException
04-07 22:07:25.104 31214 31214 W System.err: at java.lang.reflect.Method.invoke(Native Method)
04-07 22:07:25.104 31214 31214 W System.err: at javafxports.android.FXDalvikEntity.onGlobalLayout(FXDalvikEntity.java:389)
04-07 22:07:25.104 31214 31214 W System.err: at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:912)
04-07 22:07:25.104 31214 31214 W System.err: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1996)
04-07 22:07:25.104 31214 31214 W System.err: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1134)
04-07 22:07:25.104 31214 31214 W System.err: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6050)
04-07 22:07:25.104 31214 31214 W System.err: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:860)
04-07 22:07:25.104 31214 31214 W System.err: at android.view.Choreographer.doCallbacks(Choreographer.java:672)
04-07 22:07:25.104 31214 31214 W System.err: at android.view.Choreographer.doFrame(Choreographer.java:608)
04-07 22:07:25.104 31214 31214 W System.err: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:846)
04-07 22:07:25.104 31214 31214 W System.err: at android.os.Handler.handleCallback(Handler.java:742)
04-07 22:07:25.104 31214 31214 W System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
04-07 22:07:25.104 31214 31214 W System.err: at android.os.Looper.loop(Looper.java:154)
04-07 22:07:25.104 31214 31214 W System.err: at android.app.ActivityThread.main(ActivityThread.java:5469)
04-07 22:07:25.104 31214 31214 W System.err: at java.lang.reflect.Method.invoke(Native Method)
04-07 22:07:25.104 31214 31214 W System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
04-07 22:07:25.104 31214 31214 W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
04-07 22:07:25.105 31214 31214 W System.err: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'double javafx.scene.Scene.getHeight()' on a null object reference
04-07 22:07:25.105 31214 31214 W System.err: at com.sun.javafx.scene.control.skin.TextFieldSkinAndroid.adjustSize(TextFieldSkinAndroid.java:111)
04-07 22:07:25.105 31214 31214 W System.err: at com.sun.javafx.scene.control.skin.TextFieldSkinAndroid.lambda$showSoftwareKeyboard$643(TextFieldSkinAndroid.java:107)
04-07 22:07:25.105 31214 31214 W System.err: at com.sun.javafx.scene.control.skin.TextFieldSkinAndroid.access$lambda$2(TextFieldSkinAndroid.java)
04-07 22:07:25.105 31214 31214 W System.err: at com.sun.javafx.scene.control.skin.TextFieldSkinAndroid$$Lambda$3.accept(Unknown Source)
04-07 22:07:25.105 31214 31214 W System.err: at com.sun.glass.ui.android.DalvikInput.keyboardSize(DalvikInput.java:72)
04-07 22:07:25.105 31214 31214 W System.err: ... 17 more
04-07 22:07:25.110 31214 31572 E libEGL : validate_display:255 error 3008 (EGL_BAD_DISPLAY)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: FATAL EXCEPTION: JavaFX Application Thread
04-07 22:07:25.150 31214 31255 E AndroidRuntime: Process: com.gluonapplication, PID: 31214
04-07 22:07:25.150 31214 31255 E AndroidRuntime: java.lang.UnsupportedOperationException: Not supported yet.
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at com.sun.webkit.WebPage.executeScript(WebPage.java:152)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at javafx.scene.web.WebEngine.executeScript(WebEngine.java:860)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at com.lynden.gmapsfx.javascript.JavaFxWebEngine.executeScript(JavaFxWebEngine.java:42)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at com.lynden.gmapsfx.GoogleMapView.initialiseScript(GoogleMapView.java:253)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at com.lynden.gmapsfx.GoogleMapView.access$000(GoogleMapView.java:47)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at com.lynden.gmapsfx.GoogleMapView$1.changed(GoogleMapView.java:224)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at com.lynden.gmapsfx.GoogleMapView$1.changed(GoogleMapView.java:221)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:181)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at javafx.beans.property.ReadOnlyObjectWrapper$ReadOnlyPropertyImpl.fireValueChangedEvent(ReadOnlyObjectWrapper.java:176)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at javafx.beans.property.ReadOnlyObjectWrapper.fireValueChangedEvent(ReadOnlyObjectWrapper.java:142)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:146)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at javafx.scene.web.WebEngine$LoadWorker.updateState(WebEngine.java:1023)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at javafx.scene.web.WebEngine$LoadWorker.dispatchLoadEvent(WebEngine.java:1134)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at javafx.scene.web.WebEngine$LoadWorker.access$1000(WebEngine.java:1016)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at javafx.scene.web.WebEngine$PageLoadListener.dispatchLoadEvent(WebEngine.java:1003)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at com.sun.webkit.WebPage.fireLoadEvent(WebPage.java:251)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at com.sun.webkit.NativeWebView$1.run(NativeWebView.java:100)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at com.sun.javafx.application.PlatformImpl.lambda$null$156(PlatformImpl.java:295)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at com.sun.javafx.application.PlatformImpl.access$lambda$18(PlatformImpl.java)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at com.sun.javafx.application.PlatformImpl$$Lambda$19.run(Unknown Source)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at java.security.AccessController.doPrivileged(AccessController.java:52)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at com.sun.javafx.application.PlatformImpl.lambda$runLater$157(PlatformImpl.java:294)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at com.sun.javafx.application.PlatformImpl.access$lambda$5(PlatformImpl.java)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at com.sun.javafx.application.PlatformImpl$$Lambda$6.run(Unknown Source)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:92)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:51)
04-07 22:07:25.150 31214 31255 E AndroidRuntime: at java.lang.Thread.run(Thread.java:818)
04-07 22:07:25.154 31214 31255 E MQSEventManagerDelegate: failed to get MQSService.
Android sdk platform-toolsフォルダに移動し、電話機を接続してコマンドライン 'adb logcat -v threadtime'から実行します。次に、アプリを実行し、アプリが終了したときに発生する可能性のある例外をコンソールでチェックします。あなたがそれを解決できない場合は、関連する部分を投稿してください。 –
実際には、私はInvocationtarget例外を取得しています、unsupportedoperationexception:サポートされていない例外Sir、 –
エラーの原因を正確に示すメッセージを切り捨てています:TextFieldにNPEがあります。スクリーンショットの代わりに、できるだけ詳細にスタックトレースのテキストをコピーしてコピーします。 –