HarmonyOS鸿蒙Next设备模拟器无法开启NFC! E/s.nfccontrolle: GcSupervisor: parse parameters failed

HarmonyOS鸿蒙Next设备模拟器无法开启NFC! E/s.nfccontrolle: GcSupervisor: parse parameters failed 手机设备模拟器上这个NFC启用不了。

尝试了用代码去启动也是不行:

package com.waylau.hmos.nfccontroller.slice;

import com.waylau.hmos.nfccontroller.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;
import ohos.nfc.NfcController;

public class MainAbilitySlice extends AbilitySlice {
    private static final String TAG = MainAbilitySlice.class.getSimpleName();
    private static final HiLogLabel LABEL_LOG =
        new HiLogLabel(HiLog.LOG_APP, 0x00001, TAG);

    private NfcController nfcController;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        // 查询本机是否支持NFC
        if (this.getContext() != null) {
            nfcController = NfcController.getInstance(this.getContext());
        } else {
            return;
        }

        boolean isAvailable = nfcController.isNfcAvailable();
        if (isAvailable) {
            // 调用查询NFC是否打开接口,返回值为NFC是否是打开的状态
            boolean isOpen = nfcController.isNfcOpen();
            HiLog.info(LABEL_LOG, "isOpen: %{public}s", isOpen);
        } else {
            HiLog.info(LABEL_LOG, "NFC is not available");
        }

        HiLog.info(LABEL_LOG, "openNfc");
        boolean isOpenNfc = nfcController.openNfc();
        HiLog.info(LABEL_LOG, "openNfc: %{public}s", isOpenNfc);
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}

应用执行日志如下:

02-13 09:09:08.091 6090-6090/? I 00001/MainAbilitySlice: NFC is not available
02-13 09:09:08.091 6090-6090/? I 00001/MainAbilitySlice: openNfc

设备运行日志:

02/13 09:08:59: Launching com.waylau.hmos.nfccontroller
$hdc shell am force-stop com.waylau.hmos.nfccontroller
$hdc shell bm uninstall com.waylau.hmos.nfccontroller
$hdc file send D:/workspaceGithub/harmonyos-tutorial/samples/NfcController/entry/build/outputs/hap/debug/entry-debug-unsigned.hap /sdcard/3206327f53ae4d0e9b16ad2a44ee3e91/entry-debug-unsigned.hap
$hdc shell bm install -p /sdcard/3206327f53ae4d0e9b16ad2a44ee3e91/
$hdc shell rm -rf /sdcard/3206327f53ae4d0e9b16ad2a44ee3e91
$hdc shell am start -n "com.waylau.hmos.nfccontroller/com.waylau.hmos.nfccontroller.MainAbilityShellActivity"
Client not ready yet..Waiting for process to come online
Connected to process 6090 on device huawei-ana_an00-127.0.0.1:18888
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/RenderThread: type=1400 audit(0.0:4161): avc: denied { connectto } for pid=6090 path="/dev/socket/property_service" scontext=u:r:untrusted_app:s0:c87,c256,c512,c768 tcontext=u:r:init:s0 tclass=unix_stream_socket permissive=1
D/libEGL: loaded /vendor/lib64/egl/libGLESv1_CM_emulation.so
I/RenderThread: type=1400 audit(0.0:4162): avc: denied { read } for pid=6090 name="libOpenglSystemCommon.so" dev="vdd1" ino=6927 scontext=u:r:untrusted_app:s0:c87,c256,c512,c768 tcontext=u:object_r:vendor_file:s0 tclass=file permissive=1
D/libEGL: loaded /vendor/lib64/egl/libGLESv2_emulation.so
W/s.nfccontrolle: Can't mmap dex file /data/app/com.waylau.hmos.nfccontroller-UiifhoI-4nL_pztf5WNtMA==/feature_entry-debug-unsigned.hap!classes.dex directly; please zipalign to 4 bytes. Falling back to extracting file.
I/RenderThread: type=1400 audit(0.0:4163): avc: denied { open } for pid=6090 path="/vendor/lib64/libOpenglSystemCommon.so" dev="vdd1" ino=6927 scontext=u:r:untrusted_app:s0:c87,c256,c512,c768 tcontext=u:object_r:vendor_file:s0 tclass=file permissive=1
D/AGP: VsyncSchedulerAndroid:jni is registered.
    Typeface:native typeface ptr 0x7aecdf34e0
    Typeface:native typeface ptr 0x7aecdf34e0
    Typeface:native typeface ptr 0x7aecdf3b20
    Typeface:native typeface ptr 0x7aecdf34e0
    Typeface:native typeface ptr 0x7aecdf3780
    Typeface:native typeface ptr 0x7aecdf3600
    Initialize system fonts.
