久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

自動解決 Android 構(gòu)建錯誤:幀像素必須是實(shí)心或透

Automatically solve Android build Error:Frame pixels must be either solid or transparent (not intermediate alphas). - Found at pixel #4 along top edge(自動解決 Android 構(gòu)建錯誤:幀像素必須是實(shí)心或透明(不是中間 alpha).- 在
本文介紹了自動解決 Android 構(gòu)建錯誤:幀像素必須是實(shí)心或透明(不是中間 alpha).- 在頂部邊緣的像素 #4 處發(fā)現(xiàn)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

Android Studio(使用 SDK 19、21 或 22)顯示 Eclipse ADT(使用 SDK 19)沒有的錯誤:

<塊引用>

錯誤:9 補(bǔ)丁圖像 D:Workspaces.... esdrawable-hdpitn_bg_common_press.9.png 格式錯誤.錯誤:幀像素必須是實(shí)心或透明的(不是中間 alpha).- 在頂部邊緣的像素 #4 處找到.

或 和 .這解釋了每邊額外的 1px 的用途.

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.... esdrawable-hdpitn_bg_common_press.9.png malformed. Error:Frame pixels must be either solid or transparent (not intermediate alphas). - Found at pixel #4 along top edge.

Or another error:

Error:Ticks in transparent frame must be black or red.

both within aapt

Error:Error: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'E:Androidsdk-Android-Studiouild-tools19.1.0aapt.exe'' finished with non-zero exit value 42

Example of file is above, but there are 20+ such files that worked well.

How do I make Android Studio or Gradle skip this error and not fail without having to modify those files one-by-one?

If it is not possible with Gradle, what command-line tool could I use to replace all transparent pixel with non-transparent?

The build.gradle file for the application module (where resources are) is below.

I have tried both with SDK 19 and SDK 21 and build tools 19.1, 21.1.2, 22.

A similar issue on AOSP, Issue 159464: Android studio: mergeDebugResources FAILED when importing Eclipse project.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.+'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

//---
task wrapper(type: Wrapper) {
    gradleVersion = '2.2.1'
}

apply plugin: 'com.android.application'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':afinal')
    compile 'com.android.support:appcompat-v7:19.0.+'
    //compile 'com.android.support:appcompat-v7:21.0.+'
}

//---
android {
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
    }

    compileSdkVersion 19
    buildToolsVersion "19.1.0"
    //compileSdkVersion 21
    //buildToolsVersion "21.1.2"
    //compileSdkVersion Integer.parseInt(project.COMPILE_SDK_VERSION)
    //buildToolsVersion project.BUILD_TOOLS_VERSION

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            zipAlignEnabled true
            //signingConfig signingConfigs.release
        }
        debug {
            zipAlignEnabled true
        }
    }

    lintOptions {
        //checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false // false also required by https://wiki.jenkins-ci.org/display/JENKINS/Android+Lint+Plugin
    }
}//android

Android Gradle plugins sources are at https://android.googlesource.com/platform/tools/build/+/master.

解決方案

How automatically solve the issue (without checking all images in different resolutions)

Not possible. Since you want the .png to behave like a nine-patch (expand along the edges, not stretch the whole bitmap), you're going to have to format them as such ergo you have to modify the files.

Proposed alternative

Since the shape is so simple you'd be better off deleting all variants of this file (saving space, time and headache in the process) and create /res/drawable/btn_bg_common_press.xml drawable with following contents:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <corners android:radius="16dp"/>
    <solid android:color="#ccc"/>
    <stroke
        android:color="#0c0"
        android:width="2dp"/>
</shape>

You can use dimen and color resources instead of hardcoded values. Additionally you might want to add the padding element inside shape

<shape...>
    <padding
        android:top="8dp"
        android:left="8dp"
        android:bottom="8dp"
        android:right="8dp"/>
</shape>

and/or wrap the shape element inside an inset element.

<inset
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:insetTop="8dp"
    android:insetLeft="8dp"
    android:insetBottom="8dp"
    android:insetRight="8dp">
    <shape...>
</inset>

If you do that, the drawable will have implied padding and you won't have to set it when styling widgets. Since you have multiple state drawables for the button I suggest you convert all of them to XML to make sure the line thickness and corners match.

Despite the root element's name the <shape> actually inflates to GradientDrawable (meaning you can fill it with gradient instead of solid color). Review GradientDrawable docs for all its options. Do not ever use ShapeDrawable programmatically, it just doesn't work.

Analyzing 9-patches

Consider the three following enlarged images.

Candidate #1 is a nine-patch. It has reserved 1px on each side for stretch and padding specification. This one will behave as an ordinary bitmap when stretched. If the width will be greater than height, so will the border thickness on sides. The border will scale proportionally.

Candidate #2 is also a nine-patch and is actually saying it's going to stretch everything besides 1px border and will have implied padding of 3px on each side. It will have a nice crisp 1px border when stretched.

Candidate #3 is NOT a nine-patch. It scales the same way as #1.

Now let's take a look at enlarged version of the image you included in OP:

As you can see it's not a nine-patch, so it won't get interpreted as one and the build tools are kind enough to warn you of that. Even if older build tools were more forgiving and added transparent 1px on each side for you, the result would have behaved like an ordinary bitmap, meaning when stretched it would look like specimen A instead of expected result specimen B.

Here's more reading on nine-patches. This explains what the extra 1px on each side is used for.

這篇關(guān)于自動解決 Android 構(gòu)建錯誤:幀像素必須是實(shí)心或透明(不是中間 alpha).- 在頂部邊緣的像素 #4 處發(fā)現(xiàn)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

IncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM(更新到 Android Build Tools 25.1.6 GCM/FCM 后出現(xiàn) IncompatibleClassChangeError)
How to get current flavor in gradle(如何在 gradle 中獲取當(dāng)前風(fēng)味)
How to fix quot;unexpected element lt;queriesgt; found in lt;manifestgt;quot; error?(如何修復(fù)“意外元素lt;查詢gt;在“清單中找到錯誤?)
Multi flavor app based on multi flavor library in Android Gradle(基于 Android Gradle 中多風(fēng)味庫的多風(fēng)味應(yīng)用)
Android dependency has different version for the compile and runtime(Android 依賴在編譯和運(yùn)行時有不同的版本)
Transitive dependencies for local aar library(本地 aar 庫的傳遞依賴)
主站蜘蛛池模板: 色性av| 精品视频在线一区 | 男人的天堂久久 | 亚洲在线日韩 | 欧洲视频一区二区 | 亚洲黄色一级毛片 | 红桃视频一区二区三区免费 | 黄色欧美视频 | 日韩综合在线 | 五月激情综合网 | 日韩精品一区二区三区视频播放 | 99精品99久久久久久宅男 | 99精品视频免费在线观看 | 亚洲一区视频 | 一区二区日本 | 玖玖综合网 | 国产精品亚洲一区二区三区在线观看 | 日韩毛片中文字幕 | a级黄色片在线观看 | 在线观看欧美日韩视频 | 91精产国品一二三区 | 天天爽夜夜骑 | 综合久久综合久久 | 亚洲精品久久久一区二区三区 | 天堂在线1 | 中文在线播放 | 久久久久久国产 | 成人在线中文字幕 | 国产日韩欧美激情 | 国产视频三级 | 91 中文字幕 | 精品99久久久久久 | 久久精品网 | 天天操天天干天天爽 | 欧美一区2区三区4区公司二百 | 国产精品一区2区 | 天天曰夜夜 | 欧美精品在线观看 | 亚洲一区二区三区免费视频 | 好婷婷网 | 免费在线观看成人av |