HarmonyOS 鸿蒙Next 更改button的background_element时报错
HarmonyOS 鸿蒙Next 更改button的background_element时报错
btn.setBackground(new StateElement(this,ResourceTable.Graphic_state_button))
报错:java.lang.NoSuchMethodError: No direct method <init>(Lohos/app/Context;I)V in class Lohos/agp/components/element/StateElement; or its super classes (declaration of ‘ohos.agp.components.element.StateElement’ appears in /system/framework/zframework.z.jar)
使用远程模拟器运行正常,previewer中点击也正常,但是本地模拟器和真机运行就报错
更多关于HarmonyOS 鸿蒙Next 更改button的background_element时报错的实战教程也可以访问 https://www.itying.com/category-93-b0.html
楼主你好,能否使用最新ide和sdk版本,能否说明手机版本。
更多关于HarmonyOS 鸿蒙Next 更改button的background_element时报错的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
IDE是3.0.0.800,sdk是7,手机版本是2.0.0.220(C00E205R1P4) 本地模拟器也会报错,你可以试试能不能复现,只有在previewer里点击和state切换都正常显示。
找HarmonyOS工作还需要会Flutter的哦,有需要Flutter教程的可以学学大地老师的教程,很不错,B站免费学的哦:BV1S4411E7LY/?p=17
解决了,因为StateElement(Context context, int xmlId)
这个构造器只在SDK7开始才有,而测试设备api版本是6,远程真机版本是5,所以都不支持。
欢迎开发小伙伴们进来帮帮楼主