Vibhor Vibhuti
Vibhor Vibhuti

Reputation: 11

Cannot find R.layout.activity_main in main activity.java

I am developing an app, and have started working on main screen design but I am not able to test my app. When I want to test the app it suddenly stop all the time and error showing in catlog in the line

setContentView(R.layout.activity_main)

I have attached the screenshots in this question also.

main activity

Upvotes: 0

Views: 4320

Answers (4)

prog_student
prog_student

Reputation: 1

vibhor vibhoti -- your problem is that you are using ( view ) tag with v small in your activity_main.xml change it to ( View ) with Capital V .. that is the SOLUTION

Upvotes: 0

colens
colens

Reputation: 487

R.java is automatically generated on build, and it is automatically imported so you don't have to import it explicitly.

Try this:

  1. delete generated sub folder in your app folder since R.java is in one of its sub folders

enter image description here

  1. rebuild your project and generated folder will be generated again

Upvotes: 0

Skizo-ozᴉʞS ツ
Skizo-ozᴉʞS ツ

Reputation: 20626

I invite to you to clean project and rebuild again, you have the how to here.

And remove those imports that contains R in your project.

import vibhor.dev.eat24.R;

import vibhor.dev.eat24.R.layout;

I see you have this :

dependencies {
   classpath 'com.android.tools.build:gradle:3.0.1'
   classpath 'com.google.gms:google-services:3.1.0'
}

Change it to :

dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
}

This is problem of your library, take a look on this answer, try it, if it does not work.. just change the library.

Upvotes: 1

Aimée
Aimée

Reputation: 49

try that solution:

check that the import for R class is not import com.android.R;

and you should make it import yourpackagename.R, then recompile

if it works, your answer has already been replied here.

Upvotes: 0

Related Questions