Search code examples
androidandroid-studiobuildbuild.gradlesample

Android samples' gradle files refer to a non-existent file


I've been trying to import and run the new Android samples, specifically ArchitectureComponentsBasic example. However, the gradle files refer to a file that has not been downloaded with the project.

In the app module's gradle file:

buildscript {
    apply from: '../versions.gradle' // <-- This file!
    addRepos(repositories)
    dependencies {
        classpath deps.android_gradle_plugin

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

the build script is applied from ../version.gradle file.

And in the project's gralde file:

android {
    compileSdkVersion build_versions.target_sdk
    buildToolsVersion build_versions.build_tools

..

dependencies {
    // Support libraries
    implementation deps.support.app_compat
    implementation deps.support.v4
    implementation deps.support.design

...

    androidTestImplementation deps.room.testing
    androidTestImplementation deps.arch_core.testing

    // Espresso UI Testing
    androidTestImplementation deps.espresso.core
    androidTestImplementation deps.espresso.contrib
    androidTestImplementation deps.espresso.intents

    // Resolve conflicts between main and test APK:
    androidTestImplementation deps.support.annotations
    androidTestImplementation deps.support.v4
    androidTestImplementation deps.support.app_compat
    androidTestImplementation deps.support.design
}

The versions are defined in a variable which is not in the file itself.

How do I get the file versions.gradle and run the sample project? Also will that resolve the undefined variables in the project's gradle file?


Solution

  • You did not download the entire repository, or you may have set your project up incorrectly. the ".." in ../version.gradle is telling the code to go up a folder in the file system.

    Here is the missing file. You may be able to just download it, and edit your gradle, or your might have to clone the whole project again.