HarmonyOS 鸿蒙Next call.makeCall 打电话在build mode选择release时异常闪退,选择debug时正常

HarmonyOS 鸿蒙Next call.makeCall 打电话在build mode选择release时异常闪退,选择debug时正常

1、build mode 选择release,调打电话的接口,闪退,选择debug则没问题

call.makeCall(phone).then(() => {
BoBLog.info(this.TAG,“拨打电话”+phone)
}).catch((error: string) => {
BoBLog.info(this.TAG, error)
}); 


更多关于HarmonyOS 鸿蒙Next call.makeCall 打电话在build mode选择release时异常闪退,选择debug时正常的实战教程也可以访问 https://www.itying.com/category-93-b0.html

2 回复

这边用相同版本的真机并选择release进行测试未复现闪退情况,示例代码:


import call from '[@ohos](/user/ohos).telephony.call';

[@Entry](/user/Entry)({ routeName: 'Index' })

[@Component](/user/Component)

struct Index {

  [@State](/user/State) message: string = 'Hello World';

  build() {

    Column(){

      Button('拨打电话').onClick(()=>{

        call.makeCall('11111111').then(() => {

          console.info("拨打电话"+'11111111')

        }).catch((error: string) => {

          console.info( error)

        });

      })

    }

  }

}

您这边可以定位一下是那边的代码导致的,我根据您的代码做了点修改,也未复现闪退


import call from '[@ohos](/user/ohos).telephony.call';

export class CallPhone {

  TAG: string = '123';

  apiName(): string {

    return "callPhone";

  }

  handle(str: string): void {

    console.debug("callPhone", str)

    let isSupport = call.hasVoiceCapability();

    if (isSupport) {

      // const paramJSON: ESObject = JSON.parse(str)

      let phone: string = str;

      if(!phone){

        // this.callbackH5Data('1', '号码不能为空', '',jsCallParam)

      }

      call.makeCall(phone).then(() => {

        console.info(this.TAG,"拨打电话"+phone)

      }).catch((error: string) => {

        console.info(this.TAG, error)

      });

    }else{

      console.info(this.TAG, '设备不支持呼叫能力')

      // this.callbackH5Data('1', '设备不支持呼叫能力', '',jsCallParam)

    }

  }

}

[@Entry](/user/Entry)({ routeName: 'Index' })

[@Component](/user/Component)

struct Index {

  [@State](/user/State) message: string = 'Hello World';

  build() {

    Column(){

      Button('拨打电话').onClick(()=>{

        let c = new CallPhone();

        c.handle('123456');

      })

    }

  }

}

更多关于HarmonyOS 鸿蒙Next call.makeCall 打电话在build mode选择release时异常闪退,选择debug时正常的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


在HarmonyOS中,遇到Next call.makeCall在release模式下异常闪退而debug模式下正常的问题,通常与代码优化、资源管理或权限配置有关。

  1. 代码优化差异:Release模式会对代码进行更深入的优化,可能导致某些在debug模式下未触发的路径被执行。检查makeCall相关代码,确保所有变量都已正确初始化,无野指针访问。

  2. 资源管理:Release模式下,系统可能更严格地管理内存和资源,如电话权限、进程生命周期等。确认应用已正确申请并持有打电话所需的权限,同时检查是否有资源(如文件、网络连接)在release模式下未正确释放。

  3. 日志与调试:由于release模式不易直接调试,可尝试增加日志输出,尤其是makeCall前后的关键步骤,通过日志分析异常发生的可能位置。使用HarmonyOS提供的性能分析工具检查应用行为。

  4. 签名与配置:确认release版本的签名配置正确无误,且应用的manifest文件中关于电话功能的配置与debug版本一致。

如果问题依旧没法解决请联系官网客服,官网地址是:https://www.itying.com/category-93-b0.html

回到顶部