Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I resolve a "'generateDebugSources' not found in project" error?

I was trying to add a dependency to my application and I accidentally modified the wrong build.gradle file and now my application no longer builds correctly.

This is my error:

Error:FAILURE: Build failed with an exception.

* What went wrong:
Task 'generateDebugSources' not found in project ':app'.

* Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

I was trying to implement the code that exists here, but I ended up breaking things in Android Studio because I am new to the gradle system.

The files I edited were .idea/gradle.xml and build.gradle, which I am including below:

build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

gradle.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="GradleSettings">
    <option name="linkedExternalProjectsSettings">
      <GradleProjectSettings>
        <option name="distributionType" value="DEFAULT_WRAPPED" />
        <option name="externalProjectPath" value="$PROJECT_DIR$" />
        <option name="modules">
          <set>
            <option value="$PROJECT_DIR$" />
            <option value="$PROJECT_DIR$/app" />
          </set>
        </option>
      </GradleProjectSettings>
    </option>
  </component>
</project>

I was trying to get as close as the default files are, but ended up making the problem worse and I cannot build my project anymore.

Also, I am using Android Studio 1.1.0, which is shown to be the latest update.

Thanks in advance, and if I need to provide more information, just let me know.

like image 809
Steven Zahuranec Avatar asked Mar 29 '15 17:03

Steven Zahuranec


2 Answers

Not mentioned here, so maybe it can help some people. Got this error and solved it by doing a gradle sync (somehow, android studio was not suggesting it).

like image 68
Simon Ninon Avatar answered Sep 28 '22 01:09

Simon Ninon


In Android Studio menu: Go to File -> Invalidate caches / restart

IMPORTANT NOTE: Take into account that it will also clear "Local History" if it's important to you.

like image 25
Hanoch Moreno Avatar answered Sep 27 '22 23:09

Hanoch Moreno