2月6日Deadline,Android要上线前夕,Debug包测试通过都正常的情况下,打Release包做发版准备,其中遇到报错,做下小记。 报错如下:
wangzhe@MacBook-Pro android % sudo ./gradlew assembleRelease --warning-mode all
Password:
> Configure project :app
Reading env from: .env
> Configure project :react-native-blob-util
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.
The AbstractCompile.destinationDir property has been deprecated. This is scheduled to be removed in Gradle 9.0. Please use the destinationDirectory property instead. Consult the upgrading guide for further information: https://docs.gradle.org/8.0.1/userguide/upgrading_version_7.html#compile_task_wiring
> Task :app:mergeReleaseResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> Multiple task action failures occurred:
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> Android resource compilation failed
ERROR:/Users/wangzhe/Work/xxxMobile/android/app/build/generated/res/createBundleReleaseJsAndAssets/drawable-mdpi/src_assets_images_sisal.png: AAPT: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> Android resource compilation failed
ERROR:/Users/wangzhe/Work/xxxMobile/android/app/build/generated/res/createBundleReleaseJsAndAssets/drawable-mdpi/src_assets_images_skyline.png: AAPT: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> Android resource compilation failed
ERROR:/Users/wangzhe/Work/xxxMobile/android/app/build/generated/res/createBundleReleaseJsAndAssets/drawable-mdpi/src_assets_images_elephant.png: AAPT: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> Android resource compilation failed
ERROR:/Users/wangzhe/Work/xxxMobile/android/app/build/generated/res/createBundleReleaseJsAndAssets/drawable-mdpi/src_assets_images_structure.png: AAPT: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> Android resource compilation failed
ERROR:/Users/wangzhe/Work/xxxMobile/android/app/build/generated/res/createBundleReleaseJsAndAssets/drawable-mdpi/src_assets_images_chianti.png: AAPT: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> Android resource compilation failed
ERROR:/Users/wangzhe/Work/xxxMobile/android/app/build/generated/res/createBundleReleaseJsAndAssets/drawable-mdpi/src_assets_images_orange.png: AAPT: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> Android resource compilation failed
ERROR:/Users/wangzhe/Work/xxxMobile/android/app/build/generated/res/createBundleReleaseJsAndAssets/drawable-mdpi/src_assets_images_orientalic.png: AAPT: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> Android resource compilation failed
ERROR:/Users/wangzhe/Work/xxxMobile/android/app/build/generated/res/createBundleReleaseJsAndAssets/drawable-mdpi/src_assets_images_keywest.png: AAPT: error: file failed to compile.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 25s
818 actionable tasks: 6 executed, 812 up-to-date
一开始看到这个报错的时候不太理解,百度谷歌之后大部分都是说gradle版本的问题,最后有看到一些文章说可能是图片源的问题。
找了产品重新提供这些图片之后,发现仍旧是相同的报错,最后看到stackoverflow上的一个问题采纳的也是图片重新处理,最后不死心自己下了Photoshop,重新处理保存了一下图片,发现这个问题已经解决。
解决方案: 1.修改图片后缀.png为.jpg,然后修改代码里引用的图片后缀 ✖️尝试无效 2.使用图片编辑器(例如Photoshop)打开图片后重新另存为自己需要的格式 ☑️对我是有效的