Reputation: 634
Whenever I try to initialize the map, I always get the "error UNKNOWN" message.
I tried the examples from HERE, but I get the same error on all of them. So I made a very simple and clean application with the sole purpose of loading the map. It still doesn't work and I can't put my finger on it.
I'm using Android, trying to target version 4.4 (KitKat). I am using the Premium SDK (during the 90 day trial). I verified the app key, code and licence key many times now. They are absolutely correct.
The registered package name is
com.example.workywork
but in the manifest I have:
package="com.example.workywork.testherepremium"
(It was supposed to be a test, so don't mind the package name :) ) I think it is right, since they asked for package name, not for package name + project name.
Here is the code from my simple application:
Build.Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.workywork.testherepremium"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation (name: 'HERE-sdk', ext: 'aar')
implementation 'com.vividsolutions:jts:1.13'
implementation 'com.google.code.gson:gson:2.8.0'
}
Activity layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.workywork.testherepremium.MainActivity">
<fragment
class="com.here.android.mpa.mapping.MapFragment"
android:id="@+id/mapfragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.constraint.ConstraintLayout>
Activity
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
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 MainActivity extends AppCompatActivity {
MapFragment mapFragment;
Map map;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.mapfragment);
mapFragment.init(new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(OnEngineInitListener.Error error) {
if (error == Error.NONE) {
map = mapFragment.getMap();
map.setCenter(new GeoCoordinate(49.259149, -123.008555),
Map.Animation.LINEAR);
map.setZoomLevel(13.2);
} else {
Toast.makeText(getApplicationContext(),"ERROR: Cannot initialize Map with error " + error,
Toast.LENGTH_LONG).show();
Log.e("mymsg", error.getStackTrace());
Log.e("mymsg", error.getDetails());
}
}
});
}
}
AndroidManifest.xml
...
<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.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:hardwareAccelerated="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!--Developers should put application credentials here.To obtain them, please register the application
at https://developer.here.com/develop/mobile-sdks-->
<meta-data android:name="com.here.android.maps.appid" android:value="-- app id --"/>
<meta-data android:name="com.here.android.maps.apptoken" android:value="-- app token --"/>
<meta-data android:name="com.here.android.maps.license.key" android:value="-- license --" />
<service
android:name="com.here.android.mpa.service.MapService"
android:label="HereMapService"
android:process="global.Here.Map.Service.v3"
android:exported="true">
<intent-filter>
<action android:name="com.here.android.mpa.service.MapService.v3">
</action>
</intent-filter>
</service>
</application>
I also tried to use
android:process="global.Here.Map.Service.v2"
with
android:name="com.here.android.mpa.service.MapService"
or
android:name="com.here.android.mpa.service.MapService.v2"
Or any other such combination.
What am I missing?
As you can see, I've been struggleing with this for a couple of days now ;) Thank you very much for your help. It is greatly appreciated.
Upvotes: 1
Views: 1463
Reputation: 1478
The applicationId
has to match the registered name exactly (in your case com.example.workywork
). Otherwise, I can't spot an issue with the code you've posted.
You can try following this guide: Creating a Simple Application Using the HERE SDK
Upvotes: 1