18

So I'm trying to build my project in Android Studio, but each time the project has been loaded or been executed, I get the following error. I have no clue how to fix this ...

Execution failed for task ':oefening1:processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\Jorre\AppData\Local\Android\android-studio1\sdk\build-tools\android-        4.4.2\aapt.exe package -f --no-crunch -I C:\Users\Jorre\AppData\Local\Android\android-studio1\sdk\platforms\android-19\android.jar -M C:\Users\Jorre\Desktop\Android\Oefening\oefening1\build\manifests\debug\AndroidManifest.xml -S C:\Users\Jorre\Desktop\Android\Oefening\oefening1\build\res\all\debug -A C:\Users\Jorre\Desktop\Android\Oefening\oefening1\build\assets\debug -m -J C:\Users\Jorre\Desktop\Android\Oefening\oefening1\build\source\r\debug -F C:\Users\Jorre\Desktop\Android\Oefening\oefening1\build\libs\oefening1-debug.ap_ --debug-mode --custom-package be.verstraetejordy.oefening1
Error Code:    -1073741819

This is my build.gradle

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.1"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}

anyone got a solution for me? :/ Keep in mind that I'm a beginner and don't know much about Android Studio or Gradle ..

Jorrex
  • 1,503
  • 3
  • 13
  • 32

13 Answers13

18

If this is happenning to you after switching to compileSdkVersion 21 make sure you use buildToolsVersion "21.0.2" (or later), not "21.0.1".

Vishal Yadav
  • 3,642
  • 3
  • 25
  • 42
VM4
  • 6,321
  • 5
  • 37
  • 51
11

You're hitting bug https://code.google.com/p/android/issues/detail?id=42752 which is that the AAPT compiler in the Android build process sometimes crashes when it receives certain kinds of bad input. Based on that bug report and also https://code.google.com/p/android/issues/detail?id=61308 it's usually caused by a @string reference in a menu.xml file to a string that doesn't exist. Give it a careful look and see if you can find one that's wrong.

