1

I know this question has been answered before but I checked them all and nothing worked.

I have a simple project that cannot resolve the R sign for some reason.

MainActivity Code

    public void onCreate(Bundle savedInstanceState)
        {   super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            editName = (EditText)findViewById(R.id.editname);
            editCode =(EditText)findViewById(R.id.editcode);
            bSearch=(Button)findViewById(R.id.bSearch);
}

activity_main File

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TextView android:text="Ελληνικά Προϊόντα"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAlignment="center"
        android:textSize="20dp"
        android:layout_marginBottom="10dp"/>
    <TextView android:text="Όνομα"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
    <EditText android:id="@+id/editname"
        android:inputType="number"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
    <TextView android:text="Κωδικός Προϊόντος"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
    <EditText android:id="@+id/editcode"
        android:inputType="number"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
    <Button   android:id="@+id/bSearch"
        android:text="Αναζητηση"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
</LinearLayout>

Android Manifest File

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.seth.greekproducts" >
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="GreekProducts"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" >
        <activity android:name=".MainActivity" >
        </activity>
    </application>
</manifest>

EDIT: at the error console I am getting:

Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner.Underlined'.

Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.

and dozens of similar errors.

EDIT: Build.Gradle

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}
Lambros Hitiris
  • 99
  • 1
  • 1
  • 8

3 Answers3

0

I think You got this error after cleaning the project.If you have errors on xml file it will show error on R.java. So,try to check your xml file has errors.

Prasanna
  • 195
  • 2
  • 16
0

Using Android Studio, what you have to do usually in this case is clicking on Sync Project with Gradle Files.

That's the icon on the top right of your screen, the 5th from the right.

Virthuss
  • 3,142
  • 1
  • 21
  • 39
0

Do the changes as below in modules's build.gradle, you have posted project build file in your query.

Gradle official documentation.

 android {
        compileSdkVersion 22
        buildToolsVersion "22.0.1"

        defaultConfig {
            applicationId "com.package"
            minSdkVersion 16
            targetSdkVersion 22
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }

    }

style.xml

<!--.......................................MyTheme......................................-->
    <style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
       <!-- Optionals..-->
        <item name="colorPrimary">@color/red_primary_color</item>
        <item name="colorPrimaryDark">@color/red_primary_color_dark</item>
        <item name="android:textColorHint">@color/red_placeholder_color</item>
        <item name="android:editTextStyle">@style/MaterialEditText</item>
    </style>
    <!--........................................................................................-->

Set the above theme in manifest.

Your compile SDK version must match the support library's major version.

Anoop M Maddasseri
  • 10,213
  • 3
  • 52
  • 73
  • Now it cant find AppCompatActivity and for some reason it can not sync. Anyway, I dont know why is it so difficult, espcially since I did not change anything from the project start, just the main_activity.xml. I am starting anew – Lambros Hitiris Nov 04 '15 at 09:51
  • https://www.google.co.in/search?q=hard+work+is+the+key+to+success&source=lnms&tbm=isch&sa=X&ved=0CAgQ_AUoAmoVChMI6POS7cH2yAIVAZmUCh3R6wyf&biw=1366&bih=696 – Anoop M Maddasseri Nov 04 '15 at 10:03