0

i just started a little project in android studio debugging and everything was fine, but then about a hour ago, i got an error, that "R" can not be resolved, so i can't reference to my layouts anymore. I searched for help on the web and here on Stackoverflow, but no solution seemed to work for me. I tried Cleaning my Project but then i got this error during gradle building:

Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Admin\AppData\Local\Android\sdk\build-tools\23.0.2\aapt.exe'' finished with non-zero exit value 1

Does anyone know a solution to this? This never happened to me before and there's no need of linking me to an existing thread, because i've read all threads related to this topic on here and noone was able to help me. Thanks in advance

build gradle console: Executing tasks: [:app:assembleDebug]

Configuration on demand is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2311Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42311Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Admin\AppData\Local\Android\sdk\build-tools\23.0.2\aapt.exe'' finished with non-zero exit value 1

* 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: 1.51 secs
ImTwain
  • 11
  • 4
  • Look in the gradle console for build errors. Most likely there's a problem with one or more of the .xml files and aapt cannot compile the resources. If that doesn't provide a useful clue, try cleaning your project. – Ted Hopp Jan 24 '16 at 18:51
  • where's the gradle build console? if you mean the messages tab, i posted the error i got there in the OP and i already tried Cleaning my Project :/ – ImTwain Jan 24 '16 at 18:57
  • There should be a tab at the bottom right labeled "Gradle Console". If not, you can find it under the "View" menu at the top of the window. – Ted Hopp Jan 24 '16 at 18:59
  • this is the rror from the gradle console: FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:processDebugResources'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Admin\AppData\Local\Android\sdk\build-tools\23.0.2\aapt.exe'' finished with non-zero exit value 1 * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. – ImTwain Jan 24 '16 at 19:15
  • Look up further in the gradle console. There should be another message about what specifically caused aapt to exit with an error code. – Ted Hopp Jan 24 '16 at 19:53
  • I added the full Gradle Console code. – ImTwain Jan 24 '16 at 20:31
  • sure looks like a problem with the resources. If the editor shows no errors when you open each resource file in the editor, then make sure that all your resource files are named with only lower-case letters, numbers, and underscores. That could cause the problem. You might also try running gradle with the `--info` option. – Ted Hopp Jan 24 '16 at 20:50

1 Answers1

0

R can't be resolved in Android studio happened some reasons:

  1. When face any code problem in .xml file
  2. Any theme chosen/build problem in android manifest file

Solutions:

  1. Look, if you don't write any code in xml file then just click rebuild or make project button or clean button. Your problem may be solved.
  2. If you modify your xxxxx.xml layout file then look these files and I'm sure you've written some wrong code. Like theme name problem, any referencing problem of strings, dimens, colors and so on. Correct them and may be your R can't be resolved text will be solved. Obviously, after doing this click make project button and provably get no error..

My same problem of 2 is just given below: My styles.xml file was:

<style name="MyCustomToolbar" parent="ThemeOverlay.AppCompat.Light">
    <item name="colorPrimary">#5974AB</item>
</style>

And in xml file I've written that

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
....
android:popupTheme="@style/MyCustomToolber"
>

</android.support.v7.widget.Toolbar>

Look in xml

android:popupTheme="@style/MyCustomToolber"

I've typed wrong style name and so I got that error R can't be resolved.

Maniruzzaman Akash
  • 4,610
  • 1
  • 37
  • 34