UPDATE
I have tried it with my coworkers N6. It WORKED. So I grab a new out of box N6. I install Play services.. IT FAILS.
I have been at this all day. It worked perfectly all day yesterday. All I can remember was gradle had me swap networks (security) to download something. A hour or so later I go to build.. nada. Revert to last nights checkings, nada. It WORKS on my personal phone but not the nexus 6. Heck I even flashed the #### phone to 5.1 nexus image. Nada. Cleared out all the cached gradle files, twiddled the min SDK numbers. Nothing. Oh and googled for hours.
I build, run no problem. Navigate to the activity with my map, CRASH. Though only on the nexus, my note 4 has no crashes. The issue isn't the null pointer, the issue is
06-23 15:01:21.414 19516-19516/? W/ResourcesManager﹕ Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
06-23 15:01:21.414 19516-19516/? W/ResourcesManager﹕ Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
Full Below
06-23 15:01:14.982 19516-19535/xxxx.xxxx.xxxx.mobility I/Adreno﹕ EGLInit: QTI Build: 01/29/15, 1bccc5d, I0ba6dce82d
06-23 15:01:14.990 19516-19535/xxxx.xxxx.xxxx.mobility I/OpenGLRenderer﹕ Initialized EGL, version 1.4
06-23 15:01:14.997 19516-19535/xxxx.xxxx.xxxx.mobility D/OpenGLRenderer﹕ Enabling debug mode 0
06-23 15:01:16.733 19516-19526/? I/art﹕ Ignoring second debugger -- accepting and dropping
06-23 15:01:21.407 19516-19516/? I/zzy﹕ Making Creator dynamically
06-23 15:01:21.414 19516-19516/? W/ResourcesManager﹕ Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
06-23 15:01:21.414 19516-19516/? W/ResourcesManager﹕ Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
06-23 15:01:21.443 19516-19516/? I/Google Maps Android API﹕ Google Play services client version: 7571000
06-23 15:01:21.452 19516-19516/? I/Google Maps Android API﹕ Google Play services package version: 7574430
06-23 15:01:21.845 19516-19516/? D/AndroidRuntime﹕ Shutting down VM
06-23 15:01:21.846 19516-19516/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: xxxx.xxxx.xxxx.mobility, PID: 19516
java.lang.NullPointerException: Attempt to invoke virtual method 'double android.location.Location.getLatitude()' on a null object reference
at xxxx.xxxx.xxxx.mobility.Map.MapPaneActivity.onMapReady(MapPaneActivity.java:109)
at com.google.android.gms.maps.MapFragment$zza$1.zza(Unknown Source)
at com.google.android.gms.maps.internal.zzm$zza.onTransact(Unknown Source)
at android.os.Binder.transact(Binder.java:380)
at com.google.android.gms.maps.internal.ba.a(SourceFile:82)
at com.google.maps.api.android.lib6.d.fz.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Cut out most of the package names. The permissions are at the top.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xcv.qwe.xxxxx.mobility"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<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.WRITE_EXTERNAL_STORAGE"/>
<permission
android:name="xcv.qwe.xxxxx.mobility.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="xcv.qwe.xxxxx.mobility.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".StartSplashActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/title_activity_start_splash" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="xxxxx"
<activity
android:name=".StartSplashActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/title_activity_start_splash" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
<receiver
android:name="xxxxx"
android:enabled="true" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" >
</action>
</intent-filter>
</receiver>
<receiver
android:name="xxxxxr"
android:enabled="true" >
</receiver>
<receiver
android:name="xxxxx"
android:enabled="true" >
<intent-filter>
<action android:name="local.transition.initialize" />
<action android:name="local.transition.exited_geofence" />
<action android:name="local.transition.stopped_moving" />
<action android:name="local.transition.stop_tracking" />
</intent-filter>
</receiver>
<receiver android:name="xxxxx" >
<intent-filter>
<action android:name="android.intent.action.ACTION_BATTERY_LOW" />
<action android:name="android.intent.action.ACTION_BATTERY_OKAY" />
</intent-filter>
</receiver>
<service
android:name="xxxxx"
android:enabled="true" >
</service>
<service android:name="xxxxx" >
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data
android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>
<service
android:name="xxxxx"
android:enabled="true"
android:exported="false" >
</service>
<service
android:name="xxxxxe"
android:enabled="true"
android:exported="false" >
</service>
<service
android:name="xxxxx"
android:enabled="true"
android:exported="false" >
</service>
<service
android:name="xxxxx"
android:exported="true"
android:process=":sync" >
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>
<meta-data
android:name="android.content.SyncAdapter"
android:resource="@xml/syncadapter" />
</service>
<provider
android:name="xxxxx"
android:authorities="xxxxx"
android:exported="false"
android:syncable="true" />
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
</activity>
<activity
android:name="xxxxx.MainActivity"
android:label="@string/app_name" >
</activity>
<activity
android:name=".InformedConsentActivity"
android:label="@string/title_activity_informed_consent"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
</activity>
<activity
android:name=".calendar.CalendarScrapeActivity"
android:label="@string/title_activity_calendar_scrape"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
</activity>
<activity
android:name=".calendar.CalendarViewerActivity"
android:label="@string/title_activity_calendar_viewer"
android:theme="@style/Theme.AppCompat.Light"
>
</activity>
<activity
android:name=".Map.MapPaneActivity"
android:label="@string/title_activity_calendar_viewer"
android:theme="@style/Theme.AppCompat.Light"
>
</activity>
" />
<receiver
android:name="xxxxx"
android:enabled="true" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" >
</action>
</intent-filter>
</receiver>
<receiver
android:name="xxxxx"
android:enabled="true" >
<intent-filter>
<action android:name="xxxxx" />
</intent-filter>
</receiver>
<receiver
android:name="xxxxx"
android:enabled="true" >
<intent-filter>
<action android:name="local.transition.initialize" />
<action android:name="local.transition.exited_geofence" />
<action android:name="local.transition.stopped_moving" />
<action android:name="local.transition.stop_tracking" />
</intent-filter>
</receiver>
<receiver android:name="xxxxx" >
<intent-filter>
<action android:name="android.intent.action.ACTION_BATTERY_LOW" />
<action android:name="android.intent.action.ACTION_BATTERY_OKAY" />
</intent-filter>
</receiver>
<service
android:name="xxxxx"
android:enabled="true" >
</service>
<service android:name="xxxxx" >
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data
android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>
<service
android:name="xxxxx"
android:exported="true"
android:process=":sync" >
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>
<meta-data
android:name="android.content.SyncAdapter"
android:resource="@xml/syncadapter" />
</service>
<provider
android:name="xxxxtracker.smap.StubContentProvider"
android:authorities="xxxxtracker.provider"
android:exported="false"
android:syncable="true" />
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
</activity>
<activity
android:name="xxxxtracker.MainActivity"
android:label="@string/app_name" >
</activity>
<activity
android:name=".InformedConsentActivity"
android:label="@string/title_activity_informed_consent"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
</activity>
<activity
android:name=".calendar.CalendarScrapeActivity"
android:label="@string/title_activity_calendar_scrape"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
</activity>
<activity
android:name=".calendar.CalendarViewerActivity"
android:label="@string/title_activity_calendar_viewer"
android:theme="@style/Theme.AppCompat.Light"
>
</activity>
<activity
android:name=".Map.MapPaneActivity"
android:label="@string/title_activity_calendar_viewer"
android:theme="@style/Theme.AppCompat.Light"
>
</activity>
</application>
Executing tasks: [:mobility:assembleDebug]
Configuration on demand is an incubating feature.
:tracker:compileLint
:tracker:copyReleaseLint UP-TO-DATE
:tracker:preBuild UP-TO-DATE
:tracker:preReleaseBuild UP-TO-DATE
:tracker:checkReleaseManifest
:tracker:preDebugAndroidTestBuild UP-TO-DATE
:tracker:preDebugBuild UP-TO-DATE
:tracker:preDebugUnitTestBuild UP-TO-DATE
:tracker:preReleaseUnitTestBuild UP-TO-DATE
:tracker:prepareComAndroidSupportAppcompatV72200Library UP-TO-DATE
:tracker:prepareComAndroidSupportMediarouterV72200Library UP-TO-DATE
:tracker:prepareComAndroidSupportSupportV42200Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServices750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesAds750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesAnalytics750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesAppindexing750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesAppinvite750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesAppstate750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesBase750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesCast750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesDrive750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesFitness750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesGames750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesGcm750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesIdentity750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesLocation750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesMaps750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesNearby750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesPanorama750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesPlus750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesSafetynet750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesWallet750Library UP-TO-DATE
:tracker:prepareComGoogleAndroidGmsPlayServicesWearable750Library UP-TO-DATE
:tracker:prepareReleaseDependencies
:tracker:compileReleaseAidl UP-TO-DATE
:tracker:compileReleaseRenderscript UP-TO-DATE
:tracker:generateReleaseBuildConfig UP-TO-DATE
:tracker:generateReleaseAssets UP-TO-DATE
:tracker:mergeReleaseAssets UP-TO-DATE
:tracker:generateReleaseResValues UP-TO-DATE
:tracker:generateReleaseResources UP-TO-DATE
:tracker:mergeReleaseResources UP-TO-DATE
:tracker:processReleaseManifest UP-TO-DATE
:tracker:processReleaseResources UP-TO-DATE
:tracker:generateReleaseSources UP-TO-DATE
:tracker:processReleaseJavaRes UP-TO-DATE
:tracker:compileReleaseJava UP-TO-DATE
:tracker:extractReleaseAnnotations UP-TO-DATE
:tracker:mergeReleaseProguardFiles UP-TO-DATE
:tracker:packageReleaseJar UP-TO-DATE
:tracker:compileReleaseNdk UP-TO-DATE
:tracker:packageReleaseJniLibs UP-TO-DATE
:tracker:packageReleaseLocalJar UP-TO-DATE
:tracker:packageReleaseRenderscript UP-TO-DATE
:tracker:packageReleaseResources UP-TO-DATE
:tracker:bundleRelease UP-TO-DATE
:mobility:preBuild UP-TO-DATE
:mobility:preDebugBuild UP-TO-DATE
:mobility:checkDebugManifest
:mobility:preReleaseBuild UP-TO-DATE
:mobility:prepareAndroidtrackerUnspecifiedLibrary UP-TO-DATE
:mobility:prepareComAndroidSupportAppcompatV72200Library UP-TO-DATE
:mobility:prepareComAndroidSupportMediarouterV72200Library UP-TO-DATE
:mobility:prepareComAndroidSupportSupportV42220Library UP-TO-DATE
:mobility:prepareComGithubAlamkanakAndroidWeekView123Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServices750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesAds750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesAnalytics750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesAppindexing750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesAppinvite750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesAppstate750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesBase750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesCast750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesDrive750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesFitness750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesGames750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesGcm750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesIdentity750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesLocation750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesMaps750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesNearby750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesPanorama750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesPlus750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesSafetynet750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesWallet750Library UP-TO-DATE
:mobility:prepareComGoogleAndroidGmsPlayServicesWearable750Library UP-TO-DATE
:mobility:prepareComGoogleMapsAndroidAndroidMapsUtils034Library UP-TO-DATE
:mobility:prepareDebugDependencies
:mobility:compileDebugAidl UP-TO-DATE
:mobility:compileDebugRenderscript UP-TO-DATE
:mobility:generateDebugBuildConfig UP-TO-DATE
:mobility:generateDebugAssets UP-TO-DATE
:mobility:mergeDebugAssets UP-TO-DATE
:mobility:generateDebugResValues UP-TO-DATE
:mobility:generateDebugResources UP-TO-DATE
:mobility:mergeDebugResources UP-TO-DATE
:mobility:processDebugManifest UP-TO-DATE
:mobility:processDebugResources UP-TO-DATE
:mobility:generateDebugSources UP-TO-DATE
:mobility:processDebugJavaRes UP-TO-DATE
:mobility:compileDebugJava UP-TO-DATE
:mobility:compileDebugNdk UP-TO-DATE
:mobility:compileDebugSources UP-TO-DATE
:mobility:preDexDebug UP-TO-DATE
:mobility:dexDebug UP-TO-DATE
:mobility:validateMyConfigSigning
:mobility:packageDebug UP-TO-DATE
:mobility:zipalignDebug UP-TO-DATE
:mobility:assembleDebug UP-TO-DATE
BUILD SUCCESSFUL
Total time: 2.959 secs
The Java code. It is mostly the sample code with a few click listeners. I did change the map to hybrid, from the sample... EDIT I don't think it was a google sample now that I see the issue.
package xxx.xxx.xxx.mobility.Map;
import android.app.Activity;
import android.content.Intent;
import android.location.Address;
import android.location.Criteria;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.Toast;
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.OnMapReadyCallback;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import xxx.xxx.xxx.mobility.R;
import xxx.xxx.xxx.mobility.calendar.CalendarConstants;
public class MapPaneActivity extends Activity implements OnMapReadyCallback, GoogleMap.OnMapClickListener, GoogleMap.OnMapLongClickListener, Spinner.OnItemSelectedListener {
final static int MAP_MAX_RESULTS = 10;
final static String TAG = "MapPaneActivity";
private Spinner map_selection_spinner;
private ArrayAdapter<String> mMapAddressAdapter;
private LatLng mLatLng;
private String mCurrentSelection = "";
Button submit_map_button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map_pane);
map_selection_spinner = (Spinner) findViewById(R.id.map_selection_spinner);
submit_map_button = (Button) findViewById(R.id.submit_map_button);
MapFragment mapFragment = (MapFragment) getFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
map_selection_spinner.setOnItemSelectedListener(this);
/*
* The submit button will take the currently selected label from the spinner
* and return to the calling activity.
*/
submit_map_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle bundle = new Bundle();
bundle.putString(CalendarConstants.mapDataKey, mLatLng+CalendarConstants.divider+ mCurrentSelection);
Intent intent = new Intent();
intent.putExtras(bundle);
setResult(RESULT_OK, intent);
finish();
}
});
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos,long id) {
if (mMapAddressAdapter != null) {
submit_map_button.setEnabled(true);
mCurrentSelection = mMapAddressAdapter.getItem(pos);
// Toast.makeText(getApplicationContext(), mCurrentSelection, Toast.LENGTH_LONG).show();
}
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
@Override
public void onMapReady(GoogleMap map) {
map.setMyLocationEnabled(true);
map.setOnMapClickListener(this);
map.setOnMapLongClickListener(this);
/*
* Set the map to our cuurent location
*/
map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
String provider = locationManager.getBestProvider(criteria, true);
Location myLocation = locationManager.getLastKnownLocation(provider);
double latitude = myLocation.getLatitude();
double longitude = myLocation.getLongitude();
LatLng latLng = new LatLng(latitude, longitude);
map.moveCamera(CameraUpdateFactory.newLatLng(latLng));
// Zoom in the Google Map
map.animateCamera(CameraUpdateFactory.zoomTo(17));
map.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).title(getResources().getString(R.string.your_local)));
}
/**
* Handles the clicking of the map fragment.
* This will mark a location and kick off populating the
* spinner with addresses
* @param latLng
*/
@Override
public void onMapClick(LatLng latLng) {
mLatLng = latLng;
// Toast.makeText(getApplicationContext(), "Clicked at.. " + mLatLng, Toast.LENGTH_LONG).show();
List<Address> addressList;
Geocoder geocoder = new Geocoder(getApplicationContext());
double latitude = mLatLng.latitude;
double longitude = mLatLng.longitude;
try {
addressList = geocoder.getFromLocation(latitude, longitude, MAP_MAX_RESULTS);
for(Address address : addressList){
Log.d(TAG,address+" is at "+mLatLng);
}
}
catch (IOException exception){
Log.e(TAG, "Got an IO exeption!");
}
}
@Override
public void onMapLongClick(LatLng latLng) {
onMapClick(latLng);
}
}
Your problem is here:
Based on your stack trace,
getLastKnownLocation()
is returningnull
. That is documented behavior.getLastKnownLocation()
is only really good for optimistic checks on location, where if it does returnnull
you either live without the location data or you use other methods to request location updates and work with the location once it becomes available.