uni-app 自定义基座提示24 files found with path 'META-INF/INDEX.LIST' from inputs
uni-app 自定义基座提示24 files found with path ‘META-INF/INDEX.LIST’ from inputs
打包自定义基座提示:
```javascript
* What went wrong:
Execution failed for task ':app:mergeReleaseJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
> 24 files found with path 'META-INF/INDEX.LIST' from inputs:
- /home/[Name]/.gradle/caches/transforms-3/7e9aa5426f5ab971f983ff266693c8ef/transformed/jetified-netty-transport-rxtx-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/a605079fe75cd8578ceceb5cdb2d5bef/transformed/jetified-netty-transport-classes-kqueue-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/dbec77590d8e5cd8a0a9ea16d7de6f59/transformed/jetified-netty-transport-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/96d7d053c6e21ddf03e918afd4e460ba/transformed/jetified-netty-transport-udt-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/aa9d11324ae6cec207a6cabd7999fc6d/transformed/jetified-netty-codec-smtp-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/4c4877cbf95629a7c312bbc7bdc4ed74/transformed/jetified-netty-transport-sctp-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/c079acd042da0c31edb496fb21297b38/transformed/jetified-netty-codec-dns-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/80781b388e16e979d50de81d0869df06/transformed/jetified-netty-codec-redis-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/54226e9d4dfb0b6a7a3213b6de94e1ee/transformed/jetified-netty-codec-memcache-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/3cf4672a584f1c1209475ce1a8fc6c06/transformed/jetified-netty-resolver-dns-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/3e403a6fd70e8b03a5a44437926092c4/transformed/jetified-netty-transport-classes-epoll-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/49090ab6487b4e5b57737536b4f7f422/transformed/jetified-netty-codec-http2-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/c66787154af02064a3558cf44e8cb95f/transformed/jetified-netty-resolver-dns-classes-macos-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/5a06ac035cebef68f6b974e2822d80e7/transformed/jetified-netty-codec-socks-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/953c6aa4f8b0f11a3e3c744231b86134/transformed/jetified-netty-buffer-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/209e5bc5cd276a57b20e2dcc55465aa6/transformed/jetified-netty-codec-xml-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/18c99b954e917365853eb7fceab77796/transformed/jetified-netty-resolver-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/5732815d9b4e42519438fd82d434d951/transformed/jetified-netty-codec-mqtt-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/cda4a2d395dceccb69921c62630669eb/transformed/jetified-netty-codec-stomp-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/995f224bed8c7e10b927c4be4ecd9c80/transformed/jetified-netty-transport-native-unix-common-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/8fc0bd361d1cb5508fd74dabd5762ca6/transformed/jetified-netty-codec-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/7b268371d02a53ec7dc3833bf315cffe/transformed/jetified-netty-codec-http-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/02dc47a5c2bfe79d06ac53c2dac37c58/transformed/jetified-netty-handler-4.1.70.Final.jar
- /home/[Name]/.gradle/caches/transforms-3/760d5ee929cfb9a938f9f3565f8c3f02/transformed/jetified-netty-handler-proxy-4.1.70.Final.jar
Adding a packagingOptions block may help, please refer to
https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html
for more information
但是我的原生插件已经排除掉这个文件了如下:
packagingOptions {
resources {
excludes += "META-INF/INDEX.LIST"
excludes += "META-INF/io.netty.versions.properties"
}
}
并且离线打包运行都是没问题的,就是原生插件打包后放到hb里面有问题,请问还需要如何配置
在处理uni-app自定义基座构建过程中遇到的“24 files found with path ‘META-INF/INDEX.LIST’ from inputs”这类提示时,通常是由于APK打包过程中多个库或模块包含了相同的META-INF/INDEX.LIST
文件,导致冲突。这种情况在Android开发中较为常见,尤其是在集成了多个第三方库时。
为了解决这个问题,你可以在构建过程中配置Gradle脚本,自动删除重复的META-INF/INDEX.LIST
文件。以下是一个针对uni-app自定义基座(通常基于Android Studio)的Gradle配置示例,展示了如何在打包时排除这些文件。
修改build.gradle
文件
-
定位到你的uni-app项目的Android平台目录,通常路径为
platforms/android
。 -
打开
app
模块下的build.gradle
文件。 -
在
android
代码块内添加以下配置来排除META-INF/INDEX.LIST
文件:
android {
...
packagingOptions {
exclude 'META-INF/INDEX.LIST'
// 如果需要排除其他文件,可以添加更多exclude行,例如:
// exclude 'META-INF/DEPENDENCIES'
// exclude 'META-INF/LICENSE'
// exclude 'META-INF/LICENSE.txt'
// exclude 'META-INF/NOTICE'
// exclude 'META-INF/NOTICE.txt'
}
...
}
完整示例
以下是一个简化的build.gradle
文件示例,展示了如何整合上述配置:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.example.uniapp"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/INDEX.LIST'
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
// 其他依赖项...
}
应用更改并重新构建
保存build.gradle
文件的更改后,重新构建你的自定义基座。在Android Studio中,你可以通过点击Build -> Rebuild Project
来完成这一操作。
这样配置后,Gradle在打包APK时会自动排除所有META-INF/INDEX.LIST
文件,从而避免冲突,解决你遇到的问题。这种方法适用于大多数基于Gradle构建的Android项目,包括uni-app的自定义基座。