Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct local .aar file dependencies are not supported when building an AAR. #18

Open
haydenconquerstars opened this issue Dec 1, 2020 · 35 comments

Comments

@haydenconquerstars
Copy link

When I build the apk , there is error .
Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :uiw_react-native-alipay project caused this error: C:\Users\username\AwesomeProject\node_modules@uiw\react-native-alipay\android\libs\alipaySdk-15.7.9-20200727142846.aar

@chenshaxuanjing
Copy link

same issue

@wulaizi
Copy link

wulaizi commented Feb 26, 2021

I'm also the one who reported the mistake

@wulaizi
Copy link

wulaizi commented Mar 2, 2021

Modify Android/ build.gradle 'dependencies classpath
classpath 'com.android.tools.build:gradle:4.1.0' Change to com.android.tools.build:gradle:3.x.x

@meiqi1992
Copy link

我也碰到了,但是gradle 又只能4.0.1 用了react-native-crop-image 这咋办? @wulaizi

@GreatAuk
Copy link

GreatAuk commented May 13, 2021

我也碰到了,但是gradle 又只能4.0.1 用了react-native-crop-image 这咋办? @wulaizi

参考这个:https://stackoverflow.com/a/63665094/6880617
image
这是我改的

更新:
改了之后打包好像没问题,但是点击支付的时候闪退了

@GreatAuk
Copy link

Modify Android/ build.gradle 'dependencies classpath
classpath 'com.android.tools.build:gradle:4.1.0' Change to com.android.tools.build:gradle:3.x.x

@jaywcjlove 小弟调调™ 我看仓库里的 example 并没有修改 com.android.tools.build:gradle 的版本,请问是怎么避免这个问题的?

@jaywcjlove
Copy link
Member

@GreatAuk 是我测试用例,在我们 项目 中使用没有问题的样子

@GreatAuk
Copy link

@jaywcjlove 我下载了 example , android 打包./gradlew assembleRelease发现有一样的问题,开发调试没问题
image
你们自己的项目的 com.android.tools.build:gradle 版本是大于 4 的吗

@jaywcjlove
Copy link
Member

我自己项目每次都升级到 react 初始化工程的默认版本

当前工程是边开发边测试,所以示例里面使用 link:../ 使用 yarn 安装,会把上一级目录中的包进行 软连接

"@uiw/react-native-alipay": "link:../",

@jaywcjlove
Copy link
Member

@chenshaxuanjing

@GreatAuk
Copy link

@jaywcjlove 目前找到了这个方案 https://stackoverflow.com/a/60888941/6880617,或许可以参考下。不会 android 原生,所以搜索到的方案一直感觉不得要领

@GreatAuk
Copy link

RN 安装 react-native-camera 升级 classpath 'com.android.tools.build:gradle:4.0.1' 应该是大多数应用都有用到的...。所以感觉这样问题应该挺普遍的,希望能跟进下

@GreatAuk
Copy link

我也碰到了,但是gradle 又只能4.0.1 用了react-native-crop-image 这咋办? @wulaizi

@meiqi1992 问下这个问题有解决吗

@jaywcjlove
Copy link
Member

@GreatAuk 我把 SDK 也升级了, Upgrade + @uiw/react-native-alipay@4.0.0-beta.1
@haydenconquerstars @chenshaxuanjing @wulaizi 还没有测试,可以测试一下有什么问题。

@jaywcjlove
Copy link
Member

classpath("com.android.tools.build:gradle:4.1.0")

@GreatAuk
Copy link

@jaywcjlove
image

@GreatAuk
Copy link

@jaywcjlove 确认还是报一样的错

@jaywcjlove
Copy link
Member

@GreatAuk 示例必须降到 3.5.3 才能兼容所有?

@GreatAuk
Copy link

@GreatAuk 示例必须降到 3.5.3 才能兼容所有?

对的,你自己也可以打包试下,就仓库里面的 example 项目(我只是把 package.json 里面的 react-native-alipay 源改成了在线的)。你们不会从来没用这个 example 打包过吧...

@jaywcjlove
Copy link
Member

@GreatAuk 前面几版本都是有测试,我们的产品上线之后,改动不大的,我都只测试了iOS

@meiqi1992
Copy link

@GreatAuk 这个问题你解决了吗,我还没解决 升级到4.0.0-beta.1 还是一样的问题

@GreatAuk
Copy link

GreatAuk commented Jun 23, 2021

@meiqi1992
Modify Android/ build.gradle 'dependencies classpath
classpath 'com.android.tools.build:gradle:4.1.0' Change to com.android.tools.build:gradle:3.x.x
直接改成 3.x.x 了,react-native-camera 也能用...,试试吧,也没什么成本

@jaywcjlove
Copy link
Member

