简体   繁体   English

无法运行Android的位图示例代码

[英]Unable to run Bitmap sample code for Android

I am trying to run the sample from : http://developer.android.com/training/displaying-bitmaps/display-bitmap.html 我正在尝试从以下网站运行示例: http : //developer.android.com/training/displaying-bitmaps/display-bitmap.html

However I encountered lots of errors like: 但是我遇到了很多错误,例如:

Description Resource Path Location Type 说明资源路径位置类型

BuildConfig cannot be resolved to a variable    ImageGridFragment.java  /ImageGridActivity/src/com/example/android/bitmapfun/ui line 124    Java Problem

Description Resource Path Location Type 说明资源路径位置类型

SuppressLint cannot be resolved to a type   Utils.java  /ImageGridActivity/src/com/example/android/bitmapfun/util   line 99 Java Problem

I ran thru Google but could get nothing. 我跑过Google,但一无所获。 Adjusted the android build target to 4.0.3 (15) but still no clue. 将android构建目标调整为4.0.3 (15)但仍然没有任何提示。 Anyone ran this sample successfully? 有人成功运行了该样本吗?

Thanks. 谢谢。

Here is my solution: 1.Create a new class: 这是我的解决方案:1.创建一个新类:

package com.example.android.bitmapfun;

public class BuildConfig {
public static final boolean DEBUG = true;
}

2.Comment the lines that contain "SuppressLint": 2.注释包含“ SuppressLint”的行:

//import android.annotation.SuppressLint;
//    @SuppressLint("NewApi")

Android developer tools r17 brings a feature to Eclipse where a class is auto built at build-time, called BuildConfig, which contains a constant that can be used by the app developer to sense whether the build is a dev build or a production build. Android开发人员工具r17为Eclipse带来了一项功能,该功能在构建时会自动构建一个名为BuildConfig的类,该类包含一个常量,应用程序开发人员可以使用该常量来感测该构建是开发构建还是生产构建。 This feature appears to be in the Eclipse integration support, so when using IntelliJ, this useful feature is not available 该功能似乎在Eclipse集成支持中,因此在使用IntelliJ时,此有用的功能不可用

In gen folder with R.java there should be BuildConfig.java if your program compiled successfully. 如果您的程序编译成功,则在带有R.java的gen文件夹中应该有BuildConfig.java。

/** Automatically generated file. DO NOT MODIFY */
package com.example.android.bitmapfun;

public final class BuildConfig {
    public final static boolean DEBUG = true;
}

Clean your project and try to launch it again. 清理您的项目,然后尝试再次启动它。

It worked for me. 它为我工作。

For me also it is not running directly import to eclipse. 对我来说,它也没有运行直接导入到日食。 Just i put comments which lines is showing errors then it is working fine for me. 只要我发表评论,哪几行显示错误,然后对我来说就很好了。 May be it is not a right answer but we can see the application functionality by running the code so i did like that. 也许这不是一个正确的答案,但是我们可以通过运行代码来查看应用程序的功能,因此我确实这样做了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM