So I tried to implemented a map fragment in my app. The application works perfectly on my Galaxy S4, but wont work on my Xperia Z. The fragment shows up blank, with no map. And LogCat states:
07-31 00:20:07.265: E/Google Maps Android API(8763): Failed to load map. Error contacting
Google servers. This is probably an authentication issue (but could be due to network errors).
So I checked if the Google-play-services_lib was referenced correct, and I do think so. All permissions are OK, and everything should work fine. (I assume the authentication problem si bogus since its working on the S4?).
I then checked logcat without filter and I get spammed with text making no sense:
07-31 00:23:45.398: E/LocSvc_adapter(705): I/<--- void globalEventCb(locClientHandleType, uint32_t, locClientEventIndUnionType, void*) line 89 QMI_LOC_EVENT_POSITION_REPORT_IND_V02
07-31 00:23:45.438: E/LocSvc_adapter(705): I/<--- void globalEventCb(locClientHandleType, uint32_t, locClientEventIndUnionType, void*) line 89 QMI_LOC_EVENT_NMEA_IND_V02
07-31 00:23:45.438: E/LocSvc_eng(705): I/<=== nmea_cb line 1681 0x74211aa0
07-31 00:23:45.448: E/LocSvc_adapter(705): I/<--- void globalEventCb(locClientHandleType, uint32_t, locClientEventIndUnionType, void*) line 89 QMI_LOC_EVENT_NMEA_IND_V02
07-31 00:23:45.448: E/LocSvc_eng(705): I/<=== nmea_cb line 1681 0x7331d878
07-31 00:23:45.458: E/LocSvc_adapter(705): I/<--- void globalEventCb(locClientHandleType, uint32_t, locClientEventIndUnionType, void*) line 89 QMI_LOC_EVENT_NMEA_IND_V02
07-31 00:23:45.458: E/LocSvc_eng(705): I/<=== nmea_cb line 1681 0x74211aa0
07-31 00:23:45.458: E/LocSvc_adapter(705): I/<--- void globalEventCb(locClientHandleType, uint32_t, locClientEventIndUnionType, void*) line 89 QMI_LOC_EVENT_NMEA_IND_V02
07-31 00:23:45.458: E/LocSvc_eng(705): I/<=== nmea_cb line 1681 0x74211aa0
07-31 00:23:45.478: E/LocSvc_adapter(705): I/<--- void globalEventCb(locClientHandleType, uint32_t, locClientEventIndUnionType, void*) line 89 QMI_LOC_EVENT_NMEA_IND_V02
07-31 00:23:45.478: E/LocSvc_eng(705): I/<=== nmea_cb line 1681 0x7331d878
07-31 00:23:45.478: E/LocSvc_adapter(705): I/<--- void globalEventCb(locClientHandleType, uint32_t, locClientEventIndUnionType, void*) line 89 QMI_LOC_EVENT_NMEA_IND_V02
07-31 00:23:45.478: E/LocSvc_eng(705): I/<=== nmea_cb line 1681 0x7331d878
07-31 00:23:45.488: E/LocSvc_adapter(705): I/<--- void globalEventCb(locClientHandleType, uint32_t, locClientEventIndUnionType, void*) line 89 QMI_LOC_EVENT_GNSS_SV_INFO_IND_V02
07-31 00:23:45.488: E/LocSvc_afw(705): I/<=== sv_status_cb - line 1043 14
And it just keeps on going like this. I can't make any sense out of it. If I remove everything related to maps, the error stops. So its something with the Google maps which trigger the error. Here is the classes containing the Gmaps code:
The .java file:
package com.nordoid.tracephone;
import android.content.Context;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
public class Mfragment_main extends Fragment
{
TextView settings;
TextView home;
TextView friends;
final int RQS_GooglePlayServices = 1;
MapFragment myMapFragment;
private GoogleMap map;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
}
@Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
View view = inflater.inflate(R.layout.mainmenu_main, container, false);
map = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.map1)).getMap();
map.setMyLocationEnabled(true);
setUpMap();
/*** Statiske posisjoner til MAPS ***/
final LatLng Pune = new LatLng(58.341907, 8.584957);
@SuppressWarnings("unused")
Marker pune = map.addMarker(new MarkerOptions()
.position(Pune)
.title("Friend 1")
.snippet("Christian")
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
final LatLng Pune1 = new LatLng(58.421157,7.400101);
@SuppressWarnings("unused")
Marker pune1 = map.addMarker(new MarkerOptions()
.position(Pune1)
.title("Friend 2")
.snippet("Howie")
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_VIOLET)));
final LatLng Pune2 = new LatLng(36.724576,-4.452317);
@SuppressWarnings("unused")
Marker pune2 = map.addMarker(new MarkerOptions()
.position(Pune2)
.title("Christian på ferie!")
.snippet("Partyyløva.")
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
return view;
}
private void setUpMap()
{
// Enable MyLocation Layer of Google Map
map.setMyLocationEnabled(true);
// Get LocationManager object from System Service LOCATION_SERVICE
LocationManager locationManager = (LocationManager)getActivity().getSystemService(Context.LOCATION_SERVICE);
// Create a criteria object to retrieve provider
Criteria criteria = new Criteria();
// Get the name of the best provider
String provider = locationManager.getBestProvider(criteria, true);
// Get Current Location
Location myLocation = locationManager.getLastKnownLocation(provider);
// Get latitude of the current location
double latitude = 60.0426;//myLocation.getLatitude();
// Get longitude of the current location
double longitude = 6.3286;//myLocation.getLongitude();
// Create a LatLng object for the current location
LatLng latLng = new LatLng(latitude, longitude);
// Show the current location in Google Map
map.moveCamera(CameraUpdateFactory.newLatLng(latLng));
// Zoom in the Google Map
map.animateCamera(CameraUpdateFactory.zoomTo(3));
// map.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).title("You are here!"));
}
}
The .xml file :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/slider"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.32" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="216dp"
android:layout_height="75dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="381dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="18dp"
android:layout_marginTop="83dp"
android:background="@drawable/inputfield"
android:gravity="left"
android:paddingTop="0dp" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:paddingLeft="7dp"
android:paddingTop="5dp"
android:text="QUICK TRACK"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#33b5e5" />
<SearchView
android:id="@+id/searchView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:iconifiedByDefault="false"
android:paddingBottom="20dp"
android:paddingLeft="-15dp" >
</SearchView>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/relativeLayout1"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/relativeLayout1"
android:layout_alignTop="@+id/relativeLayout1"
android:layout_marginBottom="50dp"
android:layout_marginTop="113dp"
android:background="@drawable/inputfield" >
<fragment
android:id="@+id/map1"
android:layout_width="200dp"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="14dp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_marginTop="3dp"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
And my manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nordoid.tracephone"
android:versionCode="9"
android:versionName="1.1.45" >
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="16" />
<permission
android:name="com.nordroid.tracephone.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
<uses-permission android:name="com.nordroid.tracephone.permission.MAPS_RECEIVE"/>
<uses-feature android:name="android.hardware.camera"/>
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature
android:name="android.hardware.telephony"
android:required="false" />
<uses-feature
android:name="android.hardware.location.gps"
android:required="false" />
<uses-feature
android:name="android.hardware.location.network"
android:required="false" />
<uses-feature
android:name="android.hardware.screen.portrait"
android:required="false" />
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<uses-feature
android:name="android.hardware.location"
android:required="false" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
>
<activity android:name="com.nordoid.tracephone.install.MainInstaller"
android:configChanges="orientation"
android:label="@string/title_activity_main"
android:noHistory="true"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Holo.Light.NoActionBar"
android:windowSoftInputMode="stateUnchanged"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" >
</activity>
<activity
android:name="com.nordoid.tracephone.Settings"
android:configChanges="orientation"
android:screenOrientation="portrait" />
<activity
android:name="com.nordoid.tracephone.MainMenu"
android:configChanges="orientation"
android:theme="@android:style/Theme.Holo.Light.NoActionBar"
android:windowSoftInputMode="stateVisible|adjustPan"
android:screenOrientation="portrait" />
<activity
android:name="com.nordoid.tracephone.background.ReceiveSMS2VideoActivityHidden"
android:theme="@style/Theme.someName" />
<activity
android:name="com.nordoid.tracephone.background.CameraActivityHidden"
android:theme="@style/Theme.someName2" />
<activity
android:name="com.nordoid.tracephone.FriendList"
android:theme="@style/Theme.someName2" />
<activity
android:name="com.nordoid.tracephone.googleplay"
android:theme="@style/Theme.someName2" />
<activity
android:name="com.nordoid.tracephone.Friend"
android:theme="@style/Theme.someName2" />
<activity android:name="com.nordoid.tracephone.background.CameraPreviewHidden" >
</activity>
<activity android:name="com.tapfortap.TapForTapActivity" />
<receiver
android:name="com.nordoid.tracephone.background.hidden_gps_and_mail"
android:enabled="true" >
<intent-filter>
<action android:name="intent.action.HIDDEN_GPS_AND_MAIL" >
</action>
</intent-filter>
</receiver>
<receiver
android:name="com.nordoid.tracephone.background.ReceiveSMS"
android:exported="true" >
<intent-filter android:priority="1000" >
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<receiver
android:name="com.nordoid.tracephone.background.ReceiveSMS2"
android:exported="true" >
<intent-filter android:priority="1000" >
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="THE MAPS API KEY"/>
</application>
</manifest>
I am aware of the horrible coding, its very messy right now. Sorry for that!