Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

荣耀x10可以定位,我用黑鲨1却一直报错10808: AGC_CHECK_FAIL #4

Open
zjianflys opened this issue May 20, 2022 · 9 comments

Comments

@zjianflys
Copy link

我查文档错误描素是这样的:

AGC_CHECK_FAIL | 10808 | AGC身份验证失败。 | 请检查是否已配置AppGallery Connect。

我也按步骤做了 还是不行...不晓得还有哪点问题,主要是荣耀x10和V30Pro都行

@Xuejiao-Shi
Copy link
Contributor

您好,
1 请检查一下签名 SHA256是否按照官网正确配置。
image

2 非华为手机只支持 LocationUpdates with callback方式请求定位。

@zjianflys
Copy link
Author

2 非华为手机只支持 LocationUpdates with callback方式请求定位。 这句话很关键 我用的intent 找了好久问题 确实没找到 我在试一下....

@zjianflys
Copy link
Author

我试了一下 还是不得行
HMSSDK_ServiceErrorCodeAdaptor: set task by error code:10808,reason:AGC_CHECK_FAIL

@Xuejiao-Shi
Copy link
Contributor

您好,麻烦您用adb logcat截取一份完整的日志我们看下。

@zjianflys
Copy link
Author

I/HMSSDK_HwLocation_LocationClientImpl: |d3236a6e-05dd-4174-aa41-00f29edae95f|checkLocationSettings I/HMSSDK_LiteSDKProxy: isHmsWithSysSignature:false I/HMSSDK_LiteSDKProxy: isHMSEnable:false I/HMSSDK_LiteSDKApiProxyHandler: not find HMS Core ,try use lite I/HMSSDK_LiteSDKApiProxyHandler: handlerLiteTask success I/APKUtil: [2022-05-20 18:15:17.408 I/LITE_SDK-APKUtil] getPackageInfo From PackageManager E/APKUtil: [2022-05-20 18:15:17.411 E/LITE_SDK-APKUtil] NameNotFoundException! I/ROMUtil: [2022-05-20 18:15:17.412 I/LITE_SDK-ROMUtil] is huawei device:false I/OnlineAgcService: [2022-05-20 18:15:17.413 I/LITE_SDK-OnlineAgcService] getOnlineAgcInfo I/APKUtil: [2022-05-20 18:15:17.414 I/LITE_SDK-APKUtil] getPackageInfo From PackageManager I/NetworkKit_e: Location_Location_DispatchTaskManager_1|null|com.huawei.hms.framework.network.grs.h.e|a|30|isSpExpire false. I/NetworkKit_LocalManagerProxy: Location_Location_DispatchTaskManager_1|null|com.huawei.hms.framework.network.grs.f.b|a|14|appGrs is not null and clear services. I/NetworkKit_a: Location_Location_DispatchTaskManager_1|null|com.huawei.hms.framework.network.grs.a|a|41|get unexpired cache localUrl: h*t*s*/*o*e*l*c*t*o*-*r*n*p*a*f*r*.*b*n*c*o*d*c*m I/NetworkKit_LocalManagerProxy: Location_Location_DispatchTaskManager_1|null|com.huawei.hms.framework.network.grs.f.b|a|14|appGrs is not null and clear services. I/LocationUtil: [2022-05-20 18:15:17.441 I/LITE_SDK-LocationUtil] registerScreenStatusBroadcast start I/LocationUtil: [2022-05-20 18:15:17.442 I/LITE_SDK-LocationUtil] registerScreenStatusBroadcast is Register I/APKUtil: [2022-05-20 18:15:17.457 I/LITE_SDK-APKUtil] getPackageInfo From PackageManager E/APKUtil: [2022-05-20 18:15:17.458 E/LITE_SDK-APKUtil] NameNotFoundException! I/ROMUtil: [2022-05-20 18:15:17.458 I/LITE_SDK-ROMUtil] is huawei device:false I/RealSubmit: [2022-05-20 18:15:17.459 I/LITE_SDK-RealSubmit] executeCall() I/DeviceInfoUtil: [2022-05-20 18:15:17.461 I/LITE_SDK-DeviceInfoUtil] 1. detectHuaweiFeature: -1 I/DeviceInfoUtil: [2022-05-20 18:15:17.462 I/LITE_SDK-DeviceInfoUtil] 2. detectAndroidFeature: -1 I/DeviceInfoUtil: [2022-05-20 18:15:17.462 I/LITE_SDK-DeviceInfoUtil] System property not found. I/DeviceInfoUtil: [2022-05-20 18:15:17.463 I/LITE_SDK-DeviceInfoUtil] 3. detectSystemProperty: -1 I/DeviceInfoUtil: [2022-05-20 18:15:17.463 I/LITE_SDK-DeviceInfoUtil] Final DeviceType: -1 I/CommonRequestParamInterceptor: [2022-05-20 18:15:17.463 I/LITE_SDK-CommonRequestParamInterceptor] clientLiteSDKVersion:20400300 I/UCSSignHelper: [2022-05-20 18:15:17.465 I/LITE_SDK-UCSSignHelper] sign successful I/SecurityComp10105310: SecureSSLSocketFactory: createSocket s host port autoClose I/SecurityComp10105310: SecureSSLSocketFactory: set default protocols I/SecurityComp10105310: SecureSSLSocketFactory: set default cipher suites I/LocationTracker: [2022-05-20 18:15:17.705 I/LITE_SDK-LocationTracker] onMaintEvent:{brand=blackshark, pub_mfc=blackshark, callTime=1653041717459, service=hwLocation, networkType=wifi, MCC=unknow, lcSdkType=4, lbs_version=-1, rom_type=2001, package=com.jszy.vi, version=20400300, apiName=Location_serverApi, transId=bbc09e1d-81a0-4998-b98a-f4f0ca79c7ee, requestUrl=/location/v1/getToken, errorCode=200042, errorMessage=Failed to get fingerprint from scopeserver., costTime=246} I/FormalHASDK: hmsSdk=> onEvent. TAG: _hms_config_tag, TYPE: 1, eventId : Location_serverApi I/FormalHASDK: hmsSdk=> onEvent. TAG: _hms_config_tag, TYPE: 0, eventId : Location_serverApi E/OnlineAgcService: [2022-05-20 18:15:17.709 E/LITE_SDK-OnlineAgcService] doHttp, OnErrorException: code is 200042, msg is Failed to get fingerprint from scopeserver. E/ErrorRequestApi: [2022-05-20 18:15:17.710 E/LITE_SDK-ErrorRequestApi] handlerNoApiTask I/HMSSDK_HMSPackageManager: Enter getHMSPackageNameForMultiService E/HMSSDK_AGCUtils: In getMetaDataAppId, Failed to read meta data for the AppID. E/HMSSDK_AGCUtils: Get client/app_id failed: java.io.FileNotFoundException: agconnect-services.json E/HMSSDK_AGCUtils: The client/app_id is null. I/HMSSDK_HMSPackageManager: Enter getHMSPackageNameForMultiService I/HMSSDK_AGCUtils: In getMetaDataCpId, Failed to read meta data for the CpId. E/HMSSDK_AGCUtils: Get client/cp_id failed: java.io.FileNotFoundException: agconnect-services.json E/HMSSDK_AGCUtils: The client/cp_id is null. I/HMSSDK_HMSPackageManager: Enter getHMSPackageName I/HMSSDK_LiteApiListener: inner hms is empty,hms pkg name is com.huawei.hwid I/HMSSDK_TaskApiCall: doExecute, uri:location.checkLocationSettings, errorCode:10808, transactionId:null I/HMSSDK_HwLocation_CheckLocationSettingsTaskApiCall: |d3236a6e-05dd-4174-aa41-00f29edae95f|doExecute I/HMSSDK_ServiceErrorCodeAdaptor: set task by error code:10808,reason:AGC_CHECK_FAIL E/LocationHmsHelper: ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────── │ main, com.jszy.hmslocation.LocationHmsHelper.lambda$requestLocationUpdatesWithCallback$7(LocationHmsHelper.java:257) ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ │ 检查位置设置异常:10808: AGC_CHECK_FAIL └────────────────────────────────────────────────────────────────────────────────────────────────────────────────

@zjianflys
Copy link
Author

不知道怎么传图片..

@zjianflys
Copy link
Author

`package com.jszy.hmslocation;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.os.Build;
import android.os.Looper;
import android.util.Log;

import com.blankj.utilcode.constant.TimeConstants;
import com.blankj.utilcode.util.LogUtils;
import com.huawei.hmf.tasks.OnFailureListener;
import com.huawei.hmf.tasks.OnSuccessListener;
import com.huawei.hmf.tasks.Task;
import com.huawei.hms.location.FusedLocationProviderClient;
import com.huawei.hms.location.LocationAvailability;
import com.huawei.hms.location.LocationCallback;
import com.huawei.hms.location.LocationRequest;
import com.huawei.hms.location.LocationResult;
import com.huawei.hms.location.LocationServices;
import com.huawei.hms.location.LocationSettingsRequest;
import com.huawei.hms.location.LocationSettingsResponse;
import com.huawei.hms.location.SettingsClient;
import com.xz.comm.utils.StringExtUtils;

import java.util.List;

/**

  • 华为定位
    */
    public class LocationHmsHelper {
    private static LocationHmsHelper INSTANCE;
    private static Activity mActivity;
    // 融合定位,程序定位交互接入类
    private static FusedLocationProviderClient mFusedLocationProviderClient;
    private static SettingsClient mSettingsClient;
    private static LocationRequest mLocationRequest;

    private static LocationCallback mLocationCallback;

    private LocationHmsHelper(Activity activity) {
    this.mActivity = activity;
    // 实例化fusedLocationProviderClient对象
    mFusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(activity);
    mSettingsClient = LocationServices.getSettingsClient(activity);
    mLocationRequest = new LocationRequest();
    // 设置位置回调的时间间隔为6000ms,默认是5000ms。
    mLocationRequest.setInterval(TimeConstants.SEC * 10);
    // 设置定位类型,PRIORITY_HIGH_ACCURACY为融合定位模式。
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

// enableBackgroundLocationHms();
}

public synchronized static LocationHmsHelper getInsatance(Activity activity) {
    if (INSTANCE == null) {
        try {
            Thread.sleep(1);
        } catch (Exception e) {
            e.printStackTrace();
        }
        INSTANCE = new LocationHmsHelper(activity);
    }
    return INSTANCE;
}


/**
 * 调用enableBackgroundLocation()方法,传入服务通知开启后台定位能力
 */
private void enableBackgroundLocationHms() {
    Notification.Builder builder;
    Notification mNotification;
    int notificationId = 1;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationManager notificationManager =
                (NotificationManager) mActivity.getSystemService(Context.NOTIFICATION_SERVICE);
        String channelId = mActivity.getPackageName();
        NotificationChannel notificationChannel =
                new NotificationChannel(channelId, "LOCATION", NotificationManager.IMPORTANCE_LOW);
        notificationManager.createNotificationChannel(notificationChannel);
        builder = new Notification.Builder(mActivity, channelId);
    } else {
        builder = new Notification.Builder(mActivity);
    }
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        mNotification = builder.build();
    } else {
        mNotification = builder.getNotification();
    }
    mFusedLocationProviderClient.enableBackgroundLocation(notificationId, mNotification);
}

