wonday / react-native-aliyun-push

A react native wrapper for aliyun push SDK
MIT License
218 stars 64 forks source link

集成了Alipay支付 出现的问题汇总及解决办法 #113

Open evan0204 opened 5 years ago

evan0204 commented 5 years ago

1、react-native-aliyun-push 的gradle 编译支持只到API 26,但是目前Android9 API28了,会出现找不到资源问题。 2、集成了Alipay支付的,我集成的是:@0x5e/react-native-alipay 这个库,造成了冲突;主要冲突是alicloud-android-utdid这个库的依赖问题。

特别是第2个问题困扰了我很久(3-4个小时)才解决,针对以上2个问题我做了build.gradle的配置调整,经过测试,打包成功,现分享给朋友们,希望可以帮助绕坑。

鉴于github无法上传文件,我把react-native-aliyun-push工程下的整个build.gradle 调整过的代码贴在下面。

apply plugin: 'com.android.library'

description = 'react-native-aliyun-push'

buildscript { repositories { jcenter() }

dependencies {
    classpath 'com.android.tools.build:gradle:1.3.1'
    classpath 'com.google.gms:google-services:3.0.0'
}

}

android { compileSdkVersion 28 buildToolsVersion '28.0.3'

defaultConfig {
    minSdkVersion 16
    targetSdkVersion 28
}

}

repositories { flatDir { dirs 'libs' } jcenter() }

dependencies {

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.facebook.react:react-native:+'
api ('com.aliyun.ams:alicloud-android-push:3.1.5')
{
    exclude module:'alicloud-android-utdid'
}
implementation ('com.aliyun.ams:alicloud-android-utils:1.1.3') {
    exclude module:'alicloud-android-utdid'
}
implementation ('com.aliyun.ams:alicloud-android-beacon:1.0.1') {
    exclude module:'alicloud-android-utdid'
}
// implementation 'com.aliyun.ams:alicloud-android-utdid:1.1.5.3'
implementation ('com.aliyun.ams:alicloud-android-ut:5.1.0') {
    exclude module:'alicloud-android-utdid'
}
api(name: 'alicloud-android-third-push-3.0.6', ext: 'aar') {
    exclude module:'alicloud-android-utdid'
}
implementation 'me.leolin:ShortcutBadger:1.1.22@aar'

}

wonday commented 5 years ago

多谢,我会更新到下一版。 关于冲突,也可以查看官方资料: https://help.aliyun.com/knowledge_detail/59152.html?spm=a2c4g.11186623.2.28.464752e7m6xoyi

BridgeEast commented 5 years ago

@wonday 去掉了这个依赖,对于只用到推送功能的人,alicloud-android-utdid这个还是需要的,文档需要提及一下

evan0204 commented 5 years ago

多谢,我会更新到下一版。 关于冲突,也可以查看官方资料: https://help.aliyun.com/knowledge_detail/59152.html?spm=a2c4g.11186623.2.28.464752e7m6xoyi

RN 0.63.3 集成最新版本,因为IOS工程是自动Link了,所以集成了Alipay的情况下IOS出现了冲突。 错误Log:duplicate XXXX 出现了重复之类的语句。

解决办法: 找到node_modules目录下的react-native-aliyun-push工程中 RCTAliyunPush.podspec文件的16行代码: spec.vendored_frameworks = "ios/libs/AlicloudUtils.framework","ios/libs/CloudPushSDK.framework","ios/libs/UTDID.framework","ios/libs/UTMini.framework" 改成(删除UTDID.framework): spec.vendored_frameworks = "ios/libs/AlicloudUtils.framework","ios/libs/CloudPushSDK.framework","ios/libs/UTMini.framework"

phyng commented 4 years ago

感谢 @Evan-Future ! 👍 顺便提供一下综合 f8ebbb96a71e2dc4e47b2bb5dc2c650a40a353dc 代码和 @Evan-Future 修改之后的配置:

点击展开

```gradle apply plugin: 'com.android.library' description = 'react-native-aliyun-push' buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.3.1' classpath 'com.google.gms:google-services:3.0.0' } } android { compileSdkVersion 28 buildToolsVersion '28.0.3' defaultConfig { minSdkVersion 16 targetSdkVersion 28 } } repositories { flatDir { dirs 'libs' } jcenter() } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.facebook.react:react-native:+' api ('com.aliyun.ams:alicloud-android-push:3.1.6') { exclude module:'alicloud-android-utdid' } api ('com.aliyun.ams:alicloud-android-utils:1.1.3') { exclude module:'alicloud-android-utdid' } api ('com.aliyun.ams:alicloud-android-beacon:1.0.2') { exclude module:'alicloud-android-utdid' } // api 'com.aliyun.ams:alicloud-android-utdid:1.1.5.3' api ('com.aliyun.ams:alicloud-android-ut:5.4.0') { exclude module:'alicloud-android-utdid' } api (name: 'alicloud-android-third-push-3.0.9', ext: 'aar') { exclude module:'alicloud-android-utdid' } // huawei api 'com.google.firebase:firebase-messaging:17.6.0' api ('com.aliyun.ams:huawei-push:2.6.3.305') { exclude module:'alicloud-android-utdid' } api ('com.aliyun.ams:huawei-push-base:2.6.3.305') { exclude module:'alicloud-android-utdid' } // meizu api ('com.aliyun.ams:meizu-push:3.8.3-fix') { exclude module:'alicloud-android-utdid' } // shortcutBadger api 'me.leolin:ShortcutBadger:1.1.22@aar' } ```

alleniver commented 4 years ago

测试过有效的,不错,只是组件应该更新一下了,现在是3.2.2版本了,组件还是3.1.6版本的.