0

I'm new at android development with eclipse, and when creating a new project i get two errors. One is in the src folder, main activity saying:

"R cannot be resolved to a variable"

And also in res folder, values, styles.xml:

" C:\Users\userName\workspace\test\res\values\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'."

I get the same error 3 times, one in values-v11 with appcompat.light andthe other with dark action bar. I really don't know what to do. i Feel stupid. Haven't even been able to test anything in my phone.

If you could help me with this, i'll be really thankful.

Here is some code:

package com.example.test;

import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}
 }

and in the styles.xml

 <resources>

    <!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
     -->
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level        can go here. -->
</style>

 </resources>

Also the manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.example.test"
   android:versionCode="1"
   android:versionName="1.0" >

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

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

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

   </manifest>

2 Answers2

2

First of all, I'll shed some light on the original issue You might not have added the appcompat library properly. There's an answer here

Second thing is; Eclipse is no longer a supported IDE for Android development. You should download Android Studio from the Android developer website at http://developer.android.com Its a lot easier to add this library in Android studio and continue work.

Community
  • 1
  • 1
Tharaka Devinda
  • 1,952
  • 21
  • 23
0

For me it was a problem with "junit test" packages l. After weeks i found that I just have to delete "junit test" packages and delete them from gradle file too. Then synced the project again and every thing worked well. You can delete junit test package from "app" tab in "project structure" setting. I hope it works for you too.