// public void startLocation() {
// mLocationCallback = new LocationCallback() {
// @OverRide
// public void onLocationResult(LocationResult locationResult) {
// if (locationResult != null) {
// // TODO: 处理位置回调结果
// LogUtils.i("locationResult:" + locationResult.getLocations());
// }
// }
// };
// fusedLocationProviderClient.requestLocationUpdates(mLocationRequest, mLocationCallback, Looper.getMainLooper())
// .addOnSuccessListener(new OnSuccessListener() {
// @OverRide
// public void onSuccess(Void aVoid) {
// // TODO: 接口调用成功的处理
// LogUtils.i("-----------接口调用成功的处理----------");
// }
// })
// .addOnFailureListener(new OnFailureListener() {
// @OverRide
// public void onFailure(Exception e) {
// // TODO: 接口调用失败的处理
// LogUtils.i("-----------接口调用失败的处理----------" + e.getMessage());
// }
// });
// }

// public void stopLocation() {
// fusedLocationProviderClient.disableBackgroundLocation();
// // 注意:停止位置更新时,mLocationCallback必须与requestLocationUpdates方法中的LocationCallback参数为同一对象。
// fusedLocationProviderClient.removeLocationUpdates(mLocationCallback)
// // 停止位置更新成功监听回调
// .addOnSuccessListener(new OnSuccessListener() {
// @OverRide
// public void onSuccess(Void aVoid) {
// // TODO: 停止位置更新成功的处理
// }
// })
// // 停止位置更新失败监听回调
// .addOnFailureListener(new OnFailureListener() {
// @OverRide
// public void onFailure(Exception e) {
// // TODO:停止位置更新失败的处理
// }
// });
// }

