cordova cordova-plugin-wechat微信登陆常见问题

本文详细记录了解决Cordova项目中微信登录遇到的问题过程,包括处理httpPost异常及登陆回调缺失的方法。通过在config.xml中添加特定配置,解决了高版本安卓上因缺少org.apache.http.legacy库导致的错误,并通过添加WXEntryActivity活动配置解决了登录不回调的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

cordova cordova-plugin-wecha微信登陆常见问题


最近做混合开发,项目要接入微信登陆,于是屁颠屁颠去使用cordova-plugin-wechat,一步步看着文档弄好了,支付分享什么的都没有问题,唯独登陆一直没响应,网上各种查找也没头绪,于是我就去logcat 看日志,日志报了下面的错误错误,

Failed resolution of: Lorg/apache/http/client/methods/HttpPost

然后各种网上找资料说高版本安卓缺少了org.apache.http.legacy,于是查资料在config.xml加上了org.apache.http.legacy配置

 <config-file parent="/manifest/application" target="AndroidManifest.xml">
        <uses-library android:name="org.apache.http.legacy" android:required="false" />
 </config-file>

加完之后错误没有了,但是依然没有回调,本人非安卓出身,各种查资料依然无法解决,于是网上找了一份安卓微信登陆的源码,从头到位看了一遍,发现多了一个activity配置于是在config.xml加上了这个配置,

 <config-file parent="/manifest/application" target="AndroidManifest.xml">
            <activity
                    android:name=".wxapi.WXEntryActivity"
                    android:label="WXEntryActivity"
                    android:exported="true" />
        </config-file>

httpPost异常

Failed resolution of: Lorg/apache/http/client/methods/HttpPost
在conffig.xml加上

 <config-file parent="/manifest/application" target="AndroidManifest.xml">
        <uses-library android:name="org.apache.http.legacy" android:required="false" />
 </config-file>

登陆不回调

在conffig.xml加上

 <config-file parent="/manifest/application" target="AndroidManifest.xml">
            <activity
                    android:name=".wxapi.WXEntryActivity"
                    android:label="WXEntryActivity"
                    android:exported="true" />
        </config-file>

参考资料 https://www.jianshu.com/p/04ed0b65f3df

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值