So far, the app has only one layout, activity_main.xml
.
The application does runs but exits almost immediately on a usb-connected developer Android phone.
I tried debugging and troubleshooting the app, but the result was always the same: the app keeps quitting.
Finally, I tried to edit the only layout in the app, activity_main.xml
.
I started adding, removing, and swapping elements.
I found out that the app runs just fine when the fragment
element is removed, and I don't know the explanation nor the solution to this issue.
Here's the activity_main.xml
below. The fragment
element I referred to has supportMap
id
property.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<FrameLayout
android:id="@+id/driverStatusLayout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/colorPrimary"
android:orientation="horizontal">
<TextView
android:id="@+id/totalOnlineDrivers"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:gravity="center"
android:text="@string/total_online_drivers"
android:textColor="@color/common_google_signin_btn_text_dark"
android:textSize="22sp" />
<android.support.v7.widget.SwitchCompat
android:id="@+id/driverStatusSwitch"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:layout_marginRight="15dp"
android:checked="false" />
</FrameLayout>
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/supportMap"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/driverStatusLayout"
tools:context="spartons.com.frisbeeGo.fragments.MapFragment" />
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
Here's MainActivity.java
:
package com.example.testbasna;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
public class MainActivity extends AppCompatActivity {
private GoogleMap googleMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}