1

I am working with HMS Maps, for this I follow their documentation.
For this query I tried this link. I added SHA-256 key and agconnect-services.json file too.
The Steps which I did are:

dependency in app gradle: implementation 'com.huawei.hms:maps:6.0.0.301'
in app gradle: apply plugin: 'com.huawei.agconnect'
My root gradle is:

buildscript {
    repositories {
        maven { url 'http://developer.huawei.com/repo/' }
        google()
        jcenter()
        mavenCentral()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'com.huawei.agconnect:agcp:1.2.1.301'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven {url 'http://developer.huawei.com/repo/'}
        google()
        jcenter()
        mavenCentral()
        maven {
            url 'https://jitpack.io'
        }

        maven {
            url "https://github.com/QuickBlox/quickblox-android-sdk-releases/raw/master/"
        }

    }
}

I added SHA-256 key at AppGallery connect.
Enabled MapApi from AppGallery connect.
Downloaded and added "agconnect-services.json" file in my project.

After resolving some thread related issues, I am able to produce logcat errors and it is saying that "Illegal FingerPrint".
I know, it is about some integration issues with the AppGallery but I am unable to get it that what I am missing, I am following all the steps.
**Logcat is:**
2021-08-31 10:35:22.520 30490-30773/com.moody.poster E/HmsMapKit_AuthenticateClient_1074: Exception occur
    com.huawei.hms.maps.foundation.client.d: *1*0*2*:*I*L*G*L*F*N*E*P*I*T
        at com.huawei.hms.maps.foundation.client.d$d.c(:89)
        at com.huawei.hms.maps.foundation.client.c.d(:22556)
        at com.huawei.hms.maps.foundation.client.c.c(:88)
        at com.huawei.hms.maps.maproute.client.auth.e.d(:76)
        at com.huawei.hms.maps.maproute.client.auth.e.a(Unknown Source:0)
        at com.huawei.hms.maps.maproute.client.auth.b.a(Unknown Source:4)
        at com.huawei.hms.maps.foundation.client.c$a.e(:492)
        at com.huawei.hms.maps.maproute.client.auth.e.c(:1074)
        at com.huawei.hms.maps.maproute.cache.c$b.e(:298)
        at com.huawei.hms.maps.maproute.cache.c$b.call(:291)
        at eU.a(:42)
        at em.d(:12025)
        at fc$b.run(:96)
        at eq$c.run(:571)
        at fj.run(:66)
        at fj.call(:57)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:929)
2021-08-31 10:35:22.528 30490-30773/com.moody.poster E/HmsMapKit_ErrorTraceLogPusher_509: cache error trace log : ErrorTraceLogDTO{ scenario = ACCESS_SERVICE_ERROR', message='010002 : ILLEGAL_FINGERPRINT'}
    com.huawei.hms.maps.foundation.client.d: *1*0*2*:*I*L*G*L*F*N*E*P*I*T
        at com.huawei.hms.maps.foundation.client.d$d.c(:89)
        at com.huawei.hms.maps.foundation.client.c.d(:22556)
        at com.huawei.hms.maps.foundation.client.c.c(:88)
        at com.huawei.hms.maps.maproute.client.auth.e.d(:76)
        at com.huawei.hms.maps.maproute.client.auth.e.a(Unknown Source:0)
        at com.huawei.hms.maps.maproute.client.auth.b.a(Unknown Source:4)
        at com.huawei.hms.maps.foundation.client.c$a.e(:492)
        at com.huawei.hms.maps.maproute.client.auth.e.c(:1074)
        at com.huawei.hms.maps.maproute.cache.c$b.e(:298)
        at com.huawei.hms.maps.maproute.cache.c$b.call(:291)
        at eU.a(:42)
        at em.d(:12025)
        at fc$b.run(:96)
        at eq$c.run(:571)
        at fj.run(:66)
        at fj.call(:57)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:929)
