gradle 打包所有依赖 Invalid signature file digest for Manifest main attributes(转)

1.打包所有依赖:

// 指定main函数的类

jar {

manifest

{

  attributes "Main-Class": "com.baeldung.fatjar.Application" }

  from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }

}

}

 

遇到问题: Invalid signature file digest for Manifest main attributes

When using spark-submit to run a jar, you may encounter this error:

Invalid signature file digest for Manifest main attributes

The error occurs when one of the included libraries in the jar's META-INF directory has a bad signature.

Solve the error with this command:

zip -d <jar file name>.jar META-INF/*.RSA META-INF/*.DSA META-INF/*.SF

转载于:https://www.cnblogs.com/luoluoshidafu/p/11195816.html

### 解决 JDK21 升级后编译失败问题 当升级到 JDK 21 后遇到 `Invalid signature file digest for Manifest main attributes` 错误时,这通常意味着签名文件中的摘要与清单文件的主要属性不匹配。此问题可能源于多个方面。 #### 可能原因分析 1. **签名工具版本差异** 如果使用的签名工具有所不同或者版本更新,则可能导致生成的签名文件不符合预期格式[^2]。 2. **JDK 版本兼容性** 新版 JDK 对于某些旧有结构的支持可能会有所变化,特别是对于服务提供者接口(SPI)和服务加载机制方面的改动[^1]。 3. **构建过程中的资源冲突** 构建过程中如果存在重复或多余的签名文件被加入到了最终 APK 中,也会引发此类验证错误。 #### 解决策略 为了修复这个问题,可以尝试以下几个方法: - **清理并重新打包项目** 清除所有已有的构建缓存和输出目录,确保没有任何残留文件干扰新一次的构建流程。 - **移除多余签名文件** 手动检查并删除任何不必要的签名文件(如非标准命名的 `.RSA`, `.DSA` 或其他类似的文件),只保留官方推荐的标准签名组件 CERT.RSA, CERT.SF 和 MANIFEST.MF 文件。 - **调整 Gradle 配置** 修改项目的 `build.gradle` 文件来指定正确的签名配置项,并确认是否启用了 v2 签名方案以及其设置是否正确。 ```groovy android { ... signingConfigs { debug { storeFile file("debug.keystore") keyAlias 'androiddebugkey' keyPassword 'android' storePassword 'android' } release { // Your production keystore details here. } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release } } } ``` - **使用最新版本的 Android SDK 工具链** 更新至最新的 Android Studio 和相关插件,利用更稳定的工具集来进行应用开发和发布准备活动。 通过上述措施应该能够有效解决因 JDK 版本变更而引起的编译期
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值