仓库大佬,能帮忙看一下吗,已经尝试了两周,仓库里ohos的工程还是跑不起来,尝试了下载仓库源码编译ohos工程,还有导入仓库提供的ohpm har包,安装到设备上,应用都是闪退报类似这样的jscrash问题the requested module 'pag' does not provide an export name 'JPAGView' ,能帮忙看一下吗,感谢
wybxyzds opened this issue · comments
问题:
尝试下载仓库源码编译ohos工程,还有导入仓库提供的ohpm libpag的har包方式,应用安装到设备上,应用闪退都是报类似这样的jscrash问题the requested module 'pag' does not provide an export name 'JPAGView' ,能帮忙看一下吗,感谢
Build info:OpenHarmony 5.0.2.123 Fingerprint:eb2a2b1bd811faef8deb4b4b1fef5bc4862ce19a8a9e7bc3411b04cf022c6e1e Module name:org.libpag.pagviewer Version:1.0.0 VersionCode:1000000 PreInstalled:No Foreground:Yes Pid:1700 Uid:20010043 Reason:SyntaxError Error name:SyntaxError Error message:the requested module 'pag' does not provide an export name 'JPAGView' which imported by 'org.libpag.pagviewer/entry@libpag/ets/PAGView' Stacktrace: at PAGViewController (libpag/src/main/ets/PAGView.ets:458:33) at anonymous (/devcloud/slavespace/usr1/081f8aba80800f0f0fcec015bd66c7e0/harmony_code/codearts_workspace/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:2249:1) at Index (entry/src/main/ets/pages/Index.ets:25:50) at anonymous (entry/src/main/ets/pages/Index.ets:232:26)
编译环境:
使用的比较新的鸿蒙开发IDE:DevEco Studio 5.0.2 Release 5.0.7.200 SDK 5.0.2(14)(IDE这里下的https://developer.huawei.com/consumer/cn/download/)
(1)下载仓库源码编译仓库里的ohos工程
下载仓库源码,分支切换到origin/release/4.4,安装依赖npm install -g depsync,然后depsync,编译成hap安装到设备上,打开应用jscrash
目前问题详见之前反馈的issue: #2687 第一条评论的最后,jscrash :
Error message:the requested module 'pag' does not provide an export name 'JPAGView' which imported by 'org.libpag.pagviewer/entry@libpag/ets/PAGView'
(2)使用ohpm install @tencent/libpag 导入新建的工程中,工程中也添加了pag资源文件https://github.com/Tencent/libpag/tree/main/ohos/entry/src/main/resources/rawfile 和仓库里实例代码https://github.com/Tencent/libpag/blob/main/ohos/entry/src/main/ets/pages/Index.ets 编译报错:
手动把代码中import * as pag from '@tencent/libpag';改成import pag, { PAGImageView, PAGView } from '@tencent/libpag'; 能编译出hap,但是安装到设备上,打开应用也是报类似的jscrash:
Build info:OpenHarmony 5.0.2.123 Fingerprint:c62752fab78cbb72d0b6fb636428b39a4ce6622f43768431a752229ce4be2da3 Module name:com.example.myapplication2 Version:1.0.0 VersionCode:1000000 PreInstalled:No Foreground:Yes Pid:10382 Uid:20010046 Reason:SyntaxError Error name:SyntaxError Error message:the requested module '@normalized:Y&&&libpag.so&' does not provide an export name 'JPAGView' which imported by '&@tencent/libpag/src/main/ets/PAGView&4.4.25' Stacktrace: at PAGViewController (oh_modules/.ohpm/@tencent+libpag@4.4.25/oh_modules/@tencent/libpag/src/main/ets/PAGView.js:189:1) at anonymous (/devcloud/slavespace/usr1/081f8aba80800f0f0fcec015bd66c7e0/harmony_code/codearts_workspace/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:2249:1) at Index (entry/src/main/ets/pages/Index.ets:27:50) at anonymous (entry/src/main/ets/pages/Index.ets:232:26)
希望仓库大佬帮忙看一下,感谢
ohpm导入libpag har方式复现demo:
MyApplication2.zip
1.源码方式已解决,设备问题
2.使用ohpm install @tencent/libpag 导入新建的工程jscrash问题原因找到了,改成这样可以解决
`import { PAGFile, PAGImageView, PAGImageViewController, PAGView, PAGViewController } from '@tencent/libpag';
@entry
@component
struct Index {
@State imageViewControllers: Array = new Array();
@State viewController: PAGViewController = new PAGViewController();
@State pageIndex: number = 0;
aboutToAppear(): void {
let manager = getContext(this).resourceManager;
let file = PAGFile.LoadFromAssets(manager, "PAG_LOGO.pag");
this.viewController.setComposition(file);
this.viewController.setRepeatCount(-1);
this.viewController.play();
for (let index = 0; index < 20; index++) {
let imageViewController = new PAGImageViewController();
let file = PAGFile.LoadFromAssets(manager, "list/" + index + ".pag");
imageViewController.setComposition(file);
imageViewController.setRepeatCount(-1);
this.imageViewControllers.push(imageViewController);
}
}
build() {
Column() {
Row() {
if (this.pageIndex == 1) {
Grid() {
ForEach(this.imageViewControllers, (item: PAGImageViewController) => {
GridItem() {
PAGImageView({
controller: item
})
.onClick(() => {
if (item.isPlaying()) {
item.pause();
} else {
item.play();
}
})
}.width("25%").height(100)
})
}.width("100%")
} else {
PAGView({
controller: this.viewController
}).onClick(() => {
if (this.viewController.isPlaying()) {
this.viewController.pause();
} else {
this.viewController.play();
}
})
}
}.height("70%")
Row() {
Button("PAGView").width("40%").margin(10)
.onClick(() => {
this.pageIndex = 0;
this.viewController.play();
this.imageViewControllers.forEach((item: PAGImageViewController) => {
item.pause();
})
})
Button("PAGImageView").width("40%")
.onClick(() => {
this.pageIndex = 1;
this.imageViewControllers.forEach((item: PAGImageViewController) => {
item.play();
})
this.viewController.pause();
})
}
}
}
}`