Problems专题之Gradle

Problems专题之Gradle

0x01 More than one file was found with OS independent path ‘META-INF/webview_release.kotlin_module’

这是因为第三方库中存在很多重名的META-INF文件,在打包的时候去除即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
android {
// ...
packagingOptions {
exclude 'META-INF/webview_release.kotlin_module'
exclude 'META-INF/proguard/androidx-annotations.pro'
exclude 'META-INF/gradle/incremental.annotation.processors'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
// ...
}
}

0x02 Certificate for <x.x.x> doesn’t match any of the subject alternative names

在执行gradlew命令打包时遇到这个错误,肯定是https证书有问题。

解决方案:如果支持http的话就使用http

1
2
3
4
5
6
7
8
9
> Could not resolve com.bytedanceapi:ttsdk-ttmp:1.36.2.25.pcdn.
Required by:
project :player > com.bytedanceapi:ttsdk-player_premium:1.36.2.25.pcdn > com.bytedanceapi:ttsdk-ttplayer:1.36.2.25.pcdn
> Could not resolve com.bytedanceapi:ttsdk-ttmp:1.36.2.25.pcdn.
> Could not get resource 'https://artifact.bytedance.com/repository/Volcengine/com/bytedanceapi/ttsdk-ttmp/1.36.2.25.pcdn/ttsdk-ttmp-1.36.2.25.pcdn.pom'.
> Could not GET 'https://artifact.bytedance.com/repository/Volcengine/com/bytedanceapi/ttsdk-ttmp/1.36.2.25.pcdn/ttsdk-ttmp-1.36.2.25.pcdn.pom'.
> Certificate for <artifact.bytedance.com> doesn't match any of the subject alternative names: [*.alicdn.com, *.cmos.greencompute.org, cmos.greencompute.org, m.intl.taob
ao.com, *.mobgslb.tbcache.com, alikunlun.com, *.alikunlun.com, s.tbcdn.cn, *.django.t.taobao.com, alicdn.com]

把项目根目录的build.gradle文件中所有的https://artifact.bytedance.com/替换为http://artifact.bytedance.com/即可

Ox03 module java.base does not “opens java.io” to unnamed module

升级到 Java 16 以上,AndroidStudio编译遇到错误。

Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not “opens java.io” to unnamed module @fb04536

解决方案一:

  1. gradle-wrapper 属性中的 gradle 版本更改为 7.1.1(6.x 不支持 java 16)
  2. gradle.properties 中添加以下行
1
2
3
4
5
6
org.gradle.jvmargs=-Xmx1536m \
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED \
--add-opens=java.base/java.lang=ALL-UNNAMED \
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED \
--add-opens=java.base/java.io=ALL-UNNAMED \
--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED

解决方案二:

升级build-gradlew版本。 将项目根目录的 build.gradle文件中
classpath 'com.android.tools.build:gradle:4.2.2'
升级为
classpath 'com.android.tools.build:gradle:7.2.1'

作者

Dench

发布于

2023-07-05

更新于

2023-07-05

许可协议

CC BY-NC-SA 4.0

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×