安装expo-auth-session后Android构建失败:expo-crypto编译Release Kotlin失败
错误详情
Task :expo-crypto:compileReleaseKotlin FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
错误说明:本次构建使用了已弃用的Gradle特性,与Gradle 8.0不兼容;可通过--warning-mode all参数查看具体弃用警告,定位问题来源。
修复步骤
降级Gradle版本至7.x系列
修改项目根目录下gradle/wrapper/gradle-wrapper.properties文件中的distributionUrl,指定7.x版本的Gradle:distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip同步修改
android/build.gradle中的Gradle插件版本,保证版本匹配(示例中Gradle 7.5.1对应插件7.4.2):buildscript { dependencies { classpath 'com.android.tools.build:gradle:7.4.2' } }更新expo相关依赖版本
确认expo-auth-session和expo-crypto版本与当前Expo SDK兼容,在package.json中调整版本后执行依赖安装:npm install # 或使用yarn yarn install定位具体弃用警告
执行构建命令时添加--warning-mode all参数,获取详细警告信息:./gradlew assembleRelease --warning-mode all根据输出的具体警告,针对性修改对应脚本或插件配置。
清理构建缓存
清理缓存后重新构建,避免缓存导致的异常:./gradlew clean npm run android
内容的提问来源于stack exchange,提问作者sakshya73

