java导入工程出现问题

1.提示The import java.util cannot be resolved;

项目buildpath不对
与原来的项目,jdk不同。
换了之后原来的没了就导致了现在这种错误,基本的java.lang或
者util包都找不到。
解决方案:
右键项目----buildpath---Configure Build Path
选择libraries,添加一个jre;
选中项目----project----clean

2.The import android cannot be resolved错误怎么办

右键工程→Bulid Path→Configure Build Path...
选择Android,如图,在Project Build Target里面勾选相应的SDK即可

3.cannot be resolved or is not a field

setContentView(R.layout.activity_main)
提示信息是:activity_main cannot be resolved or is not a
field

删掉 import android.R;再选中项目----project----clean

4导入外部的class文件

方法一:右键src文件夹-》build path-》config build path-》library-》add exterdal class folder-》选择class文件所在的文件夹

(注意:当该文件夹被删除后,则class文件也被删除而导致出错)

方法二:右键src文件夹-》build path-》config build path-》library-》add class folder-》create new folder,此时在工程中会出现Referenced Librarier,在其中包含了你的新文件夹,同时在其下面出现了你的新文件夹,这时右键你的新文件夹-》import-》general-》file system-》选择你的class文件所在的文件夹-》勾选你的class文件-》ok了。这时你的class已经被导入到你的新文件夹中,你可删除之前的老文件夹。

原文地址:https://www.cnblogs.com/moon-lights/p/4776520.html