无法解析符号奇巧不能解析方法getAllocationByteCount() [英] Cannot resolve symbol KITKAT Cannot Resolve method getAllocationByteCount()

查看:1005
本文介绍了无法解析符号奇巧不能解析方法getAllocationByteCount()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行BitmapFun官方的例子,但得到以下错误:

1)无法解析符号奇巧
2)无法解析法getAllocationByteCount()

任何帮助吗?

我的Andr​​oidManifest.xml:

 <采用-SDK
        安卓的minSdkVersion =7
        机器人:targetSdkVersion =19/>

和这里是code:

  @TargetApi(VERSION_ codeS.KITKAT)
公共静态INT getBitmapSize(BitmapDrawable值){
    位图的位图= value.getBitmap();    //从奇巧起使用getAllocationByteCount()作为分配的字节有可能成为
    //比位图字节数大。
    如果(Utils.hasKitKat()){
        返回bitmap.getAllocationByteCount();
    }    如果(Utils.hasHoneycombMR1()){
        返回bitmap.getByteCount();
    }    // pre HC-MR1
    返回bitmap.getRowBytes()* bitmap.getHeight();
}


解决方案

您需要构建SDK版本设置为19(4.4)或更高可用在编译时API级别19的符号。

首先,使用SDK管理器下载API 19,如果你没有它。

然后,配置项目中使用API​​ 19:


  • 在Android的工作室:文件 - >项目结构 - >常规设置 - >项目SDK


  • 在Eclipse ADT:项目属性 - > Android的 - >项目建设目标


I am trying to run "BitmapFun" official example but getting the following errors:

1)Cannot resolve symbol KITKAT 2) Cannot resolve method getAllocationByteCount()

Any help ?

My AndroidManifest.xml :

<uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="19" />

and here is the code :

 @TargetApi(VERSION_CODES.KITKAT)
public static int getBitmapSize(BitmapDrawable value) {
    Bitmap bitmap = value.getBitmap();

    // From KitKat onward use getAllocationByteCount() as allocated bytes can potentially be
    // larger than bitmap byte count.
    if (Utils.hasKitKat()) {
        return bitmap.getAllocationByteCount();
    }

    if (Utils.hasHoneycombMR1()) {
        return bitmap.getByteCount();
    }

    // Pre HC-MR1
    return bitmap.getRowBytes() * bitmap.getHeight();
}

解决方案

You'll need to set the build SDK version to 19 (4.4) or higher to have API level 19 symbols available while compiling.

First, use the SDK Manager to download API 19 if you don't have it yet.

Then, configure your project to use API 19:

  • In Android Studio: File -> Project Structure -> General Settings -> Project SDK.

  • In Eclipse ADT: Project Properties -> Android -> Project Build Target

这篇关于无法解析符号奇巧不能解析方法getAllocationByteCount()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