简体   繁体   English

导入com.example.TimeCalculator.R无法解析

[英]The import com.example.TimeCalculator.R cannot be resolved

I have an import that cannot be resolved. 我的导入无法解决。 I have renamed my package and the come example within the src file. 我已重命名我的包和src文件中的come示例。

The name of my package is Time Calculator and the name of my com.example is com.example.TimeCalculator. 我的包的名称是时间计算器,而我的com.example的名称是com.example.TimeCalculator。 I have renamed my androidmanifest and the XML file goes as this 我已重命名了androidmanifest,XML文件如下所示

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.TimeCalculator"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="15" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.TimeCalculator.MainActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

I am not sure why this import cannot be resolved, I basically just renamed a previous project. 我不确定为什么导入无法解决,我基本上只是重命名了以前的项目。 Sorry I am quite new to android and eclipse. 抱歉,我对android和eclipse很陌生。

import com.example.TimeCalculator.R;

This is the import that cannot be resolved. 这是无法解决的导入。

Just to add I get this error in the console at the bottom of eclipse 只是添加我在Eclipse底部的控制台中收到此错误

[2013-04-23 18:19:38 - Time Calculator] Android requires compiler compliance level 5.0 or 6.0. [2013-04-23 18:19:38-时间计算器] Android需要编译器符合级别5.0或6.0。 Found '1.7' instead. 发现“ 1.7”。 Please use Android Tools > Fix Project Properties. 请使用Android工具>修复项目属性。

That import should be used as it is the generated class that allows access to project resources such as strings and layouts. 应该使用该导入,因为它是生成的类,该类允许访问项目资源,例如字符串和布局。 The import not being resolved may be caused by many reasons. 导入未解决的原因可能有很多。 If you take a look in the gen folder and open the package matching your apps package name do you see the generated R class? 如果查看gen文件夹并打开与您的应用程序包名称匹配的包,您会看到生成的R类吗? If you do it means the project is building correctly and you might not have the correct fully qualified path in your import statement. 如果这样做,则意味着项目正在正确构建,并且导入语句中可能没有正确的标准路径。 If you do not see your R file in the gen folder that means for some reason your app is not compiling properly and thus not generating the R file. 如果您在gen文件夹中看不到R文件,则意味着由于某种原因,您的应用无法正确编译,因此无法生成R文件。 The import is still correct but you have to resolve the true problem which will exist somewhere in your res folder. 导入仍然正确,但是您必须解决在res文件夹中某个地方存在的真实问题。 Look for the problem listed in the "Problems" view inside of Eclipse. 查找Eclipse内部“问题”视图中列出的问题。

After your last edit you should take a look at this question already posted Android requires compiler compliance level 5.0 or 6.0. 上一次编辑后,您应该看看已经发布的这个问题。Android要求编译器符合级别为5.0或6.0。 Found '1.7' instead. 发现“ 1.7”。 Please use Android Tools > Fix Project Properties 请使用Android工具>修复项目属性

as Bobbake4 said, I repeate it again, right click on your project folder, select Android Tools > Fix Project Properties, this will fix your problem. 正如Bobbake4所说,我再次重复一遍,右键单击您的项目文件夹,选择“ Android工具”>“修复项目属性”,这将解决您的问题。 In fact, the problem caused by the builder was not set correctly, you can also update your jdk. 实际上,由构建器引起的问题未正确设置,您还可以更新jdk。

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

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