Cannot build android project using Android Studio - Gradle 1.7

后端 未结 12 1206
抹茶落季
抹茶落季 2020-12-05 17:06

I\'m having lots of problems with Gradle and Android Studio.

Making changes in any resource in the project can randomly give an exception during compilation, this is

相关标签:
12条回答
  • 2020-12-05 17:41

    I ran into the same problem and issue was with my build directory, currently Android Studio supports directory path less than 100 characters.

    Found solution for this:

    In root build.gradle

    allprojects {
        buildDir = "/path/to/build/${rootProject.name}/${project.name}"
    }
    

    and docs https://gradle.org/docs/current/userguide/writing_build_scripts.html

    0 讨论(0)
  • 2020-12-05 17:44

    It has happened to me for an Activity declared in the manifest whose title was remove from the string file.

    This bug can be Anything related to resources. The best way to find the error is:

    1. Save your code.
    2. Return to the last commit that worked.
    3. Add your resources changes one by one until it fails again.
    0 讨论(0)
  • 2020-12-05 17:46

    I removed an accidentally added header in the menu xml:

    Remove this:

    <?xml version="1.0" encoding="utf-8"?>
    

    Leave this:

    <menu xmlns:android="http://schemas.android.com/apk/res/android" >
    
    0 讨论(0)
  • 2020-12-05 17:48

    I'm copying here my final update as an answer.

    It finally seems like i solved this issue cleaning up my resources, removing some unused XML and an unused theme. This obviously does not answer this question that i guess is of common interest.

    Navigating the web i found that AAPT is know to fail with SegFault11, and often it does not give any information about the real error which can be caused by:

    • Malformed Resources (Missing attributes, wrong tags, etc...)
    • +id in Styles
    • Duplicated resources / libraries
    • Declare-Styleable missing name
    • Resource missmatch, try to use different AAPT versions.
    • unknown, like mine So it would be useful to: 1. Find a way to identify the real cause of this error 2. Wait for an update to AAPT that returns some error message 3. Write a list of possible common causes.

    As Dale Cooper suggested, you could also try to run Lint and see if it finds any warning about resources.

    I'm trying to find links to users experiencing those other causes (It's been some time since the original question), i will update this answer when i'll find them back.

    0 讨论(0)
  • 2020-12-05 17:48

    I had this issue after importing the eclipse project. Issue was from my side. In eclipse, I put a png image in drawable which was actually a jpg image (I just renamed the extension from .jpg to .png). It was working fine with eclipse but was failing when imported to Android Studio.

    Execution failed for task ':app:mergeDebugResources'. Crunching Cruncher d.png failed

    I just deleted the d.png and added a original png file. It worked!

    0 讨论(0)
  • 2020-12-05 17:50

    I just had sort of the same problem, but on the processDebugResources step. After a couple of hours I started to try running diffrent verisons of aapt (/build-tools/[version]/aapt) and it turns out that they give one hell of different error messages. The one I was originally using was 19.0.1 which only gave me Segmentation fault but when i tried out 18.1.1 I was suddenly pointed to a line in a menu.xml which had a resource missmatch. The problem turns out to be that I hade removed the default @string/action_settings because I thought I didn't use it.

    Conclusion, trying different versions of aapt may help you find a resource missmatch.

    0 讨论(0)
提交回复
热议问题