Automatically solve Android build Error:Frame pixels must be either solid or transparent (not intermediate alphas). - Found at pixel #4 along top edge

后端 未结 4 1935
太阳男子
太阳男子 2020-12-14 03:11

Android Studio (using SDK 19, 21 or 22) shows an error that Eclipse ADT (using SDK 19) does not:

Error:9-patch image D:\\Workspaces....\\res\\drawable

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-14 03:58

    Android now has two PNG crunchers, the AAPT one and a Java one. To ignore the PNG error in build process, you can force Gradle build to use the old AAPT by setting the below line in your build.gradle file:

    android.aaptOptions.useAaptPngCruncher = true
    

    Still this may give you the same error, as the AAPT tool from the latest SDK might be checking for this error too. So you have two options:

    • Find an older AAPT, for example, /build-tools/17.0.0/aapt, overwrite your current SDK AAPT with this old one. Your build issues may now be resolved. If this doesn't work, try the below option.

    • Write a simple Bash or Perl script, name it "aapt" and put it in your current SDK build-tools folder. This script will call the old version 17 AAPT for your *9.png, and use the new AAPT for everything else. See this Stack Overflow answer for a sample script.

提交回复
热议问题