0

once i created file called: SettingsActivity.java it appear In every instance in all of my classes where i reference R.id.something the R is in red and it says "cannot resolve symbol R". The project however never fails to build and does work fine. It is just annoying to see this all the time. I have read many other questions on here about something similar but most involved importing projects from eclipse. I am using what i believe to be the most recent version of android studio "0.8.9" and the project was created with android studio and worked without any cannot resolve R problems.

i tryied to delete that file as well the error is gone but after a while it returns back, also i tryied to change Api level to 19 insted of 20 but the same is happening the error disappear instantely and return back. I would like to know what causes this if anyone knows. "butting in your mind that i didn't install all SDK files from the SDK manger".

getting that error in the Gradle Console:

[Fatal Error] :1:2: The markup in the document preceding the root element must be well-formed.

FAILED

FAILURE: Build failed with an exception.

  • What went wrong: A problem was found with the configuration of task ':app:generateDebugBuildConfig'.

    No value has been specified for property 'buildConfigPackageName'.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 3.74 secs

here is AndroidManifest.xml file it looks fine !! :

<?xml version="1.0" encoding="utf-8"?>
   <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.abdal_000.sunshine.app" >

<uses-permission android:name="android.permission.INTERNET" />

<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>
    <activity
        android:name=".DetailActivity"
        android:label="@string/title_activity_detail"
        android:parentActivityName=".MainActivity" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.abdal_000.sunshine.app.MainActivity" />
    </activity>

</application>

   </manifest>

3 Answers3

0

Try this: Project > Clean and clean your project.

Rajat Mehra
  • 1,462
  • 14
  • 19
  • when am trying to clean Project it give me the same error in the Gradle Consol ?!! – Abdallah omran Oct 27 '14 at 14:49
  • @Abdallahomran Is there any error on your xml files? Try to lint check everything on your resources and see if there's something wrong in it. – Vancert Staff Oct 27 '14 at 14:55
  • i checked all the file on my res directory my layout files is all fine, and my xml files is also fine but the problem is in AndroidMainfest.xml file, it generates some wrong codes and giving me an error when i remove them it also gives me another error – Abdallah omran Oct 27 '14 at 15:05
0

The error would occur if there is more than on Application or Manifest tag in your Android manifest file. So check if there is improper construction of your Android xml file.

Also if you have not mentioned your package name in your manifest file, add it in the file. You may also need to add in your build.gradle.

If everything looks fine, clean and build your project and the R.java file will be created with your new set of reerences.

BDRSuite
  • 1,594
  • 1
  • 10
  • 15
0

1.Fix the errors in your xml file.

2.Delete your R file.

3.Project -> Clean and select your project.

I think error in your XML file. Check all xml files. like redmark.

I am also facing same problem. finally I find the error in XML file.

stacktry
  • 324
  • 3
  • 24