0

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.

Alex Moiseenkov
  • 49
  • 1
  • 10
  • There doesn't need to be two Gradle files. You have a single module Gradle project, but the Android library plugin just can't be found in the repository the project used – OneCricketeer Nov 24 '16 at 16:23
  • But what about the buildscript {} block where I configure the repositories and dependencies for Gradle. Where should I place it? Or is there another way to configure? – Alex Moiseenkov Nov 24 '16 at 16:57
  • Regularly, AS only includes the module's build.gradle when you start the CVS plugin. There is no hard science though. Just create it one level above your directory's structure. – Chisko Nov 24 '16 at 17:08
  • You say you downloaded a project. Where did you get it? That way, we can look at it – OneCricketeer Nov 24 '16 at 20:32
  • Possible duplicate of [Android Studio: Plugin with id 'android-library' not found](http://stackoverflow.com/questions/18153739/android-studio-plugin-with-id-android-library-not-found) – Chisko Nov 25 '16 at 00:34

2 Answers2

1

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'
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
-2

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 {      
}
Renier
  • 34
  • 2
  • 8
  • I don't understand what you're trying to say? My answer will allow his project to compile and suits his specific needs. – Renier Nov 24 '16 at 18:57