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
Chris Deligan got it partially right.
Basically, you need to resolve the gradle dependencies so that Android Studio can correctly recognize that a generateDebugSources
task does indeed exist in your :app
(For me it was the other way around - I needed Android Studio to recognize that generateDebugSources
does not exist).
Doing an include ':app'
did resolve the problem for me, but that's because gradle wasn't resolving the dependencies earlier properly for me. Doing an include ':app'
and rebuilding the project helped because Studio rebuilt those dependencies properly because of it. (Oh and removing it helps as well)
========================================================================
IN Brief -
Do something that re-generates the dependencies. Ways to do that are:
include :app
- Add or remove this from your project gradle file and do a rebuild.gradle init
- Running this from the terminal helped.I fixed my issue; I discovered that new projects didn't have the issue with the gradle, so I made a new project and transferred all my src code files and it works fine again.
Had the same problem and fixed it by updating TO latest build-tools version:
buildToolsVersion '24.0.1'
OR
buildToolsVersion '24'
I had this same issue and luckily I had made a recent backup and I figured out that the build.gradle file was missing from the App Folder. I copied that back into my project under the /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'
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.
I faced the same problem. This error occured because I unknowingly deleted the app build.gradle file ,so I created a new build.gradle file in my app directory and placed all the required code there then synced this file .The project successfully build after this.