Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio cannot find my resources

Android Studio cannot compile my test project, because it cannot resolve the resources. I tried some different settings for the res directory in the gradle.build, but nothing worked. Am I missing something simple here? It's a simple HelloWorld project with nothing individual in it.

I have the following project structure as it was created by the Android Studio wizard (newest release 0.2.5):

enter image description here

In my AndroidManifest.xml there is the usual app name reference: @string/app_name This string is defined in main/res/values/strings.xml (selected in the screenshot above).

The error I get from the IDE (Android Studio) is:

android-apt-compiler: [MyApplicationProject] C:\...\MyApplication\src\main\AndroidManifest.xml:6: error: 
Error: No resource found that matches the given name (at 'label' with value '@string/app_name').

The error I get from the command line when i run "gradle tasks" is:

A problem occurred configuring root project 'MyApplicationProject'.
 > Failed to notify project evaluation listener.
    > Main Manifest missing from C:\...\MyApplicationProject\src\main\AndroidManifest.xml
like image 953
muetzenflo Avatar asked Aug 20 '13 20:08

muetzenflo


People also ask

What is resource folder in Android?

The res/values folder is used to store the values for the resources that are used in many Android projects to include features of color, styles, dimensions etc.

How do I manage resources in Android?

Resource Manager is a tool window for importing, creating, managing, and using resources in your app. You can open the tool window by selecting View > Tool Windows > Resource Manager from the menu bar or by selecting Resource Manager on the left side bar. Click Add to add a new resource to your project.


1 Answers

Try add the following under defaultConfig (within android {...})

sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }
}
like image 95
powder366 Avatar answered Oct 10 '22 11:10

powder366