Reputation: 167
Hi all I have build a here map api for mobile but something wrong in device a map not show. I'll follow this tutorial Creating a Simple Application Using the HERE SDK but in Logcat not show any error i don't know what i wrong please see my code
Here Map Class:
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import com.here.android.mpa.common.GeoCoordinate;
import com.here.android.mpa.common.OnEngineInitListener;
import com.here.android.mpa.mapping.Map;
import com.here.android.mpa.mapping.MapFragment;
public class hereMap extends AppCompatActivity {
// map embedded in the map fragment
private Map map = null;
// map fragment embedded in this activity
private MapFragment mapFragment = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_here_map);
// Search for the map fragment to finish setup by calling init().
mapFragment = (MapFragment)getFragmentManager().findFragmentById(
R.id.mapfragment);
mapFragment.init(new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(
OnEngineInitListener.Error error)
{
if (error == OnEngineInitListener.Error.NONE) {
// retrieve a reference of the map from the map fragment
map = mapFragment.getMap();
// Set the map center to the Vancouver region (no animation)
map.setCenter(new GeoCoordinate(49.196261, -123.004773, 0.0),
Map.Animation.NONE);
// Set the zoom level to the average between min and max
map.setZoomLevel(
(map.getMaxZoomLevel() + map.getMinZoomLevel()) / 2);
} else {
System.out.println("ERROR: Cannot initialize Map Fragment"+error.toString());
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_here_map, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Here map Activity:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<!-- Map Fragment embedded with the map object -->
<fragment
class="com.here.android.mpa.mapping.MapFragment"
android:id="@+id/mapfragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
Manifest File:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mpat.bkklife" >
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".LoginActivity"
android:label="@string/app_name"
android:windowSoftInputMode="adjustResize|stateVisible" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="com.here.android.maps.appid" android:value="My App ID:************"/>
<meta-data android:name="com.here.android.maps.apptoken" android:value="My App Token:***********"/>
<meta-data android:name="com.here.android.maps.license.key" android:value="My License Key:***********"/>
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
</activity>
<activity
android:name=".hereMap"
android:label="@string/title_activity_here_map" >
</activity>
</application>
</manifest>
UPDATE I got a error in log cat it say "ERROR: Cannot initialize Map Fragment MISSING_LIBRARY" when my app is init the map. But i already include HERE SDK and armeabi-v7a.
SpecDevice: Galaxsy S4 android 5.0.1 Lollipop
and this is my lib in project:
What i wrong of my code? Thank every one.
Upvotes: 0
Views: 1589
Reputation: 156
Please check which NAME SPACE you add with your application
Important: You must use the same package name as you have registered on developer.here.com. Failure to do so leads to a blank map to appear in your application.
some time we create application in short time so its might be possible to we miss few steps .
and if we are working on more then one apps its happens :)
Upvotes: 0
Reputation: 1647
It looks like the SDK package only includes native libraries for armeabi, so when you try to run on a device with a different CPU architecture (see https://developer.android.com/ndk/guides/abis.html), it can't find the proper binaries.
I'd be curious if you found a work-around, because this prevents my app from working on any device with a non armeabi CPU.
Upvotes: 0
Reputation: 1762
Also, did you fill in the following lines in the manifest file:
<meta-data android:name="com.here.android.maps.appid" android:value="My App ID"/>
<meta-data android:name="com.here.android.maps.apptoken" android:value="My App Token"/>
<meta-data android:name="com.here.android.maps.license.key" android:value="My License Key"/>
Please insert the appid, token and evaluation key that you obtained when registering the application.
Also, did you copy the native libraries from the SDK package ?
The structure should be: "project root"\libs\armeabi-v7a*.so
Upvotes: 0
Reputation: 1478
Try changing this line:
System.out.println("ERROR: Cannot initialize Map Fragment");
to this:
System.out.println("ERROR: Cannot initialize Map Fragment: " + error.toString());
then check the log to see what OnEngineInitListener.Error
you are receiving. This will help you find the root cause of the issue.
As Shiv mentioned in the comments, based on the AndroidManifest you posted it looks like the culprit could be a missing appId appCode and/or license key.
As a side note, instead of System.out.println, you should really use android.util.Log
Upvotes: 1