title: Cannot create HERE SDK object before MapEngine is initialized. See MapEngine.init()
body: <p>I am getting the <code>com.here.android.mpa.common.UnintializedMapEngineException</code> error. That states:</p>
  
  <blockquote>
    <p>Cannot create HERE SDK object before MapEngine is initialized. See MapEngine.init()</p>
  </blockquote>
  
  <p>The code has been taken from Here Maps own example on <a href="https://github.com/heremaps/here-android-sdk-examples/tree/master/geocoder-and-reverse-geocoder" rel="nofollow noreferrer">GitHub</a>.</p>
  
  <p>In my MainActivity I am calling <code>geoCodeAddress("some address")</code> that is when the error is thrown.</p>
  
  <p>I am using HERE SDK Version: 3.11.2.82</p>
  
  <p><strong>Can anyone see what I am might be doing wrong?</strong></p>
  
  <p><strong>Manifest</strong></p>
  
  <pre><code>    &lt;meta-data
          android:name="com.here.android.maps.appid"
          android:value="MyAppIdHere" /&gt;
      &lt;meta-data
          android:name="com.here.android.maps.apptoken"
          android:value="MyAppTokenHere" /&gt;
      &lt;meta-data
          android:name="com.here.android.maps.license.key"
          android:value="MyKeyHere" /&gt;
      &lt;meta-data
          android:name="INTENT_NAME"
          android:value="HereMappingIntent" /&gt;
  
      &lt;service
          android:name="com.here.android.mpa.service.MapService"
          android:exported="false"
          android:label="HereMapping"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="HereMappingIntent"&gt;&lt;/action&gt;
          &lt;/intent-filter&gt;
      &lt;/service&gt;
  </code></pre>
  
  <p><strong>HereGeocoder.java</strong></p>
  
  <pre><code>public class HereGeoCoder {
      private String                TAG = getClass().getSimpleName();
      private IHereGeoCoderListener mListener;
      private AppCompatActivity     mActivity;
  
      public HereGeoCoder(AppCompatActivity activity, IHereGeoCoderListener listener) {
          this.mActivity = activity;
          this.mListener = listener;
          initMapEngine();
      }
  
      private void initMapEngine() {
          String diskCacheRoot = Environment.getExternalStorageDirectory().getPath() + File.separator + ".isolated-here-maps";
          String intentName = "";
          try {
              ApplicationInfo ai     = mActivity.getPackageManager().getApplicationInfo(mActivity.getPackageName(), PackageManager.GET_META_DATA);
              Bundle          bundle = ai.metaData;
              intentName = bundle.getString("INTENT_NAME");
          }
          catch (PackageManager.NameNotFoundException e) {
              Log.e(this.getClass().toString(), "Failed to find intent name, NameNotFound: " + e.getMessage());
          }
  
          boolean success = com.here.android.mpa.common.MapSettings.setIsolatedDiskCacheRootPath(diskCacheRoot, intentName);
          if (!success) {
  
          } else {
  
              MapEngine.getInstance().init(new ApplicationContext(mActivity), new OnEngineInitListener() {
                  @Override
                  public void onEngineInitializationCompleted(Error error) {
                  //Here is 
                      Log.e(TAG, "Map Engine initialized with error code: " + error);
                      Toast.makeText(mActivity, "Map Engine initialized with error code:" + error, Toast.LENGTH_SHORT).show();
                  }
              });
          }
      }
  
      public void getCoordinatesForAddress(String address) {
          GeocodeRequest geocodeRequest = new GeocodeRequest(address);
          geocodeRequest.execute(new ResultListener&lt;List&lt;GeocodeResult&gt;&gt;() {
              @Override
              public void onCompleted(List&lt;GeocodeResult&gt; results, ErrorCode errorCode) {
                  if (errorCode == ErrorCode.NONE) {
                      if (results.size() &gt; 0) {
                          HashMap&lt;String, Double&gt; coords = new HashMap&lt;&gt;();
                          GeocodeResult           result = results.get(0);
                          coords.put("Latitude", result.getLocation().getCoordinate().getLatitude());
                          coords.put("Longitude", result.getLocation().getCoordinate().getLongitude());
                          if (mListener != null) {
                              mListener.onDidDecodeAddress(coords);
                          }
                      } 
                  } 
              }
          });
      }
  }
  </code></pre>
  
  <p>---- UPDATED </p>
  
  <p><strong>IHereGeoCoderListener.java</strong></p>
  
  <pre><code>public interface IHereGeoCoderListener {
      void onDidDecodeAddress(HashMap&lt;String, Double&gt; coordinates);
  
      void onDidDecodeCoordiantes(String address);
  }
  </code></pre>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
      private String   TAG = getClass().getSimpleName();
  
      private final static int      REQUEST_CODE_ASK_PERMISSIONS = 1;
      private static final String[] RUNTIME_PERMISSIONS          = {
              Manifest.permission.ACCESS_FINE_LOCATION,
              Manifest.permission.WRITE_EXTERNAL_STORAGE,
              Manifest.permission.INTERNET,
              Manifest.permission.ACCESS_WIFI_STATE,
              Manifest.permission.ACCESS_NETWORK_STATE
      };
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          //PERMSSIONS
          if (!hasPermissions(this, RUNTIME_PERMISSIONS)) {
              ActivityCompat.requestPermissions(this, RUNTIME_PERMISSIONS, REQUEST_CODE_ASK_PERMISSIONS);
          }
  
          geoCodeAddress("1 Broad St, Chattanooga, TN 37402");
  
      }
  
  
      //PERMISSIONS
      private static boolean hasPermissions(Context context, String... permissions) {
          if (permissions != null) {
              for (String permission : permissions) {
                  if (ActivityCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) {
                      return false;
                  }
              }
          }
          return true;
      }
  
      @Override
      public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
          switch (requestCode) {
              case REQUEST_CODE_ASK_PERMISSIONS: {
                  for (int index = 0; index &lt; permissions.length; index++) {
                      if (grantResults[index] != PackageManager.PERMISSION_GRANTED) {
  
                          /*
                           * If the user turned down the permission request in the past and chose the
                           * Don't ask again option in the permission request system dialog.
                           */
                          if (!ActivityCompat.shouldShowRequestPermissionRationale(this, permissions[index])) {
                              Toast.makeText(this, "Required permission " + permissions[index] + " not granted. Please go to settings and turn on for sample app",
                                      Toast.LENGTH_LONG).show();
                          } else {
                              Toast.makeText(this, "Required permission " + permissions[index] + " not granted", Toast.LENGTH_LONG).show();
                          }
                      }
                  }
                  break;
              }
              default:
                  super.onRequestPermissionsResult(requestCode, permissions, grantResults);
          }
      }
  
      // GEOCODER
      private void geoCodeAddress(String address) {
          if (hasPermissions(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
              //GEOCODER
              HereGeoCoder geoCoder = new HereGeoCoder(this, new IHereGeoCoderListener() {
                  @Override
                  public void onDidDecodeAddress(HashMap&lt;String, Double&gt; coordinates) {
                      for (HashMap.Entry&lt;String, Double&gt; entry : coordinates.entrySet()) {
                           Log.i(TAG, String.format("%s,%s", entry.getKey(), entry.getValue()));
                      }
                  }
  
                  @Override
                  public void onDidDecodeCoordiantes(String address) {
                      Log.i(TAG, "onDidDecodeCoordinates: " + address);
                  }
              });
  
              geoCoder.getCoordinatesForAddress(address);
          } else {
              Toast.makeText(this, "You do not have the correct permissions set.", Toast.LENGTH_LONG).show();
          }
      }
  
  }
  </code></pre>