Android Studio - processDebugResources 失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21645961/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 04:52:23  来源:igfitidea点击:

Android Studio - processDebugResources failed

androidgradle

提问by Jorrex

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

所以我试图在 Android Studio 中构建我的项目,但是每次加载或执行该项目时,我都会收到以下错误。我不知道如何解决这个问题......

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

这是我的 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 ..

有没有人帮我解决?:/ 请记住,我是一个初学者,对 Android Studio 或 Gradle 不太了解..

采纳答案by Jorrex

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.

好吧,老实说:我修复它的方法是在执行系统恢复后重新安装 Android Studio。我的病毒扫描程序中断了 gradle.build,导致它每次都失败。

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.

所以我做了一个系统恢复到我没有安装很多东西的地步,再次重新安装了 Android Studio 并且它运行得很好。

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!

如果你仍然有这个,我认为这是由于很多不同的原因。祝你好运!

回答by VM4

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

如果在切换后发生这种情况以compileSdkVersion 21确保您使用buildToolsVersion "21.0.2"(或稍后),而不是"21.0.1".

回答by Scott Barta

You're hitting bug https://code.google.com/p/android/issues/detail?id=42752which 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=61308it's usually caused by a @stringreference in a menu.xmlfile to a string that doesn't exist. Give it a careful look and see if you can find one that's wrong.

您遇到了错误https://code.google.com/p/android/issues/detail?id=42752,即 Android 构建过程中的 AAPT 编译器在收到某些类型的错误输入时有时会崩溃。根据该错误报告以及https://code.google.com/p/android/issues/detail?id=61308,它通常是由menu.xml文件中对不存在的字符串的@string引用引起的。仔细看看,看看你是否能找到一个错误的。

回答by Gayan Pathirage

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;

导航到 android 文件夹并发出以下命令;

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!

希望这是有帮助的!

回答by Tim Rasim

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.

这个问题似乎很笼统。我的解决方案是重建项目(Build -> Rebuild),因为在问题发生之前,Android Studio 没有自动检测到我创建的资源。

回答by Farrukh Najmi

In my case I was using app:showAsActioninstead of android:showAsActionafter removing v4 and v7 compatibility libraries in my menu/*.xmlfile. Here is a sample diff:

在我的情况下,我在我的文件中删除了 v4 和 v7 兼容性库之后使用了app:showAsAction而不是。这是一个示例差异:android:showAsActionmenu/*.xml

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

这解决了我的问题。

回答by Diop Saliou Alpha

Updating your buildToolsVersionin your app's build.gradleshould fix your problem. Switching from '21.0.0' to '21.0.2'solved that problem for me.

更新您buildToolsVersion的应用程序build.gradle应该可以解决您的问题。从切换'21.0.0' to '21.0.2'为我解决了这个问题。

回答by Ran

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

使用--debug选项运行您的 gradle 构建并检查那里报告的错误。

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

要更改 Android Studio (1.3) 中的 gradle 选项,请转到file->settings->Build,Execution,Deployment->compiler并添加--debug命令行选项字段。

回答by Carose

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

我通过卸载并重新安装最新版本的 Android SDK Tools 和 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"

1) 打开 Android Studio 2) 转到 Tools-> Android -> SDK Manager 3) 选择“Launch Standalone SDK Manager 4) 取消全选 5) 选择最新的 Android SDK Tools 和 Android SDK Platform-tools。6) 点击“删除2 个软件包” 7) 现在您需要重新安装刚刚卸载的软件包。选择最新的 Android SDK Tools 和 Android SDK Platform-tools。8) 点击“安装 2 个软件包”

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

如果您在构建号上有其他错误,只需返回 Tools-> Android -> SDK Manager 选择“Launch Standalone SDK Manager install the build 您有错误。例如:如果您在构建 23.0.3 上收到错误,只需安装 Android SDK Buid-tools 23.0.3 更新到最新版本后即可

回答by Atef Farouk

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

在我的例子中,app build.gradle文件中的包名被错误地改变了:

applicationId "com.mypackagename"