1. Are you ready for the Galaxy S20? Here is everything we know so far!

The R.layout is giving an error

Discussion in 'Android Development' started by ExperiencedNewbie, Feb 8, 2016.

  1. ExperiencedNewbie

    Thread Starter

    It started yesterday.
    I was coding an app. I had completed the layout xml file and had started on the java file.
    After extending Activity and overriding he OnCreate method. I used setContentView. But when I enter R.layout.theXmlFile. The R is showing an error as "Cannot Resolve Symbol R". I googled a lot, cleaned, build and make the project but nothing seems to do it right.
    Help!!!!

    PS: I am using Android Studio.
     



    1. Download the Forums for Android™ app!


      Download

       
  2. Deleted User

    Deleted User Guest

    You have build problems somewhere in your project. Probably due to layout issues. Check your Gradle build window for errors.
     
    ExperiencedNewbie likes this.
  3. ExperiencedNewbie

    Thread Starter

    What are build problems? Is something wrong because I created layout first and the code??
     
  4. Deleted User

    Deleted User Guest

    Open the Gradle console window. If there are errors in building your project then they will be shown here. A successful build looks like this (see attached image).
    By 'build' I mean the process of compiling all your code, and assembling resources like images and icons into a package (.apk).
    The file 'R' is automatically generated during the build process. It's created based on the layouts you have defined. If there is one (or more) problems found in your layout files, the file will not be created, and your Java code will report unresolved symbols.

    android_build.png
     
    ExperiencedNewbie and Mikestony like this.
  5. ExperiencedNewbie

    Thread Starter

    Error:A problem occurred configuring project ':app'.
    > Could not resolve all dependencies for configuration ':app:_debugCompile'.
    > Could not find com.android.support:support-v4:22.2.0.
    Searched in the following locations:
    https://jcenter.bintray.com/com/android/support/support-v4/22.2.0/support-v4-22.2.0.pom
    https://jcenter.bintray.com/com/android/support/support-v4/22.2.0/support-v4-22.2.0.aar
    file:/C:/android setup/android-sdk/android-sdk/extras/android/m2repository/com/android/support/support-v4/22.2.0/support-v4-22.2.0.pom
    file:/C:/android setup/android-sdk/android-sdk/extras/android/m2repository/com/android/support/support-v4/22.2.0/support-v4-22.2.0.aar
    file:/C:/android setup/android-sdk/android-sdk/extras/google/m2repository/com/android/support/support-v4/22.2.0/support-v4-22.2.0.pom
    file:/C:/android setup/android-sdk/android-sdk/extras/google/m2repository/com/android/support/support-v4/22.2.0/support-v4-22.2.0.aar
    Required by:
    EMobStore:app:unspecified > com.android.support:appcompat-v7:21.0.3

    > Could not find com.android.support:support-v4:22.2.0.
    Searched in the following locations:
    https://jcenter.bintray.com/com/android/support/support-v4/22.2.0/support-v4-22.2.0.pom
    https://jcenter.bintray.com/com/android/support/support-v4/22.2.0/support-v4-22.2.0.aar
    file:/C:/android setup/android-sdk/android-sdk/extras/android/m2repository/com/android/support/support-v4/22.2.0/support-v4-22.2.0.pom
    file:/C:/android setup/android-sdk/android-sdk/extras/android/m2repository/com/android/support/support-v4/22.2.0/support-v4-22.2.0.aar
    file:/C:/android setup/android-sdk/android-sdk/extras/google/m2repository/com/android/support/support-v4/22.2.0/support-v4-22.2.0.pom
    file:/C:/android setup/android-sdk/android-sdk/extras/google/m2repository/com/android/support/support-v4/22.2.0/support-v4-22.2.0.aar
    Required by:
    EMobStore:app:unspecified > com.google.android.gms:play-services-appindexing:8.1.0 > com.google.android.gms:play-services-basement:8.1.0


    This is the error file. The bold is where it is showing error. What should I do??
     
Loading...
Similar Threads - layout giving error
  1. Bill_
    Replies:
    3
    Views:
    233
  2. Jason Edwardes
    Replies:
    0
    Views:
    185
  3. My project
    Replies:
    1
    Views:
    342
  4. Wesley Stark
    Replies:
    3
    Views:
    1,048
  5. 4EverNoob
    Replies:
    1
    Views:
    948
  6. thequeenscheese
    Replies:
    4
    Views:
    1,484
  7. workbench
    Replies:
    0
    Views:
    1,164
  8. App Update
    Replies:
    0
    Views:
    519
  9. KerenSophia
    Replies:
    1
    Views:
    1,097
  10. Armczbt
    Replies:
    0
    Views:
    1,615

Share This Page

Loading...