// /**
// * 获取最后的已知位置
// */
// public void getLastLocation() {
// // 获取最后的已知位置
// Task task = fusedLocationProviderClient.getLastLocation()
// // 获取最后的已知位置成功监听回调
// .addOnSuccessListener(new OnSuccessListener() {
// @OverRide
// public void onSuccess(Location location) {
// if (location == null) {
// return;
// }
// // TODO:成功时Location对象处理逻辑
// LogUtils.i("-----获取最后的已知位置 成功----" + location.toString());
// }
// })
// // 获取最后的已知位置失败监听回调
// .addOnFailureListener(new OnFailureListener() {
// @OverRide
// public void onFailure(Exception e) {
// // TODO:接口调用失败处理
// LogUtils.i("-----获取最后的已知位置 接口调用失败处理----" + e.getMessage());
// }
// });
// }

/**
 * 请求更新位置
 */
public void requestLocationUpdatesWithIntent() {
    try {
        //指定位置服务类型,检查位置设置以获取所有位置请求服务的最佳功能
        LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
        builder.addLocationRequest(mLocationRequest);//添加客户端需要的LocationRequest对象
        LocationSettingsRequest locationSettingsRequest = builder.build();
        // Before requesting location update, invoke checkLocationSettings to check device settings.
        Task<LocationSettingsResponse> locationSettingsResponseTask =
                mSettingsClient.checkLocationSettings(locationSettingsRequest);
        locationSettingsResponseTask
                .addOnSuccessListener(locationSettingsResponse -> {
                    LogUtils.i("检查位置设置成功");
                    //请求方使用PendingIntent的方式,持续请求位置更新
                    mFusedLocationProviderClient
                            .requestLocationUpdates(mLocationRequest, getPendingIntent())
                            .addOnSuccessListener(aVoid -> LogUtils.i("requestLocationUpdatesWithIntent onSuccess"))
                            .addOnFailureListener(e -> LogUtils.i("requestLocationUpdatesWithIntent onFailure:" + e.getMessage()));
                })
                .addOnFailureListener(e -> LogUtils.i("检查位置设置异常:" + e.getMessage()));
    } catch (Exception e) {
        LogUtils.i("requestLocationUpdatesWithIntent exception:" + e.getMessage());
    }
}