2021-08-31 10:35:22.536 30490-30773/com.moody.poster E/HmsMapKit_AuthenticateCache_333: other err occur,errorCode : .010002 : ILLEGAL_FINGERPRINT
2021-08-31 10:35:22.775 30490-30490/com.moody.poster E/HmsMapKit_AccessTraceLogPusher_16: analyticsInstance is null
2021-08-31 10:35:22.778 30490-30490/com.moody.poster E/HmsMapKit_UserEventLogPusher_16: analyticsInstance is null


Ryan M
  • 18,333
  • 31
  • 67
  • 74
Faizan Ahmad
  • 352
  • 4
  • 20
  • hi@Faizan, may i ask does your map show? And could you pls post the code of the map display class? – zhangxaochen Aug 30 '21 at 02:20
  • No, my map is not loading, after calling "getMapAsync(this)" function, I am unable to get "onMapReady(HuaweiMap huaweiMap)" callback function. – Faizan Ahmad Aug 30 '21 at 04:57
  • hi@Faizan, Could you pls provide the error log of the map kit for us to check this issue? – zhangxaochen Aug 31 '21 at 01:27
  • 1
    There were some thread issues, after resolving that I am able to produce logcat errors. My issue is about some integration with AppGallery (Illegal Fingerprint) I am updating my question, please review it. I will be very thankful to you. – Faizan Ahmad Aug 31 '21 at 05:31
  • since version 'com.huawei.hms:maps:6.5.0.301', 'MapsInitializer.initialize(this)' is needed before setting the api key to use Huaweii map kit. – Rao Arsalan Jul 18 '22 at 09:52

3 Answers3

1

I had a similar problem once when I was implementing HMS Map. In my case it was that I had the map on a fragment and was using the activity documentation. To fix it I had to use the SupportMapFragment and everything worked correctly after that.

Sergio Pardo
  • 774
  • 6
  • 17
1

Update

In your following log:

2021-08-31 10:35:22.528 30490-30773/com.moody.poster E/HmsMapKit_ErrorTraceLogPusher_509: cache error trace log : ErrorTraceLogDTO{ scenario = ACCESS_SERVICE_ERROR', message='010002 : ILLEGAL_FINGERPRINT'}

As Docs mentioned, The possible causes are as follows:

  • The app ID in your project is different from that in AppGallery Connect.

  • No signing certificate fingerprint is configured. You need to generate a signing certificate fingerprint and configure it in AppGallery Connect.

  • The AppGallery Connect configuration file of your app is not configured. You need to follow instructions in Adding the AppGallery Connect Configuration File of Your App to configure it.

  • The API key is not transcoded using encode.

Also you can follow this Docs: Generating a Signing Certificate Fingerprint, see if there's a problem.


The following Map kit codelab is for your reference. You could follow this to see if its works.

1.Declare relevant permissions in blocks at the same level as the application block in the AndroidManifest.xml file.

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

2.Add MapView to the layout file. The file path is \mapdemo\app\src\main\res\layout\activity_main.xml.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 
    
    <com.huawei.hms.maps.MapView  
       xmlns:map="http://schemas.android.com/apk/res-auto" 
        android:id="@+id/mapView" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        map:cameraTargetLat="51" 
        map:cameraTargetLng="10" 
        map:cameraZoom="8.5" 
        map:mapType="normal" 
        map:uiCompass="true" 
        map:uiZoomControls="true" /> 
</LinearLayout>

3.Add the configuration for calling MapView to the activity file. The file path is \mapdemo\app\src\main\java\com\wz\android\mapdemo\MainActivity.java.

package com.wz.android.mapdemo; 
 
import androidx.appcompat.app.AppCompatActivity; 
 
import android.os.Bundle; 
import android.util.Log; 
 
import com.huawei.hms.maps.HuaweiMap; 
import com.huawei.hms.maps.MapView; 
import com.huawei.hms.maps.OnMapReadyCallback; 
 
/** 
* Map activity entrance class. 
*/ 
public class MainActivity extends AppCompatActivity implements OnMapReadyCallback { 
 
    private static final String TAG = "MapViewDemoActivity"; 
    // Huawei map. 
    private HuaweiMap hMap; 
 
    private MapView mMapView; 
 
    private static final String MAPVIEW_BUNDLE_KEY = "MapViewBundleKey"; 
 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.activity_main); 
        // Obtain a MapView instance. 
        mMapView = findViewById(R.id.mapView); 
        Bundle mapViewBundle = null; 
        if (savedInstanceState != null) { 
            mapViewBundle = savedInstanceState.getBundle(MAPVIEW_BUNDLE_KEY); 
        } 
 
        // Please replace Your API key with the API key in  
        // agconnect-services.json. 
        MapsInitializer.setApiKey("Your API key"); 
        mMapView.onCreate(mapViewBundle); 
        // Obtain a map instance. 
        mMapView.getMapAsync(this); 
    } 
 
    @Override 
    public void onMapReady(HuaweiMap map) { 
        // Obtain a map instance from callback. 
        Log.d(TAG, "onMapReady: "); 
        hMap = map; 
    } 
}

