0

I have an import that cannot be resolved. I have renamed my package and the come example within the src file.

The name of my package is Time Calculator and the name of my com.example is com.example.TimeCalculator. I have renamed my androidmanifest and the XML file goes as this

<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.

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

[2013-04-23 18:19:38 - Time Calculator] Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties.

DorkMonstuh
  • 819
  • 2
  • 19
  • 38
  • Remove that import. You should not import `R`. – MAV Apr 23 '13 at 17:33
  • Have you tried to run the fix project properties command? – Bobbake4 Apr 23 '13 at 17:40
  • Hi Bobbake4 I was wondering how you would do this as this is the first time I am actually using eclipse – DorkMonstuh Apr 23 '13 at 17:42
  • You can right click on your project, open the "Android Tools" menu, click on "Fix Project Properties". Also take a look at the Stackoverflow question I posted below, may resolve your problem. – Bobbake4 Apr 23 '13 at 17:43

2 Answers2

3

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? 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. The import is still correct but you have to resolve the true problem which will exist somewhere in your res folder. Look for the problem listed in the "Problems" view inside of 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. Found '1.7' instead. Please use Android Tools > Fix Project Properties

Community
  • 1
  • 1
Bobbake4
  • 24,509
  • 9
  • 59
  • 94
1

as Bobbake4 said, I repeate it again, right click on your project folder, select Android Tools > Fix Project Properties, this will fix your problem. In fact, the problem caused by the builder was not set correctly, you can also update your jdk.

3h3
  • 722
  • 5
  • 6