Scott Barta
  • 79,344
  • 24
  • 180
  • 163
  • 6
    I found my problem in menu.xml. I was taking out v7 support lib, but was still referencing it. The debug msg is pretty much useless, thanks Scott for pointing me in the right direction. – sudocoder Mar 14 '14 at 18:30
  • In my case, also same menu problem, Android Studio creates a sample menu file in `res/menu` folder automatically. – Youngjae Jun 11 '14 at 09:58
  • In my case, I was using appcompat themes and not using app:showAsAction attributes for menu items. – Binoy Babu Oct 18 '14 at 04:36
  • in my case it was due to special characters in my strins.xml file. for example ( ' and " ) – Imran Ahmed Jul 13 '15 at 20:25
  • Thanks, in my case I was missing an icon in the `res` folder, once I added it, all was well – William Nov 05 '15 at 11:41
7

As you may have already found, this error can be visible due to many reasons. Hence you need to find actual reason behind the error.

Navigate to android folder and issue below command;

gradlew.bat --info clean build 

OR

./gradlew --info clean build

This will list the actual issue, rectify that and redo the build.

Hope this is helpful!

Gayan Pathirage
  • 1,979
  • 1
  • 24
  • 21
  • 1
    This is the best solution because you see the actual error. The answer could also state that the gradlew.bat exist in every android app solution folder, e.g. the place that open when you right-click App and select "Show in Explorer". Successfully started process 'command 'C:\Users\fimatronn\AppData\Local\Android\Sdk\build-tools\23.0 .3\aapt.exe'' D:\VSProjects\Android\HelgaClient\app\build\intermediates\assets\debug\my erroneus filesname: error: In valid filename. Unable to add. :app:processDebugResources FAILED – Mathias Rönnlund Aug 17 '16 at 08:09
  • Oh my. I would have never figured this out. Apparently there was already an archived file in my application, but only after using your command I managed to figure that out. Thanks a lot! – Poul Kruijt Sep 09 '16 at 08:34
5

This problem seems to be pretty generic. My solution was to rebuild the project (Build -> Rebuild) since Android Studio hadn't automatically detected a resource I created before the problem occurred.

Tim Rasim
  • 655
  • 7
  • 20
3

In my case I was using app:showAsAction instead of android:showAsAction after removing v4 and v7 compatibility libraries in my menu/*.xml file. Here is a sample diff:

     <item android:id="@+id/action_calendar"
         android:title="Calendar"
         android:orderInCategory="100"
         android:icon="@drawable/calendar"
-        app:showAsAction="never" />
+        android:showAsAction="never" />

This solved my issue.

Kamran Ahmed
  • 7,661
  • 4
  • 30
  • 55
Farrukh Najmi
  • 5,055
  • 3
  • 35
  • 54
  • 1
    This also fixed my issue, but in the opposite direction. Adding xmlns:app="http://schemas.android.com/apk/res-auto" to the element and app:showAsAction instead of android:showAsAction on the elements got my build working again in Android Studio 0.8.1/Gradle plugin 0.12. – Andy Dyer Jul 03 '14 at 15:14
2

Updating your buildToolsVersion in your app's build.gradle should fix your problem. Switching from '21.0.0' to '21.0.2' solved that problem for me.

Vishal Yadav
  • 3,642
  • 3
  • 25
  • 42
1

Well, honestly: the way I fixed it was by reinstalling Android Studio after doing a System Recovery. My virus scanner was interrupting the gradle.build, causing it to fail every time.

So I did a System Recovery to the point where I didn't install a lot of stuff, reinstalled Android Studio again and it worked perfectly.

So there's no exact cause to this, just some shitty stuff with virus scanners.

If any on you still have this, I think it's due to a lot of different reasons. Good luck fixing yours!

Jorrex
  • 1,503
  • 3
  • 13
  • 32
1

Run your gradle build with --debug option and just check the error that is reported there.

To change the gradle options in Android studio (1.3), go to file->settings->Build,Execution,Deployment->compiler and add --debug in the command-line options field.

Ran
  • 1,089
  • 1
  • 12
  • 30
1

I solved this problem by uninstall and reinstall the latest version of Android SDK Tools and Android SDK Platform-tools.

1) Open Android Studio 2) Go to Tools-> Android -> SDK Manager 3) choose "Launch Standalone SDK Manager 4) deselect all 5) select the latest Android SDK Tools and Android SDK Platform-tools. 6) click on "delete 2 packages" 7) Now you need to reinstall the packages you just uninstalled. Select the latest Android SDK Tools and Android SDK Platform-tools. 8) click on "Install 2 packages"

If you have other error on build number just return on Tools-> Android -> SDK Manager choose "Launch Standalone SDK Manager install the build you have the error on it. Example: if you receive an error on build 23.0.3 just install Android SDK Buid-tools 23.0.3 After you can update it to the latest build

Carose
  • 11
  • 2
0

For me the issue was solved by removing references in AndroidManifest.xml to a theme that I had removed from themes.xml in res/values.

SeBsZ
  • 485
  • 4
  • 8
0

In my case I had a .jar dependency in app/src/main/assets after the import of my Eclipse project into Android Studio. I did the following:

  • I created a folder app/libs;
  • Moved the .jar into that folder;
  • Removed the app/src/main/assets folder (it was now empty);
  • Updated app/build.gradle by including the following at the bottom of the file:

    dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) }

Pieter van Ginkel
  • 29,160
  • 8
  • 71
  • 111
0

Use the latest version of Android Studio build tools.

compileSdkVersion 23 buildToolsVersion "23.0.2"

Nufail Achath
  • 58
  • 1
  • 7
  • Could you please provide more information on how your proposed solution helps? – Wtower Mar 06 '16 at 07:10
  • @ Wtower: In my case after updating android studio ,i faced this problem, so i changed the build version into latest, then remove the caches by using menu Files-> Invalidated Caches / Restart. for me its working. Thank you. – Nufail Achath Mar 06 '16 at 07:48
0

In my case the package name in app build.gradle file was changed by mistake:

applicationId "com.mypackagename"