I have a problem that Gradle can't find my dependency (Android support library).
My build.gradle looks like this:
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android'
dependencies {
    compile files('libs/FlurryAgent.jar')
    compile group: 'com.google.android', name: 'support-v4', version: 'r7'
    compile files('libs/YouTubeAndroidPlayerApi.jar')
}
android {
    compileSdkVersion 17
    buildToolsVersion "17"
    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 17
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
        instrumentTest.setRoot('tests')
    }
}
When I build (on commandline, no IDE) I get the following message:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'AndroidCalculator'.
> Failed to notify project evaluation listener.
   > Could not resolve all dependencies for configuration ':compile'.
      > Could not find com.google.android:support-v4:r7.
        Required by:
            :AndroidCalculator:unspecified
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Why am I not allowed to add the Android Support library like this?
Go to File > Project structure in Android Studio. Select the app module in the Modules list on the left. Select the Dependencies tab.
You have declared a repository dependency, but haven't declared a repository. Hence the dependency cannot be resolved. (Repositories/dependencies in the buildscript block are strictly separated from repositories/dependencies in the main build script.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With