How To Resolve Package R Dose Not Exist Error In Android Studio is very important in android application development. It is used to identify all resources data such as id, layout, image, drawable resource etc. is generated by android studio automatically. But it is sometime confused for developer to use it. This article will help you to resolve these problems about you may encounter.

1. Where Saved At ? is commonly saved at directory like \Example\app\build\generated\source\r\debug\com\dev2qa\example\image.

android R class saved in local directory
You can also find it in android studio project view list like R class location in project view list

2. Why Can Not Find R Class In Android Studio ?

This is commonly because you select wrong sub view in project view. You can change project view’s sub view as following.

  1. Click ” View —> Tool Windows —> Project ” menu item in top menu bar.
    click android studio view tool windows project menu
  2. Above action will show project view in left panel. At left top in project view, there is a drop down list where you can choose project view’s sub view.
    android studio project view's sub view dropdown list
  3. Choose Project in sub view drop down list, then you can see all the folders under current project will be listed at below panel. You can find the R class in the directory tree also. If you choose other sub view, it will display different content of that sub view.

3. What Data Saved In ?

Double click file, it will display it’s content in right panel. The source code include a lot of int type variables, each int variable refer to one resource in current android application.

You can find there are some inner public static final classes defined in also , each inner class represent one kind of resource such as id, layout, string, color, drawable etc.

public static final inner class in

You do not need to care about those int variable and their values. And do not edit them also. If you change the value, you may encounter some strange error when build android project.

4. How To Resolve Package R Dose Not Exist Error ?

Sometimes you may encounter strange errors about R.class. Such as package R dost not exist, R can not be resolved as a type. You can fix these errors follow below steps.

android studio package R dose not exist error

  1. Click ” Build —> Clean Project ” or ” Build —> Rebuild Project ” in top menu bar in android studio. This will let android studio regenerate again. It will clean the cache and include all new added resources.
    android studio click menu build rebuild project
  2. If above method still do not take effect, you should check your AndroidManifest.xml file carefully. You need to make sure that the package value in AndroidManifest.xml root xml element match your activity package.
    AndroidManifest.xml package name not match activity package name
    In above picture, the manifest root xml element’s package value is com.dev2qa.example, and the launcher activity class is in package com.dev2qa.example.image. So change the package value, the error is resolved.
    change manifest package value to launcher activity package
  3. If the error still exist, you should check AndroidManifest.xml carefully to find the potential code that may generate the error. Or you can restart android studio or even computer 🙂
0 0 vote
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Comment
Oldest Most Voted
Inline Feedbacks
View all comments

I suffer from the R directory being non-existent after starting a new application. After the build to start the app, the R directory does not exist in Android Studio 3.2.1 or in the path, or in the actual folder where it is supposed to reside. How to get the R directory to build with the creation of a completely new application?

Would love your thoughts, please comment.x