https://uiwjs.github.io/npm-unpkg/#/pkg/@uiw/react-native-alipay/file/package.json

使用的时候 @uiw/react-native-alipay 组件安装不会有 example 示例目录,应该不会错误。

example 目录示例只需要保证测试 @uiw/react-native-alipay 组件有没有问题就可以了吧。

@lxp-git
Copy link

lxp-git commented Jul 13, 2021

https://uiwjs.github.io/npm-unpkg/#/pkg/@uiw/react-native-alipay/file/package.json

使用的时候 @uiw/react-native-alipay 组件安装不会有 example 示例目录,应该不会错误。

example 目录示例只需要保证测试 @uiw/react-native-alipay 组件有没有问题就可以了吧。

@justjavac 还是改成implementation (name: 'alipaysdk-15.8.03.210428205839', ext: 'aar')吧,真有问题

@jaywcjlove
Copy link
Member

jaywcjlove commented Jul 13, 2021

https://uiwjs.github.io/npm-unpkg/#/pkg/@uiw/react-native-alipay@4.0.0-beta.1/file/android/build.gradle

// 支付宝 SDK AAR 包所需的配置
// implementation (name: 'alipaysdk-15.8.03.210428205839', ext: 'aar')
implementation fileTree(dir: "libs", include: ["*.aar"])

// 支付宝 SDK AAR 包所需的配置
// implementation (name: 'alipaySdk-15.7.7-20200702160044', ext: 'aar')
implementation fileTree(dir: "libs", include: ["*.aar"])

@lxp-git 这两种方式有什么区别?

@lxp-git
Copy link

lxp-git commented Jul 13, 2021

https://uiwjs.github.io/npm-unpkg/#/pkg/@uiw/react-native-alipay@4.0.0-beta.1/file/android/build.gradle

// 支付宝 SDK AAR 包所需的配置
// implementation (name: 'alipaysdk-15.8.03.210428205839', ext: 'aar')
implementation fileTree(dir: "libs", include: ["*.aar"])

// 支付宝 SDK AAR 包所需的配置
// implementation (name: 'alipaySdk-15.7.7-20200702160044', ext: 'aar')
implementation fileTree(dir: "libs", include: ["*.aar"])

@lxp-git 这两种方式有什么区别?

@jaywcjlove 现在gradle4发不了release

@jaywcjlove
Copy link
Member

gradle4 只支持implementation (name: 'alipaySdk-15.7.7-20200702160044', ext: 'aar') 这种方式?

@lxp-git
Copy link

lxp-git commented Jul 13, 2021

gradle4 只支持implementation (name: 'alipaySdk-15.7.7-20200702160044', ext: 'aar') 这种方式?

@jaywcjlove 不是只支持啊,看报错提示的意思好像是模块不能直接依赖arr,会导致resource资源出问题?

具体不知道你可以试试,我这边改了然后编译过了😂能用就行

@jaywcjlove
Copy link
Member

@lxp-git 欢迎提交 PR

@lxp-git
Copy link

lxp-git commented Jul 13, 2021

@lxp-git 欢迎提交 PR

@jaywcjlove 光是改插件还不行,要把依赖包加载app模块里面,或者在project的allprojects里面写上flatDir { dirs "$rootDir/../node_modules/@uiw/react-native-alipay/android/libs" },这两个方案吧。🤣白嫖了帮助下后面白嫖的吧

@jaywcjlove jaywcjlove pinned this issue Jul 17, 2021
@k55k32
Copy link

k55k32 commented Sep 8, 2021

目前的解决方案:

  1. projectbuild.gradle 文件里的 allprojects -> repositories 块中添加 flatDir { dirs "$rootDir/../node_modules/@uiw/react-native-alipay/android/libs" }
  2. 修改 node_modules\@uiw\react-native-alipay\android\build.gradle 文件,在 dependencies 块中,将 implementation fileTree(dir: "libs", include: ["*.aar"])替换为 implementation (name: 'alipaysdk-15.8.03.210428205839', ext: 'aar')

@jaywcjlove
Copy link
Member

@k55k32 你这个是 react-native 什么版本?

@k55k32
Copy link

k55k32 commented Jan 6, 2022

@k55k32 你这个是 react-native 什么版本?

0.64.1 @jaywcjlove

@jaywcjlove
Copy link
Member

@k55k32 可以不在 项目工程中添加任何配置,就可以使用的方法?

@k55k32
Copy link

k55k32 commented Jan 6, 2022

@jaywcjlove 不太清楚,现在已经不用这个依赖了, 我们自己集成了一下,因为要使用支付宝的其他包,有依赖冲突

jaywcjlove pushed a commit that referenced this issue Jul 6, 2022
Co-authored-by: seven <seven@beansmile.com>
jaywcjlove added a commit that referenced this issue Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants