5

I followed the steps https://developer.here.com/mobile-sdks/documentation/android/topics/app-simple-android-studio.html

but I am getting error as : Cannot initialize Map Fragment MISSING_LIBRARIES

Map init code :

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());
                    Toast.makeText(MainActivity.this, " Error: " + error.toString(), Toast.LENGTH_LONG).show();
                }
            }
        });

gradle code

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.chethan.mobileapp.startmap"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:design:22.2.1'
    compile files('libs/HERE-sdk.jar')
    compile files('libs/jts-1.14.jar')
}

manifest code:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.ethan.mobileapp.startmap">

    <uses-permission android:name="android.permission.INTERNET" />
    <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.ACCESS_WIFI_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:hardwareAccelerated="true"
            android:theme="@style/AppTheme.NoActionBar">
            <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="Ksn3W" />
        <meta-data android:name="com.here.android.maps.apptoken" android:value="m90-Q" />
        <!--<meta-data android:name="com.here.android.maps.license.key" android:value="{J8XXfNbyt7M=}" />
-->
    </application>

</manifest>

any suggestions much appreciated

chehthan
  • 213
  • 2
  • 13

3 Answers3

5

I believe you're looking at the wrong documentation. On this page: https://developer.here.com/documentation there are two versions of the HERE Android Mobile SDK listed, SDK for Android Starter and SDK for Android Premium. You are looking at the documentation for Starter when I think you want Premium.

The Premium SDK has a native library component which needs to be included in the build. Try this page: https://developer.here.com/mobile-sdks/documentation/android-hybrid-plus/topics/app-simple-android-studio.html ("Add HERE SDK Libraries to Your Project" section)

Specifically, I believe these are the sections you missed:

  • From the directory where you installed the HERE SDK, copy the contents of the HERE-sdk/libs/armeabi-v7a folder to your project's app/src/main/jniLibs/armeabi folder. You need to create the jniLibs and armeabi subfolders.

  • Within the same section in your AndroidManifest.xml file, add the following lines:

    <service android:name="com.here.android.mpa.service.MapService" android:label="HereMapService" android:process="global.Here.Map.Service.v2" android:exported="true" > <intent-filter> <action android:name="com.here.android.mpa.service.MapService" > </action> </intent-filter> </service>

UPDATE

As of HERE SDK version 3.3 the SDK is delivered as an Android Archive (AAR) file. Therefore, you no longer need to manually copy the native libraries as mentioned in the first bullet above. You can simply include the AAR file in your build.gradle file. e.g.:

// Assuming you have placed the HERE-sdk.aar in a folder 'libs'
repositories {
    flatDir {
        dirs 'libs'
    }
}

dependencies {
   ...
   compile(name: 'HERE-sdk', ext: 'aar')
   ...
}
AndrewJC
  • 1,318
  • 12
  • 11
  • steps From above completed, but I am getting MISSING_PERMISSION – chehthan Feb 06 '16 at 10:52
  • System.out: ERROR: Cannot initialize Map Fragment UNKNOWN – chehthan Feb 06 '16 at 19:23
  • System.out: ERROR: Cannot initialize Map Fragment MISSING_PERMISSION – chehthan Feb 06 '16 at 19:24
  • Specific Error msg not conveyed in here map – chehthan Feb 06 '16 at 19:25
  • 1
    You need to have a proper `AppId, AppCode and LicenseKey` to use the SDK. see this page: https://developer.here.com/mobile-sdks/documentation/android-hybrid-plus/topics/credentials.html . From your AndroidManifest I see that license key field is commented out. – AndrewJC Feb 06 '16 at 20:15
  • I have set the correct AppId, Appcode and LicenseKey. Still when I run the app. It tells Cannot initialize Map Fragment MISSING_PERMISSION I AM CLUE LESS – chehthan Feb 07 '16 at 11:49
  • 02-07 17:27:28.923 7356-7356/? I/art: Late-enabling -Xcheck:jni 02-07 17:27:30.305 7356-7424/com.chethan.mobileapp.heremap D/OpenGLRenderer: Render dirty regions requested: true 02-07 17:27:30.319 7356-7356/com.chethan.mobileapp.heremap D/Atlas: Validating map... 02-07 17:27:30.328 7356-7356/com.chethan.mobileapp.heremap I/System.out: ERROR: Cannot initialize Map Fragment – chehthan Feb 07 '16 at 11:59
  • 02-07 17:27:30.442 7356-7424/com.chethan.mobileapp.heremap I/Adreno-EGL: : EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1_RB1.05.00.00.002.030_msm8226_LA.BF.1.1_RB1__release_AU () OpenGL ES Shader Compiler Version: E031.25.03.00 Build Date: 12/04/14 Thu Local Branch: Remote Branch: quic/LA.BF.1.1_rb1.14 Local Patches: NONE Reconstruct Branch: AU_LINUX_ANDROID_LA.BF.1.1_RB1.05.00.00.002.030 + NOTHING – chehthan Feb 07 '16 at 12:01
  • 02-07 17:27:30.973 7356-7424/com.chethan.mobileapp.heremap V/RenderScript: Application requested CPU execution 02-07 17:27:31.029 7356-7424/com.chethan.mobileapp.heremap V/RenderScript: 0xb73259c8 Launching thread(s), CPUs 4 02-07 17:30:37.497 7356-7367/com.chethan.mobileapp.heremap I/art: Debugger is no longer active – chehthan Feb 07 '16 at 12:02
  • I am getting above output statements. – chehthan Feb 07 '16 at 12:02
  • Work Environment 1) Android Studio 1.5.1 2) API level 22 and build 22.0.1 – chehthan Feb 07 '16 at 12:07
  • Same here with same environment on OS X (HERE_Android_SDK_Premium_v3.1.0_451). I tried the same tutorial with the Starter SDK (HERE_Android_SDK_Starter_v3.1.0_791) and it worked just fine. With Premium I still get MISSING_LIBRARIES error. I did all steps and checked twice. – Ingo Feb 14 '16 at 12:23
  • Just wondering if anyone made any progress or has new insights on this. I'm getting same as @chehthan - Error.Unknown when using the Starter SDK library. – Clint StLaurent May 01 '17 at 14:15
0

Be sure your device meets the system requirements listed here. Specifically, be sure your device is ARM and not x86.

I've encountered the 'MISSING_LIBRARIES' error when running HERE maps on the HP Pro Slate 10 EE G1. This tablet is x86 which is not supported by the current HERE SDK. ARM native code runs on Intel x86 using an emulator named Houdini. Explanation on that can be found here.

Unfortunately I know this doesn't fix your issue. Yet it may help you understand why the app will not initialize the map.

Blake
  • 43
  • 6
0

This can happen also If you have another lib with JNI in project. In that case include following code under buildType in build.gradle:

        splits {
            abi {
                enable true
                reset()
                include 'armeabi-v7a'
                universalApk false
            }
        }
EliGreenfeld
  • 21
  • 1
  • 2