Google Map crash at specific location and zoom level 15 - android-mapview

Google Map crashes with zoom level 15 at specific location (35.670, 139.760) on Android 8 (API level 26).
No crash with other zoom levels (say: 1,2,10, or 14 etc.)
When crash, the Logcat output is:
E/AndroidRuntime: FATAL EXCEPTION: GLThread 279
Process: test.map, PID: 5690
java.lang.StackOverflowError: stack size 1038KB
at java.util.Collections$UnmodifiableList.<init>(Collections.java:1344)
at java.util.Collections$UnmodifiableRandomAccessList.<init>(Collections.java:1437)
at java.util.Collections.unmodifiableList(Collections.java:1330)
at com.google.maps.api.android.lib6.common.g.<init>(:com.google.android.gms.DynamiteModulesB#11951470:9)
at com.google.maps.api.android.lib6.gmm6.indoor.o.b(:com.google.android.gms.DynamiteModulesB#11951470:142)
at com.google.maps.api.android.lib6.gmm6.indoor.o.c(:com.google.android.gms.DynamiteModulesB#11951470:144)
at com.google.maps.api.android.lib6.gmm6.indoor.o.e(:com.google.android.gms.DynamiteModulesB#11951470:286)
at com.google.maps.api.android.lib6.gmm6.indoor.o.d(:com.google.android.gms.DynamiteModulesB#11951470:182)
at com.google.maps.api.android.lib6.gmm6.indoor.o.a(:com.google.android.gms.DynamiteModulesB#11951470:180)
at com.google.maps.api.android.lib6.gmm6.indoor.o.a(:com.google.android.gms.DynamiteModulesB#11951470:82)
at com.google.maps.api.android.lib6.gmm6.indoor.o.a(:com.google.android.gms.DynamiteModulesB#11951470:70)
at com.google.maps.api.android.lib6.gmm6.indoor.o.c(:com.google.android.gms.DynamiteModulesB#11951470:147)
at com.google.maps.api.android.lib6.gmm6.indoor.o.e(:com.google.android.gms.DynamiteModulesB#11951470:286)
at com.google.maps.api.android.lib6.gmm6.indoor.o.d(:com.google.android.gms.DynamiteModulesB#11951470:182)
at com.google.maps.api.android.lib6.gmm6.indoor.o.a(:com.google.android.gms.DynamiteModulesB#11951470:180)
at com.google.maps.api.android.lib6.gmm6.indoor.o.a(:com.google.android.gms.DynamiteModulesB#11951470:82)
at com.google.maps.api.android.lib6.gmm6.indoor.o.a(:com.google.android.gms.DynamiteModulesB#11951470:70)
at com.google.maps.api.android.lib6.gmm6.indoor.o.c(:com.google.android.gms.DynamiteModulesB#11951470:147)
at com.google.maps.api.android.lib6.gmm6.indoor.o.e(:com.google.android.gms.DynamiteModulesB#11951470:286)
at com.google.maps.api.android.lib6.gmm6.indoor.o.d(:com.google.android.gms.DynamiteModulesB#11951470:182)
......
It's very easy to reproduce by running the following code in Nexus5X Android 8 emulator
package test.map;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.LinearLayout;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.LatLng;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
setContentView(ll);
//
MapView mapView = new MapView(this);
mapView.onCreate(null);
mapView.onResume();
mapView.getMapAsync(new OnMapReadyCallback() {
#Override
public void onMapReady(final GoogleMap googleMap) {
final LatLng latLng = new LatLng(35.670, 139.760);
final CameraUpdate update = CameraUpdateFactory.newLatLngZoom(latLng, 15.0f);
googleMap.moveCamera(update);
}
});
ll.addView(mapView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT));
}
}

This is a long standing bug in Google Maps SDK, see https://issuetracker.google.com/issues/35829548
You can the issue this by disabling indoor maps:
#Override public void onMapReady(GoogleMap googleMap) {
googleMap.setIndoorEnabled(false);
}
Question is also a duplicate of Is there a workaround/fix to these Google Maps v2 StackOverflowError crashes?

Related

It is possible to use JavaFX in Groovy using the same syntax as in Java?

I am using jdk1.8.0_25.
I am trying to run a JavaFX app file below which, when named 'HelloWorldMain.java', compiles and runs OK with javac/java. I renamed it as 'HelloWorldMain.groovy' and can't run it using Groovy.
Is there a simple way to run this file using Groovy with no or minimal modification, preferably without additional software like GroovyFX? And if I have to use GroovyFX, can I run this pure Java code without modification?
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
/**
*
* #author cdea
*/
public class HelloWorldMain extends Application {
/**
* #param args the command line arguments
*/
public static void main(String[] args) {
Application.launch(args);
}
#Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Hello World");
Group root = new Group();
Scene scene = new Scene(root, 300, 250);
Button btn = new Button();
btn.setLayoutX(100);
btn.setLayoutY(80);
btn.setText("Hello World");
btn.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent event) {
System.out.println("Hello World");
}
});
root.getChildren().add(btn);
primaryStage.setScene(scene);
primaryStage.show();
}
}
I am trying to run it as
groovy HelloWorldMain.groovy
and getting the following output in command line:
Caught: java.lang.RuntimeException: java.lang.ClassNotFoundException: javafx.application.Application$launch
java.lang.RuntimeException: java.lang.ClassNotFoundException: javafx.application.Application$launch
at javafx.application.Application.launch(Application.java:260)
at javafx.application.Application$launch.call(Unknown Source)
at HelloWorldMain.main(HelloWorldMain.groovy:20)
Caused by: java.lang.ClassNotFoundException: javafx.application.Application$launch
at javafx.application.Application.launch(Application.java:248)
... 2 more
replace the main method with:
public static void main(String[] args) {
launch(HelloWorldMain, args);
}
The error basically gives you the answer: no you can not just copy the files in all cases. There are differences between groovy and java (e.g. http://groovy-lang.org/differences.html). Groovy comes with a tool called java2groovy that might help migrate.
But as groovy runs fine with java code, why bother? Migrate the parts, that are better off using groovy and keep the java parts around for now.

How to add the icon image into the CheckBoxTreeItem?

I've problem with the TreeView component, It has the CheckBoxTreeItem to check enable or disable, it's very select and unselect with this reference ==> Using JavaFX UI Controls: Tree View | JavaFX 2 Tutorials and Documentation with Using Tree Cell Editors.
This is the image with the tree view have CheckBoxTreeItem
(http://docs.oracle.com/javafx/2/ui_controls/img/tree-view-checkbox1.png)
At now, I want to add the icon image beside the CheckBoxTreeItem (Its mean that we have the icon image beside the checkbox).
Could anyone help me this problem?
I saw that when I set like that
tree.setCellFactory(CheckBoxTreeCell.forTreeView());
==> It can not show the icon
This is my coding
package sample;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.CheckBoxTreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.control.cell.CheckBoxTreeCell;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class Main extends Application {
#Override
public void start(Stage primaryStage) throws Exception{
primaryStage.setTitle("Tree View Sample");
Node graphic = new ImageView(new Image("https://duke.kenai.com/iconSized/duke4.gif"));
CheckBoxTreeItem<String> rootItem =
new CheckBoxTreeItem<String>("View Source Files", graphic);
rootItem.setExpanded(true);
final TreeView tree = new TreeView(rootItem);
tree.setEditable(true);
tree.setCellFactory(CheckBoxTreeCell.<String>forTreeView());
for (int i = 0; i < 8; i++) {
final CheckBoxTreeItem<String> checkBoxTreeItem =
new CheckBoxTreeItem<String>("Sample" + (i+1), graphic);
rootItem.getChildren().add(checkBoxTreeItem);
}
tree.setRoot(rootItem);
tree.setShowRoot(true);
StackPane root = new StackPane();
root.getChildren().add(tree);
primaryStage.setScene(new Scene(root, 300, 250));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Thanks 4 your reading.
Tran Quoc Ung
I did it and you should refer in that page ==> https://forums.oracle.com/message/11232268#11232268
CheckBoxTreeItem have a one object property we cannot use more than one object within it.
try this..
CheckBoxTreeItem<ImageView> chkbobj;
ImageView mv = new ImageView();
mv.setImage(new Image(getClass().getResourceStreamAs("abc.png")));
chkboobj.setGraphic(mv);

JavaFx 2.x : Stage within a TabPane

I need to display one or more stage(s) within a TabPane by clicking on a button, such as the picture below
My target is to have a situation similar to JInternalFrame in Swing: how to accomplish this?
I am not able to add stage as children to the tab pane.
If this is not possible, what could be other solutions? I would like to have SplitPanes on the stage.
Thanks
PS I am using Win7, NetBeans 7.4 Beta (Build 201307092200), SceneBuilder 1.1
Edit: here is how it looks after some VFXWindows css changes
There's one thing worth notice: I have had to add a node ( in my case an HBox with prefSize(0,0), otherwise I can't move o resize the first window plotted, only the first one.
As last, I can't find a way to set windows full screen (maximize).
Here I put an example of windows from jfxtras inside of Tabs, I just modify the example.
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.stage.Stage;
import jfxtras.labs.scene.control.window.CloseIcon;
import jfxtras.labs.scene.control.window.MinimizeIcon;
import jfxtras.labs.scene.control.window.Window;
public class WindowInTab extends Application {
private static int counter = 1;
private void init(Stage primaryStage) {
TabPane tabPane = new TabPane();
Tab tab = generateTab("Windows...");
Tab anotherTab = generateTab("More Windows");
tabPane.getTabs().addAll(tab, anotherTab);
primaryStage.setResizable(true);
primaryStage.setScene(new Scene(tabPane, 600, 500));
}
private Tab generateTab(String tabName) {
Tab tab = new Tab(tabName);
final Group root = new Group();
tab.setContent(root);
Button button = new Button("Add more windows");
root.getChildren().addAll(button);
button.setOnAction(new EventHandler<ActionEvent>() {
#Override
public void handle(ActionEvent arg0) {
// create a window with title "My Window"
Window w = new Window("My Window#"+counter);
// set the window position to 10,10 (coordinates inside canvas)
w.setLayoutX(10);
w.setLayoutY(10);
// define the initial window size
w.setPrefSize(300, 200);
// either to the left
w.getLeftIcons().add(new CloseIcon(w));
// .. or to the right
w.getRightIcons().add(new MinimizeIcon(w));
// add some content
w.getContentPane().getChildren().add(new Label("Content... \nof the window#"+counter++));
// add the window to the canvas
root.getChildren().add(w);
}
});
return tab;
}
public double getSampleWidth() {return 600;}
public double getSampleHeight() {return 500;}
#Override
public void start(Stage primaryStage) throws Exception {
init(primaryStage);
primaryStage.show();
}
public static void main(String[] args) {launch(args);}
}
I don't know if this was exactly what you were looking for. Hope it helps!

Why Android libslide menu with actionbarsherlock open automatically?

I have a project with the sliding menu (from jeremy feinstein) and actionbarsherlock.
For some reason, when the activity shows up the slide menu open automatically too.
Quick note about my app architecture:
All of my activities have the slide menu integrated and on menu item click I start the related activity (with FLAG_ACTIVITY_SINGLE_TOP).
All my activities extends the class shown below.
This is quite annoying because every time the user click on one item, the menu get expanded as well forcing the user to close it down.
Anyone knows what it is causing this behavior?
What should I do to fix it and have the expected behavior.
I post below the concerned code:
package com.example.mypapp;
import com.example.mypapp.R;
import ocom.example.mypapp.SampleListFragment;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.ListFragment;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity;
public class MyAppBaseActivity extends SlidingFragmentActivity {
protected ListFragment mFrag;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setBehindContentView(R.layout.menu_frame);
SlidingMenu sm = getSlidingMenu();
sm.setShadowWidthRes(R.dimen.shadow_width);
sm.setShadowDrawable(R.drawable.shadow);
sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
sm.setFadeDegree(0.35f);
sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
if (savedInstanceState == null) {
FragmentTransaction t = this.getSupportFragmentManager().beginTransaction();
mFrag = new SampleListFragment();
t.replace(R.id.menu_frame, mFrag);
t.commit();
} else {
mFrag = (ListFragment)this.getSupportFragmentManager().findFragmentById(R.id.menu_frame);
}
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
toggle();
}
return true;
}
#Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
toggle();
return true;
}
}
Where SlidingFragmentActivity has been modified to extend SherlockFragmentActivity as suggested on official page of Jeremy Feinstein when actionbarsherlock is also in the picture.

LWUIT assistance

import com.sun.lwuit.Button;
import com.sun.lwuit.Command;
import com.sun.lwuit.Display;
import com.sun.lwuit.Label;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.plaf.UIManager;
import com.sun.lwuit.util.Resources;
import java.io.IOException;
public class Ruwwa extends javax.microedition.midlet.MIDlet
implements ActionListener{
Form f;
Button mybutton1;
Button mybutton2;
Command exit;
Command ok;
public void startApp() {
Display.init(this);
f = new Form();
try {
Resources r = Resources.open("/mairuwa.res");
UIManager.getInstance().setThemeProps(r.getTheme("Mairuwa Theme"));
} catch (IOException ioe) {
ioe.printStackTrace();
}
mybutton1=new Button("Report A Problem");
mybutton2=new Button("Request Info");
f.setLayout(new BorderLayout());
f.addComponent(BorderLayout.CENTER, new Label("The Mairuwa Portal"));
ok = new Command("OK");
exit = new Command("Exit");
f.addCommand(ok);
f.addCommand(exit);
f.addCommandListener(this);
f.show();
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
public void actionPerformed(ActionEvent ae) {
notifyDestroyed();
}
}
I would like to add another label under the "The Mairuwa Portal" and also place two buttons ("Report A Problem","Request Information") beneath this as well. An illustration of what I am describing is
label: The Mairuwa Portal
then another label beneath it: I want to:
Then two buttons beneath this Button:Report Problem Button: Request Information
I have been able to add OK and EXIT button to the project,but this above buttons I talked about should as I described.
These buttons will carry functionality. I hope this can be done in LWUIT.
You need to include all JSR's when compiling a LWUIT application in the IDE. LWUIT doesn't require them all to run but requires 184, 226, MMAPI & file connector to compile. This is causing your verification error.
I would recommend developing with the Sun/Oracle simulators and using the more device like emulators for QA.
The exception you got means your application was built incorrectly, see that Ruwwa is in the jar file that was produced by your build. If not fix your build.

Resources