安卓开发错误集合

1、Cannot refer to a non-final variable rb inside an inner class defined in a different method

一旦参数在匿名类内部使用,则必须是final

即:final TextView tv = (TextView)findViewById(R.id.TextView1);

2、Exception raised during rendering: java.lang.System.arraycopy([CI[CII)V Exception details are logged

安卓开发错误集合_第1张图片

出现这样的问题是API 20不支持EditView控件,需要选择一个低版本的API就可以了。

3、The method setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener) in the type CompoundButton is not applicable for the arguments (new RadioGroup.OnCheckedChangeListener(){})

当RadioGroup与CompoundButton同时存在且都要监听事件时CompoundButton.OnCheckedChangeListener与RadioGroup.OnCheckedChangeListener就会出现冲突,导入任何一个包importandroid.widget.RadioGroup.OnCheckedChangeListener;会出现错误:

添加CompoundButton.就可以了

RadioButton rb = (RadioButton)this.findViewById(R.id.kai);

tb.setOnCheckedChangeListener(
newCompoundButton.OnCheckedChangeListener()
{

}

);

4、The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the argum

import android.content.DialogInterface.OnClickListener;  改成    import android.view.View.OnClickListener;

5、Call requires API level 5 (current min is 1): android.bluetooth.BluetoothAdapter#getDefaultAdapter

暂时解决办法:右击工程->Android Tools->Clear Lint Markers

完全解决办法:

AndroidManifest.xml中添加

    android:minSdkVersion="5"
    android:targetSdkVersion="5" />

6、错误:【The method setOnItemSelectedListener(AdapterView.OnItemSelectedListener) in the type AdapterView is not applicable for the arguments (new OnItemSelectedListener(){})】【OnItemSelectedListener cannot be resolved to a type】

添加:import android.widget.AdapterView.OnItemSelectedListener;

7、AutoUpdateReceiver cannot be resolved to a type

手动添加

import com.coolweather.app.receiver.AutoUpdateReceiver;

快捷键没有反应

8、The constructor ArrayAdapter(Top, int, String[]) is undefined

ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_spinner_item,st);

设置this为:活动名.this或者getContext()

9、No AVD available

如果有创建AVD,还出现这种情况,是因为版本过高,修改AndroidManifest.xml中android:minSdkVersion="8"

10、The import android.support.v7 cannot be resolved

ActionBarActivity cannot be resolved to a type

The method onCreate(Bundle) of type MainActivity must override or implement a supertype method

解决办法:api版本不对,可能api版本太低,右击项目->属性(Properties)->android

Library中先删除有×的,然后点击Add添加一个新的,点击OK

11、R cannot be resolved to a variable

注意所以的资源问题和文件名不能为大写、中文符号

12、不允许有匹配 "[xX][mM][lL]" 的处理指令目标。

检查AndroidManifest.xml中头部前面是不是有空格,去掉空格就好了

13、导入android-support-v7项目错误

右击项目->Properties>Android->Library中选中带× 的android-support-v7,选择Remove,然后Add.....选择新的v7包,OK

你可能感兴趣的:(Android开发错误集)