/**
 * Requests a location update and calls back on the specified Looper thread.
 */
public void requestLocationUpdatesWithCallback() {
    try {
        if (null == mLocationCallback) {
            mLocationCallback = new LocationCallback() {
                @Override
                public void onLocationResult(LocationResult locationResult) {
                    if (locationResult != null) {
                        List<Location> locations = locationResult.getLocations();
                        if (!locations.isEmpty()) {
                            StringBuilder locationBuilder = new StringBuilder("经度/纬度/准确度:");
                            for (Location location : locations) {
                                locationBuilder.append(location.getLongitude())
                                        .append(",")
                                        .append(location.getLatitude())
                                        .append(",")
                                        .append(location.getAccuracy());
                            }
                            if (StringExtUtils.isNotEmpty(locationBuilder.toString())) {
                                LogUtils.i(locationBuilder);
                            }
                        }
                    }
                }

                @Override
                public void onLocationAvailability(LocationAvailability locationAvailability) {
                    if (locationAvailability != null) {
                        boolean flag = locationAvailability.isLocationAvailable();
                        LogUtils.i("onLocationAvailability isLocationAvailable:" + flag);
                    }
                }
            };
        }

        //指定位置服务类型,检查位置设置以获取所有位置请求服务的最佳功能
        LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
        builder.addLocationRequest(mLocationRequest);
        LocationSettingsRequest locationSettingsRequest = builder.build();
        // Before requesting location update, invoke checkLocationSettings to check device settings.
        Task<LocationSettingsResponse> locationSettingsResponseTask =
                mSettingsClient.checkLocationSettings(locationSettingsRequest);
        locationSettingsResponseTask
                .addOnSuccessListener(locationSettingsResponse -> {
                    mFusedLocationProviderClient
                            .requestLocationUpdates(mLocationRequest, mLocationCallback, Looper.getMainLooper())
                            .addOnSuccessListener(aVoid -> {
                                LogUtils.i("requestLocationUpdatesWithCallback onSuccess");
                            })
                            .addOnFailureListener(e -> {
                                LogUtils.e("requestLocationUpdatesWithCallback onFailure:" + e.getMessage());
                            });
                })
                .addOnFailureListener(e -> LogUtils.e("检查位置设置异常:" + e.getMessage()));
    } catch (Exception e) {
        LogUtils.e("requestLocationUpdatesWithCallback exception:" + e.getMessage());
    }
}