E/libdnetwork: GetLocalBasicInfo: get local node basic info binder invoke failed
I/DecorView[]: old windowMode:0 new windoMode:1
I/OverScrollerOptimization: start init SmartSlideOverScroller and get the overscroller config
    get the overscroller config
W/WindowDecorActionBar: should not do the transition or the transition anim is null or it is running or the mContainer view is null or mContainer view hasn't been drawn to screen 
I/Icon_Cache: add:2130771968#com.waylau.hmos.nfccontroller
W/ZipFileCache: init icons failed when open zip file. mPath=,mZip=,isFileNotExist=false
W/ZipFileCache: init icons failed when open zip file. mPath=,mZip=,isFileNotExist=false
D/ActivityThread: add activity client record, r= ActivityRecord{5035637 token=android.os.BinderProxy@43fdf9b {com.waylau.hmos.nfccontroller/com.waylau.hmos.nfccontroller.MainAbilityShellActivity}} token= android.os.BinderProxy@43fdf9b
D/AGP: Initialize system language.
    BF:Client
D/AGP: BF:AGPWindow back to top(flag=1)
E/AGP: BF:AGPWindow OnTop fail
E/s.nfccontrolle: GcSupervisor: parse parameters failed
E/s.nfccontrolle: GcSupervisor: parse parameters failed
Application terminated.

参考文档:https://developer.harmonyos.com/cn/docs/documentation/doc-guides/connectivity-nfc-overview-0000000000030030

Deveco Studio版本

DevEco Studio 2.1 Beta 2
Build Version: 2.1.0.201, built on January 30, 2021
Runtime version: 1.8.0_252-release-1649-b2 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1981M
Cores: 8
Registry:
Non-Bundled Plugins:
5 回复

开发者您好,目前分析是您的权限申请导致接口直接返回了失败。目前TAG权限已不支持普通开发者应用。

从开发那边得到得消息是NfcController普通应用仅保留查询功能,就是确认一下你的NFC是没问题的,是可用的,然后进行后面的开发。

更多关于HarmonyOS鸿蒙Next设备模拟器无法开启NFC! E/s.nfccontrolle: GcSupervisor: parse parameters failed的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


太惭愧了

开发者你好,收到您的反馈,目前正值春节假期,您的问题相关人员会在节后,依次为您进行处理,请您耐心等待。谢谢您的谅解~

HarmonyOS鸿蒙Next设备模拟器中无法开启NFC,并出现错误日志"E/s.nfccontrolle: GcSupervisor: parse parameters failed",通常与模拟器的NFC模块配置或参数解析问题有关。该错误表明在初始化或解析NFC相关参数时发生了失败,可能是由于模拟器的NFC功能未正确配置或支持的参数格式不匹配。检查模拟器的配置文件,确保NFC模块的参数设置正确,并确认模拟器版本是否支持NFC功能。如果问题持续,可能需要更新模拟器版本或检查相关开发文档以获取更多信息。

该错误提示表明在启动HarmonyOS鸿蒙Next设备模拟器时,NFC控制器无法正确解析参数,导致NFC功能无法正常开启。可能的原因包括模拟器配置错误、NFC相关驱动或库文件缺失、或系统参数设置不当。建议检查模拟器的配置文件,确保NFC相关参数正确无误,并更新模拟器至最新版本。如果问题依旧,尝试重新安装模拟器或联系鸿蒙开发者支持团队获取进一步帮助。

回到顶部
AI 助手
你好,我是IT营的 AI 助手
您可以尝试点击下方的快捷入口开启体验!