uni-app 腾讯云实时音视频SDK 打包报错
uni-app 腾讯云实时音视频SDK 打包报错
Appid: UNIE88CD1D
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: unexpected element (uri:"", local:“extension-level”). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
Warning: unexpected element (uri:"", local:“base-extension”). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-
What went wrong: Execution failed for task ‘:app:mergeReleaseNativeLibs’.
-
A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
2 files found with path ‘lib/x86/libliteavsdk.so’ from inputs: -
/srv/.gradle/caches/transforms-3/3afe28269f34eb153e7df21052e81b92/transformed/jetified-weex_livepusher-release/jni
-
/srv/.gradle/caches/transforms-3/98a1dc8b88928a44489f037fc66b41ef/transformed/jetified-LiteAVSDK_TRTC-11.4.0.13189/jni
If you are using jniLibs and CMake IMPORTED targets, see
https://developer.android.com/r/tools/jniLibs-vs-imported-targets
Try:
- Run with --debug option to get more log output.
- Run with --scan to get full insights.
Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:app:mergeReleaseNativeLibs’.
2: Task failed with an exception.
-
What went wrong: Execution failed for task ‘:app:checkReleaseDuplicateClasses’.
-
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
Duplicate class com.tencent.liteav.TXLiteAVCode found in modules jetified-LiteAVSDK_TRTC-11.4.0.13189-runtime (com.tencent.liteav:LiteAVSDK_TRTC:11.4.0.13189) and jetified-weex_livepusher-release-runtime (weex_livepusher-release.aar)
Go to the documentation to learn how to Fix dependency resolution errors.
Try:
- Run with --debug option to get more log output.
- Run with --scan to get full insights.
Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:app:checkReleaseDuplicateClasses’.
这是原生“腾讯云实时音视频”与“LivePusher(直播推流)”模块冲突的问题,两者只能二选一。
去掉项目使用的原生插件“腾讯云实时音视频”,或者在manifest.json中 App模块配置 中去掉勾选“LivePusher(直播推流)”
在处理uni-app结合腾讯云实时音视频SDK打包报错的问题时,通常涉及到几个关键步骤,包括SDK的集成、配置文件的调整以及依赖项的正确引用。以下是一个简化的代码和配置示例,用于指导你如何解决打包报错的问题。请注意,这只是一个基本框架,具体实现可能需要根据你的项目结构和错误信息进行调整。
1. 集成腾讯云实时音视频SDK
首先,确保你已经正确集成了腾讯云实时音视频SDK。通常,你需要将SDK的JavaScript文件或npm包添加到你的uni-app项目中。
# 如果使用npm安装
npm install @tencent/trtc-js-sdk --save
在你的页面或组件中引入SDK:
import TRTC from '@tencent/trtc-js-sdk';
2. 配置manifest.json
确保在manifest.json
中正确配置了SDK所需的权限和插件。
{
"mp-weixin": { // 以微信小程序为例
"appid": "your-app-id",
"setting": {
"urlCheck": false,
"requestDomain": ["your-cloud-domain"],
"wsRequestDomain": ["your-cloud-domain"]
},
"usingComponents": true,
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序音视频通话功能"
},
"camera": {
"desc": "你的摄像头将用于小程序音视频通话"
},
"microphone": {
"desc": "你的麦克风将用于小程序音视频通话"
}
}
}
}
3. 检查webpack配置
如果你遇到打包时的模块解析错误,可能需要调整webpack的配置。在vue.config.js
或webpack.config.js
中添加对SDK文件的特殊处理。
module.exports = {
configureWebpack: {
resolve: {
alias: {
'@tencent/trtc-js-sdk': path.resolve(__dirname, 'node_modules/@tencent/trtc-js-sdk/dist/trtc-js-sdk-2.x.x.min.js')
}
}
}
};
注意:这里的路径和版本号需要根据实际情况调整。
4. 调试和错误处理
如果打包仍然报错,仔细检查错误信息,看是否是SDK版本不兼容、依赖缺失或配置错误。使用console.log
或调试工具跟踪SDK的加载和执行过程,可以帮助定位问题。
try {
const client = TRTC.createClient({ sdkAppId: 'your-sdk-app-id' });
console.log('TRTC client created successfully');
} catch (error) {
console.error('Failed to create TRTC client:', error);
}
通过上述步骤,你应该能够解决uni-app结合腾讯云实时音视频SDK打包时遇到的大部分问题。如果问题依旧存在,建议查阅SDK的官方文档或向腾讯云支持团队寻求帮助。