如何避免android studio使用绝对路径?

s4n0splo  于 2023-04-28  发布在  Android
关注(0)|答案(1)|浏览(115)

我想强制gradle文件使用相对路径,当我添加一些.jar文件作为库在android studio.我找不到明确的解决方案,这将为我工作.
当我添加.jar文件作为库时,我在我的gradle文件中看到了如下内容:

compile files('D:/Development/myApp/libs/my-jar-file.jar')

我希望有以下几点:

compile files('libs/my-jar-file.jar')

谢谢你的回答

r7s23pms

r7s23pms1#

gradle:7.4.2'新版本中,如果这样添加,会出现警告信息和黄色。

避免在.gradle文件中使用绝对路径

implementation files('C:/Users/Mori/AndroidStudioProjects/InternalLibsKotlin/banner/build/outputs/aar/banner-debug.aar')

所以你可以忽略它作为旧的建议提到它
https://googlesamples.github.io/android-custom-lint-rules/checks/GradlePath.md.html
或者就像这样做

implementation files(/C:\/Users\/moriz\/AndroidStudioProjects\/InternalLibsKotlin\/banner\/build\/outputs\/aar\/banner-debug.aar/)

相关问题