How can I fix the error `` generateDebugSources not found in the project?

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

That's my fault:

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 tried to implement the code that exists here , but I ended up working in Android Studio because I am new to gradle.

The files I edited were .idea / gradle.xml and build.gradle, which I include 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 tried to get as many default files as possible, but ended up exacerbating the problem and I can no longer build my project.

In addition, I am using Android Studio 1.1.0, which is featured in the latest update.

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

+5
source share
8 answers

I fixed my problem; I found that the new projects did not have a problem with gradle, so I created a new project and transferred all my src code files and it works fine again.

-1
source

Check your .gradle settings. Your gradle module should be included in your .gradle settings.

 include ':app' 

You must change this include for the module name of your application. If not, try removing the included ones and restarting Android studio :)

+5
source

Not mentioned here, so maybe this can help some people. I got this error and solved it by synchronizing gradle (somehow, android studio did not offer it).

+1
source

I decided to restart it Android Studio.

+1
source

Had the same problem and fixed it by updating the latest version of the assembly:

 buildToolsVersion '24.0.1' 

OR

 buildToolsVersion '24' 
0
source

Chris Deligan got it partially correct.

Basically, you need to allow gradle dependencies so that Android Studio can correctly recognize that the generateDebugSources task really exists in yours :app (for me it was the other way around) I needed Android Studio for which generateDebugSources does not exist).

Running include ':app' did solve the problem for me, but that is because gradle did not resolve the dependency before. Running include ':app' and restoring the project helped, because Studio properly rebuilt these dependencies because of this. (Oh, and removing it also helps)

==================================================== ========================

Brief information -

Do what regenerates the dependencies. Ways to do it:

  • include :app - add or remove this from the gradle project file and rebuild.
  • gradle init - Running this from the terminal helped.
0
source

I had the same problem and, fortunately, I made a recent backup, and I realized that the build.gradle file is not in the application folder. I copied this back to my project under the name /AppName/app/build.gradle and the error went away.

 apply plugin: 'com.android.application' android { compileSdkVersion 25 buildToolsVersion "25.0.2" defaultConfig { applicationId "com.company.appname" minSdkVersion 15 targetSdkVersion 25 versionCode 25 versionName "2.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:25.1.0' compile project(':BaseGameUtils') compile 'com.google.android.gms:play-services:10.0.1' compile 'com.google.android.gms:play-services-plus:10.0.1' compile 'com.google.android.gms:play-services-ads:10.0.1' compile 'com.google.firebase:firebase-ads:10.0.1' } apply plugin: 'com.google.gms.google-services' 
0
source

From the Android Studio menu: Go to File β†’ Invalid Cache / Restart

IMPORTANT NOTE: Please note that it will also clear the β€œlocal history” if it matters to you.

0
source

Source: https://habr.com/ru/post/1216414/


All Articles