4.Add the lifecycle methods of MapView. The file path is \mapdemo\app\src\main\java\com\wz\android\mapdemo\MainActivity.java.

@Override 
protected void onStart() { 
    super.onStart(); 
    mMapView.onStart(); 
} 
 
@Override 
protected void onStop() { 
    super.onStop(); 
    mMapView.onStop(); 
} 
 
@Override 
protected void onDestroy() { 
    super.onDestroy(); 
    mMapView.onDestroy(); 
} 
 
@Override 
protected void onPause() { 
    mMapView.onPause(); 
    super.onPause(); 
} 
 
@Override 
protected void onResume() { 
    super.onResume(); 
    mMapView.onResume(); 
}

5.Verify that required permissions have been assigned. The file path is \mapdemo\app\src\main\java\com\wz\android\mapdemo\MainActivity.java.

private static boolean hasPermissions(Context context, String... permissions) { 
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && permissions != null) { 
        for (String permission : permissions) { 
            if (ActivityCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) { 
                return false; 
            } 
        } 
    } 
    return true; 
}
zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
  • 1
    Thanks for your answer, I updated my question with logcat errors. Please have a look on it. It is about some integration. But I am not able to trace it. – Faizan Ahmad Aug 31 '21 at 05:40
  • hi@Faizan, i updated my answer above, pls refer that. – zhangxaochen Aug 31 '21 at 06:21
  • 1
    I am unable to get the issue. I was trying it in a fragment and it was giving me "ILLEGAL_FINGERPRINT" that means app's configuration with AppGallery was not correct. Now I am trying it in an Activity and it is working fine. If there is an "ILLEGAL_FINGERPRINT" issue then it should also effect on Activity. But now, with Activity, it is working fine, don't know what was the issue. By the way, Thanks for your support. – Faizan Ahmad Aug 31 '21 at 12:58
  • Glad to hear that the issue has been resolved.please feel free to contact me if you need any further help. – zhangxaochen Sep 01 '21 at 01:00
  • yup but I have a question, why it is not working on fragment, why it is saying "ILLEGAL_FINGERPRINT"? – Faizan Ahmad Sep 01 '21 at 05:11
  • That's weird. Maybe you can post the code of your fragment and let me check. – zhangxaochen Sep 01 '21 at 06:01
  • Can you please send me your email so that I can send you my code on that email. – Faizan Ahmad Sep 01 '21 at 10:20
  • sorry@Faizan,could you mind post it by clicking the [Ask Question](https://stackoverflow.com/questions/ask) button and tag with [huawei-mobile-services] for us to trace this issue? Include a link to this question if it helps provide context. – zhangxaochen Sep 02 '21 at 01:10
0

I am not sure that why it is happening, I talked to Huawei developers regarding this issue, I was doing this in a fragment but when I tried this in an activity, it works perfectly. Now I am doing it in a separate Activity. (I created that activity with the built in method of HMS toolkit.)

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Faizan Ahmad
  • 352
  • 4
  • 20