title: E/MotionRecognitionManager: mSContextService = null
body: <p>I am writing a geolocation tracker and it doesn't run after OnConnected(). I got some errors but haven't found anything on solving them. Would greatly appreciate any help. Sorry for being such a noob. It asks for more details, but what to write?</p>
  
  <p>So here is the log:</p>
  
  <pre><code>    08-20 23:31:43.642 31662-31662/? E/Zygote: v2
      08-20 23:31:43.642 31662-31662/? W/SELinux: Function: selinux_compare_spd_ram, index[1], priority [2], priority version is VE=SEPF_SECMOBILE_6.0.1_0030
      08-20 23:31:43.642 31662-31662/? W/SELinux: SELinux: seapp_context_lookup: seinfo=default, level=s0:c512,c768, pkgname=com.aurelius.agrotest 
      08-20 23:31:44.202 31662-31662/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,-div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.aurelius.agrotest-1/split_lib_dependencies_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.aurelius.agrotest-1@split_lib_dependencies_apk.apk@classes.dex) because non-0 exit status
      08-20 23:31:44.542 31662-31662/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,-div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.aurelius.agrotest-1/split_lib_slice_0_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.aurelius.agrotest-1@split_lib_slice_0_apk.apk@classes.dex) because non-0 exit status
      08-20 23:31:44.622 31662-31662/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,-div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.aurelius.agrotest-1/split_lib_slice_1_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.aurelius.agrotest-1@split_lib_slice_1_apk.apk@classes.dex) because non-0 exit status
      08-20 23:31:44.702 31662-31662/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,-div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.aurelius.agrotest-1/split_lib_slice_2_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.aurelius.agrotest-1@split_lib_slice_2_apk.apk@classes.dex) because non-0 exit status
      08-20 23:31:44.792 31662-31662/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,-div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.aurelius.agrotest-1/split_lib_slice_3_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.aurelius.agrotest-1@split_lib_slice_3_apk.apk@classes.dex) because non-0 exit status
      08-20 23:31:44.872 31662-31662/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,-div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.aurelius.agrotest-1/split_lib_slice_4_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.aurelius.agrotest-1@split_lib_slice_4_apk.apk@classes.dex) because non-0 exit status
      08-20 23:31:44.952 31662-31662/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,-div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.aurelius.agrotest-1/split_lib_slice_5_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.aurelius.agrotest-1@split_lib_slice_5_apk.apk@classes.dex) because non-0 exit status
      08-20 23:31:45.032 31662-31662/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,-div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.aurelius.agrotest-1/split_lib_slice_6_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.aurelius.agrotest-1@split_lib_slice_6_apk.apk@classes.dex) because non-0 exit status
      08-20 23:31:45.112 31662-31662/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,-div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.aurelius.agrotest-1/split_lib_slice_7_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.aurelius.agrotest-1@split_lib_slice_7_apk.apk@classes.dex) because non-0 exit status
      08-20 23:31:45.192 31662-31662/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,-div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.aurelius.agrotest-1/split_lib_slice_8_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.aurelius.agrotest-1@split_lib_slice_8_apk.apk@classes.dex) because non-0 exit status
      08-20 23:31:45.272 31662-31662/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm --instruction-set-features=smp,-div,-atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=cortex-a53 --instruction-set-features=default --dex-file=/data/app/com.aurelius.agrotest-1/split_lib_slice_9_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.aurelius.agrotest-1@split_lib_slice_9_apk.apk@classes.dex) because non-0 exit status
      08-20 23:31:45.272 31662-31662/? W/System: ClassLoader referenced unknown path: /data/app/com.aurelius.agrotest-1/lib/arm
      08-20 23:31:45.602 31662-31662/? W/System: ClassLoader referenced unknown path: /data/data/com.google.android.gms/app_chimera/m/0000000e/n/armeabi
      08-20 23:31:46.022 31662-31662/? E/MotionRecognitionManager: mSContextService = null
      08-20 23:31:46.022 31662-31662/? E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@42f9821
      08-20 23:31:46.162 31662-31662/? W/afz: copyMemory is missing from platform - proto runtime falling back to safer methods.
      08-20 23:31:48.162 31662-31757/com.aurelius.agrotest W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
      08-20 23:31:48.222 31662-31757/com.aurelius.agrotest W/System: ClassLoader referenced unknown path: /data/data/com.google.android.gms/app_chimera/m/0000000c/n/armeabi-v7a
      08-20 23:31:48.222 31662-31757/com.aurelius.agrotest W/System: ClassLoader referenced unknown path: /data/data/com.google.android.gms/app_chimera/m/0000000c/n/armeabi
  </code></pre>
  
  <p>The AndroidManifest:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.aurelius.agrotest"&gt;
  
      &lt;!--
           The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
           Google Maps Android API v2, but you must specify either coarse or fine
           location permissions for the 'MyLocation' functionality. 
      --&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
  
          &lt;!--
               The API key for Google Maps-based APIs is defined as a string resource.
               (See the file "res/values/google_maps_api.xml").
               Note that the API key is linked to the encryption key used to sign the APK.
               You need a different API key for each encryption key, including the release key that is used to
               sign the APK for publishing.
               You can define the keys for the debug and release targets in src/debug/ and src/release/. 
          --&gt;
          &lt;meta-data
              android:name="com.google.android.geo.API_KEY"
              android:value="@string/google_maps_key" /&gt;
  
          &lt;activity
              android:name=".MapTrackingActivity"
              android:label="@string/title_activity_map_tracking"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
          &lt;service
              android:name=".RouteService"
              android:enabled="true"
              android:exported="true" /&gt;
  
          &lt;activity
              android:name=".ProcessResultActivity"
              android:label="@string/title_activity_process_result"&gt;&lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>And the activity</p>
  
  <pre><code>   package com.aurelius.agrotest;
  
     import android.Manifest;
     import android.content.BroadcastReceiver;
     import android.content.Context;
     import android.content.Intent;
     import android.content.IntentFilter;
     import android.content.pm.PackageManager;
     import android.graphics.Color;
     import android.location.Location;
     import android.os.Bundle;
     import android.support.annotation.NonNull;
     import android.support.annotation.Nullable;
     import android.support.v4.app.ActivityCompat;
     import android.support.v4.app.FragmentActivity;
     import android.support.v4.content.LocalBroadcastManager;
     import android.util.Log;
     import com.google.android.gms.common.api.GoogleApiClient;
     import com.google.android.gms.common.api.PendingResult;
     import com.google.android.gms.common.api.ResultCallback;
     import com.google.android.gms.common.api.Status;
     import com.google.android.gms.location.LocationRequest;
     import com.google.android.gms.location.LocationServices;
     import com.google.android.gms.location.LocationSettingsRequest;
     import com.google.android.gms.location.LocationSettingsResult;
     import com.google.android.gms.location.LocationSettingsStatusCodes;
     import com.google.android.gms.maps.CameraUpdateFactory;
     import com.google.android.gms.maps.GoogleMap;
     import com.google.android.gms.maps.OnMapReadyCallback;
     import com.google.android.gms.maps.SupportMapFragment;
     import com.google.android.gms.maps.model.CameraPosition;
     import com.google.android.gms.maps.model.LatLng;
     import com.google.android.gms.maps.model.MarkerOptions;
     import com.google.android.gms.maps.model.Polyline;
     import com.google.android.gms.maps.model.PolylineOptions;
     import com.aurelius.agrotest.database.DatabaseQuery;
     import java.util.ArrayList;
     import java.util.List;
     public class MapTrackingActivity extends FragmentActivity implements OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks{
  private static final String TAG = MapTrackingActivity.class.getSimpleName();
  private GoogleApiClient mGoogleApiClient;
  private Location mLastLocation;
  private LocationRequest mLocationRequest;
  private double latitudeValue = 0.0;
  private double longitudeValue = 0.0;
  private GoogleMap mMap;
  private DatabaseQuery mQuery;
  private RouteBroadCastReceiver routeReceiver;
  private List&lt;LatLng&gt; startToPresentLocations;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_map_tracking);
      Log.d(TAG, "OnCreate has been called");
      if (mGoogleApiClient == null) {
          mGoogleApiClient = new GoogleApiClient.Builder(this)
                  .addConnectionCallbacks(this)
                  .addApi(LocationServices.API)
                  .build();
      }
      mQuery = new DatabaseQuery(this);
      startToPresentLocations = mQuery.getAllLocationObjects();//DBQ
      mLocationRequest = createLocationRequest();
      routeReceiver = new RouteBroadCastReceiver();
      // Obtain the SupportMapFragment and get notified when the map is ready to be used.
      SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
      mapFragment.getMapAsync(this);
  }
  @Override
  public void onMapReady(GoogleMap googleMap) {
      mMap = googleMap;
      Log.d(TAG, "OnMapReady has been called");
  }
  private void markStartingLocationOnMap(GoogleMap mapObject, LatLng location){
      mapObject.addMarker(new MarkerOptions().position(location).title("Current location"));
      mapObject.moveCamera(CameraUpdateFactory.newLatLng(location));
  }
  @Override
  public void onConnected(@Nullable Bundle bundle) {
      Log.d(TAG, "Connection method has been called");
      LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(mLocationRequest);
      PendingResult&lt;LocationSettingsResult&gt; result = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
      result.setResultCallback(new ResultCallback&lt;LocationSettingsResult&gt;() {
          @Override
          public void onResult(@NonNull LocationSettingsResult result) {
              Log.d(TAG, "Connection has results!");
              final Status status = result.getStatus();
              switch (status.getStatusCode()) {
                  case LocationSettingsStatusCodes.SUCCESS:
                      if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
                              &amp;&amp; ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
                          mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
                          if (mLastLocation != null) {
                              latitudeValue = mLastLocation.getLatitude();
                              longitudeValue = mLastLocation.getLongitude();
                              Log.d(TAG, "Latitude 4: " + latitudeValue + " Longitude 4: " + longitudeValue);
                              refreshMap(mMap);
                              markStartingLocationOnMap(mMap, new LatLng(latitudeValue, longitudeValue));
                              startPolyline(mMap, new LatLng(latitudeValue, longitudeValue));
                          }
                      }
                      break;
                  case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
                      break;
              }
          }
      });
  }
  @Override
  public void onConnectionSuspended(int i) {
  }
  private class RouteBroadCastReceiver extends BroadcastReceiver{
      @Override
      public void onReceive(Context context, Intent intent) {
          String local = intent.getExtras().getString("RESULT_CODE");
          assert local != null;
          if(local.equals("LOCAL")){
              //get all data from database
              startToPresentLocations = mQuery.getAllLocationObjects();//DBQ
              if(startToPresentLocations.size() &gt; 0){
                  //prepare map drawing.
                  List&lt;LatLng&gt; locationPoints = startToPresentLocations;
                  refreshMap(mMap);
                  markStartingLocationOnMap(mMap, locationPoints.get(0));
                  drawRouteOnMap(mMap, locationPoints);
              }
          }
      }
  }
  /*private List&lt;LatLng&gt; getPoints(List&lt;Location&gt; mLocations){
      List&lt;LatLng&gt; points = new ArrayList&lt;LatLng&gt;();
      for(Location mLocation : mLocations){
          points.add(new LatLng(mLocation.getLatitude(), mLocation.getLongitude()));
      }
      return points;
  }*/
  private void startPolyline(GoogleMap map, LatLng location){
      if(map == null){
          Log.d(TAG, "Map object is not null");
          return;
      }
      PolylineOptions options = new PolylineOptions().width(5).color(Color.BLUE).geodesic(true);
      options.add(location);
      Polyline polyline = map.addPolyline(options);
      CameraPosition cameraPosition = new CameraPosition.Builder()
              .target(location)
              .zoom(16)
              .build();
      map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
  }
  private void drawRouteOnMap(GoogleMap map, List&lt;LatLng&gt; positions){
      PolylineOptions options = new PolylineOptions().width(5).color(Color.BLUE).geodesic(true);
      options.addAll(positions);
      Polyline polyline = map.addPolyline(options);
      CameraPosition cameraPosition = new CameraPosition.Builder()
              .target(new LatLng(positions.get(0).latitude, positions.get(0).longitude))
              .zoom(17)
              .bearing(90)
              .tilt(40)
              .build();
      map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
  }
  private void refreshMap(GoogleMap mapInstance){
      mapInstance.clear();
  }
  protected LocationRequest createLocationRequest() {
      LocationRequest mLocationRequest = new LocationRequest();
      mLocationRequest.setInterval(5000);
      mLocationRequest.setFastestInterval(3000);
      mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
      return mLocationRequest;
  }
  @Override
  protected void onResume() {
      super.onResume();
      if(routeReceiver == null){
          routeReceiver = new RouteBroadCastReceiver();
      }
      IntentFilter filter = new IntentFilter(RouteService.ACTION);
      LocalBroadcastManager.getInstance(this).registerReceiver(routeReceiver, filter);
  }
  @Override
  protected void onPause() {
      super.onPause();
      LocalBroadcastManager.getInstance(this).unregisterReceiver(routeReceiver);
  }
  @Override
  protected void onStart() {
      mGoogleApiClient.connect();
      super.onStart();
  }
  @Override
  protected void onStop() {
      mGoogleApiClient.disconnect();
      super.onStop();
  }
  </code></pre>
  
  <p>}</p>