/**
 * 删除位置更新
 */
public void removeLocationUpdatesWithIntent() {
    try {
        Task<Void> voidTask = mFusedLocationProviderClient.removeLocationUpdates(getPendingIntent());
        voidTask
                .addOnSuccessListener(aVoid -> LogUtils.i("removeLocationUpdatesWithIntent onSuccess"))
                .addOnFailureListener(e -> LogUtils.e("removeLocationUpdatesWithIntent onFailure:" + e.getMessage()));
    } catch (Exception e) {
        LogUtils.e("removeLocationUpdatesWithIntent exception:" + e.getMessage());
    }
}


/**
 * 删除位置更新
 */
public void removeLocationUpdatesWithCallback() {
    try {
        Task<Void> voidTask = mFusedLocationProviderClient.removeLocationUpdates(mLocationCallback);
        voidTask
                .addOnSuccessListener(aVoid -> LogUtils.i("removeLocationUpdatesWithCallback onSuccess"))
                .addOnFailureListener(e -> LogUtils.i("removeLocationUpdatesWithCallback onFailure:" + e.getMessage()));
    } catch (Exception e) {
        LogUtils.i("removeLocationUpdatesWithCallback exception:" + e.getMessage());
    }
}


@SuppressLint("WrongConstant")
private PendingIntent getPendingIntent() {
    Intent intent = new Intent(mActivity, LocationBroadcastReceiver.class);
    intent.setAction(LocationBroadcastReceiver.ACTION_PROCESS_LOCATION);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
        return PendingIntent.getBroadcast(mActivity, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    } else {
        // For Android 12 or later devices, proactively configure the pendingIntent variability.
        // The default value is PendingIntent.FLAG_MUTABLE. If compileSDKVersion is 30 or less, set this parameter
        // to 1<<25.
        return PendingIntent.getBroadcast(mActivity, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | (1 << 25));
    }
}

}
`

我用单例封装了一下

@OverRide
public void setListener() {
//Intent
bindingView.mbStartIntent.setOnClickListener(view -> {
LocationHmsHelper.getInsatance(this).requestLocationUpdatesWithIntent();
});
bindingView.mbStopIntent.setOnClickListener(view -> {
LocationHmsHelper.getInsatance(this).removeLocationUpdatesWithIntent();
});
//callback
bindingView.mbStartCallback.setOnClickListener(view -> {
LocationHmsHelper.getInsatance(this).requestLocationUpdatesWithCallback();
});
bindingView.mbStopCallback.setOnClickListener(view -> {
LocationHmsHelper.getInsatance(this).removeLocationUpdatesWithCallback();
});
}

这是我的源码 我感觉单例应该也没什么毛病呀

@Xuejiao-Shi
Copy link
Contributor

您好,如截图所示,项目没有发现这个json文件。

请问您有没有按照官网流程接入?如图

@xorzdev
Copy link

xorzdev commented Mar 28, 2023

我也出现了这个问题:

  • 华为&荣耀 设备上正常
  • 在其他设备上 checkLocationSettingsAGC_CHECK_FAIL,但 requestLocationUpdates 可以正常定位
  • Redmi K40S | MIUI 14.0.5 | Android 13checkLocationSettings 报错 AGC_CHECK_FAIL,且 requestLocationUpdates 无数据返回

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants