uni-app app端 云打包出现分享模块丢失报错 "share:fail service not found"

发布于 1周前 作者 ionicwang 来自 Uni-App

uni-app app端 云打包出现分享模块丢失报错 “share:fail service not found”

开发环境 版本号 项目创建方式
Mac 13.4 HBuilderX

产品分类:uniapp/App

PC开发环境操作系统:Mac

HBuilderX类型:正式

HBuilderX版本号:3.98

手机系统:iOS

手机系统版本号:iOS 15

手机厂商:苹果

手机机型:12mini

页面类型:vue

vue版本:vue2

打包方式:云端

项目创建方式:HBuilderX


示例代码:

wxLogin() {
	uni.login({
		"provider": "weixin",
		"onlyAuthorize": true, // 微信登录仅请求授权认证
		success: function(event){
			console.log("--------", event);
		},
		fail: function (err) {
			// 登录授权失败
			console.log("sssssss", err);
			// err.code是错误码
		}
	})
}

// APP端分享
function appShare() {
	let shareInfo = {
		title: "标题",
		imageUrl: "",
		href: "https://www.baidu.com",
		summary: "啊啊啊啊啊",
		scene: "WXSceneSession",
	};
	uni.share({
		...shareInfo,
		success: function (res) {
			console.log("success:" + JSON.stringify(res));
		},
		fail: function (err) {
			console.log("fail:" + JSON.stringify(err));
		},
	});
}

操作步骤:

manifest.json 中勾选了

  • 微信 登录 和 微信分享

  • 填写了 appid

  • 填写了 UniversalLinks

  • 配置了 capabilitiesassociated-domains

云打包 打 自定义基座, 使用 自定义基座

预期结果:

正常 分享

实际结果:

{"errMsg":"share:fail service not found"}

bug描述:

使用自定义基座时, app-ios

  • 微信登录 可以正常跳转到微信,
  • 微信分享 uni.share 会报错 {"errMsg":"share:fail service not found"}

使用同样配置的 appidUniversalLinks 使用原生ios工程, 可以正常跳转


4 回复

感觉像是自定义基座版本号没改导致的安装未覆盖 更新自定义基座版本号重新打包 或者 移除手机应用重新安装运行


对不起大佬, 复制别人的代码 , 发现少了 参数 , uni.share 需要提供 provider: ‘weixin’, 这个参数…

这个 报错 是 因为 uni.share 没有 提供 provider: ‘weixin’
不是bug
总结: 要多看文档…

在 uni-app 中进行云打包时,出现 share:fail service not found 报错,通常是因为在打包过程中未正确配置或引入分享模块。以下是可能的解决方案:

1. 确认 manifest.json 配置

manifest.json 文件中,确保已正确配置分享模块。例如,如果你使用的是微信分享,需要在 manifest.json 中添加以下配置:

{
  "app-plus": {
    "plugins": {
      "share": {
        "type": "weixin",
        "appid": "your-wechat-appid"
      }
    }
  }
}

如果你使用的是其他平台的分享(如 QQ、微博等),也需要在 manifest.json 中配置相应的插件。

2. 检查模块是否已正确引入

在代码中,确保你已经正确引入了分享模块。例如,使用 uni.share 方法时,确保你已经引入了 uni 库:

uni.share({
  provider: 'weixin',
  scene: 'WXSceneSession', // 分享到聊天界面
  type: 0,
  href: 'https://www.example.com',
  title: '分享标题',
  summary: '分享描述',
  imageUrl: 'https://www.example.com/image.png',
  success: function (res) {
    console.log('分享成功');
  },
  fail: function (err) {
    console.log('分享失败:', err);
  }
});
回到顶部
AI 助手
你好,我是IT营的 AI 助手
您可以尝试点击下方的快捷入口开启体验!