嘿,更新Eclipse(Help -> Check for Updates
)和Android-SDK-Manager之后,我总是收到“ ...无法解析为类型”或“ ...无法解析为变量”的消息。在我已经创建的每个项目以及新项目中,我都会收到此错误消息。
我已经尝试过这些东西,但是没有一个适合我:
Project -> Clean...
Right click at the project -> Properties -> Java Build Path -> Libraries -> Add Library... -> JRE System Library
我的应用程序在更新eclipse和adt后无法运行Window -> Preferences -> Java -> Compiler -> Building -> [x] Rebuild class files modified by others
所有这三个步骤都无法解决这些错误消息...也许其他人知道该怎么办?重新安装Eclipse应该是最后的选择……将Eclipse与GitHub连接永远永远困扰着我:
示例代码:
package com.example.test;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
错误讯息:
ActionBarActivity cannot be resolved to a type MainActivity.java /TestProject/src/com/example/test line 7 Java Problem
ActionBarActivity cannot be resolved to a type MainActivity.java /TestProject/src/com/example/test line 11 Java Problem
ActionBarActivity cannot be resolved to a type MainActivity.java /TestProject/src/com/example/test line 31 Java Problem
error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'. styles.xml /TestProject/res/values-v14 line 8 Android AAPT Problem
error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'. styles.xml /TestProject/res/values line 7 Android AAPT Problem
error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'. styles.xml /TestProject/res/values-v11 line 7 Android AAPT Problem
R cannot be resolved to a variable MainActivity.java /TestProject/src/com/example/test line 12 Java Problem
R cannot be resolved to a variable MainActivity.java /TestProject/src/com/example/test line 18 Java Problem
R cannot be resolved to a variable MainActivity.java /TestProject/src/com/example/test line 28 Java Problem
The method getMenuInflater() is undefined for the type MainActivity MainActivity.java /TestProject/src/com/example/test line 18 Java Problem
The method onCreate(Bundle) of type MainActivity must override or implement a supertype method MainActivity.java /TestProject/src/com/example/test line 10 Java Problem
The method onCreateOptionsMenu(Menu) of type MainActivity must override or implement a supertype method MainActivity.java /TestProject/src/com/example/test line 16 Java Problem
The method onOptionsItemSelected(MenuItem) of type MainActivity must override or implement a supertype method MainActivity.java /TestProject/src/com/example/test line 23 Java Problem
@ridvanzoro Deleting the appcompat_v7 folder fixed the problem for new projects. I now can try to remove all of my old projects and import them. Thanks :)
您无需删除appcompat_v7,此文件夹中有不错的xml文件,动画,您可能需要使用它们。要从您的项目中更改或删除appcompat_v7文件夹,
Right click at project->Build Path->Configure Build Path->Lİbraries Tab->Android Dependencies
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句