简体   繁体   中英

Android Studio. Top-level build.gradle

I downloaded Android Studio project. At the root of the project only one build.gradle with next structure:

apply plugin: 'com.android.library'

android {
}

dependencies {      
}

When I run build.gradle script I get the error:

Plugin with id 'com.android.library' not found.

I know that there must be another Top-level gradle file like this:

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

allprojects {
    repositories {
        jcenter()
    }
}

But it is not present. How can i add this build file? Or maybe another way to fix this problem?

The project was created in the old version of android studio . Perhaps he had worked for another way in old version? I am waiting for help. Thank you.

You have downloaded a single module (library).

You can use it in an Android Studio project building a structure like this.
Just create an empty new project and add your module.

root
|--build.gradle   //top level
|--settings.gradle   
|--mymodule       //your module downloaded
|----build.gradle   

In settings.gradle

include ':mymodule'

Just add the top level build.gradle content to the top of the downloaded projects' build.gradle. The project you downloaded is most likely being imported into another project, and thus does not need a top level build.gradle file as it will inherit it from the project it is imported into.

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

    allprojects {
        repositories {
            jcenter()
        }
    }

apply plugin: 'com.android.library'

android {
}

dependencies {      
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM