Android Studio - processDebugResources failed

2019-07-20 09:35发布

问题:

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 ..

回答1:

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".



回答2:

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.



回答3:

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!



回答4:

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.



回答5:

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.



回答6:

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.



回答7:

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!



回答8:

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.



回答9:

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



回答10:

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.



回答11:

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']) }



回答12:

Use the latest version of Android Studio build tools.

compileSdkVersion 23 buildToolsVersion "23.0.2"



回答13:

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

applicationId "com.mypackagename"