9

Tôi nhận được lỗi này, khi tôi cố gắng sử dụng dự án thư viện trong Android Studio. Điểm mấu cụ thể trong build.gradle cung cấp cho lỗi này làPlugin có id 'com.android.library' không tìm thấy

apply plugin: 'com.android.library' 

Tôi thậm chí đã cố gắng thay đổi nó để

apply plugin: 'android-library' 

Bu nó vẫn không hoạt động, thay vào đó nó nói: Error:(7, 0) Plugin with id 'android-library' not found.

Tôi thậm chí đã cố gắng để thêm:

classpath 'com.android.tools.build:gradle:1.2.3.+' 

dưới sự phụ thuộc trong build.gradle, và vẫn không có gì ...

Bất kỳ trợ giúp nào?

EDIT: Toàn bộ build.gradle

// This buildscript will assemble the MoPub SDK into an AAR. 

repositories { 
    jcenter() 
} 

apply plugin: 'android-library' 

group = 'com.mopub' 

description = '''MoPub SDK''' 

android { 
    compileSdkVersion 22 
    buildToolsVersion '22.0.1' 

    defaultConfig { 
     versionCode 25 
     versionName "3.8.0" 
     minSdkVersion 9 
     targetSdkVersion 22 
     consumerProguardFiles 'proguard.txt' 
    } 

    sourceSets { 
     main { 
      manifest.srcFile 'AndroidManifest.xml' 
      java.srcDirs = ['src/main/java'] 
      resources.srcDirs = ['src/main/java'] 
      aidl.srcDirs = ['src/main'] 
      renderscript.srcDirs = ['src/main'] 
      res.srcDirs = ['res'] 
      assets.srcDirs = ['assets'] 
     } 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard.txt') 
     } 
    } 

    // Note: You will also need a local.properties file to set the location of the SDK in the same 
    // way that the existing SDK requires, using the sdk.dir property. 
    // Alternatively, you can set an environment variable called ANDROID_HOME. There is no 
    // difference between the two methods, you can use the one you prefer. 
} 

dependencies { 
    classpath 'com.android.tools.build:gradle:1.2.3.+' 
    compile 'com.android.support:support-v4:22.0.0' 
    compile 'com.android.support:support-annotations:22.0.0' 
    compile 'com.mopub.volley:mopub-volley:1.1.0' 
} 

// Don't run the Robolectric Unit Tests. 
check.dependsOn.remove("test") 
check.dependsOn.remove("unitTest") 
check.dependsOn.remove("testDebug") 
check.dependsOn.remove("unitTestDebug") 
+0

Post build.gradle trong thư mục gốc chính và build.gradle trong thư mục mô-đun. –

Trả lời

6

Bạn cần phải viết này:

apply plugin: 'com.android.application' 

Thay thế mã này trong tập tin của bạn quá:

buildscript { 
    repositories { 
     mavenCentral() // or jcenter() 
    } 

    dependencies { 
     classpath 'com.android.tools.build:gradle:1.2.3' // 1.3.0-beta2 
    } 
} 
+1

và bây giờ tôi nhận được điều này: Lỗi: (7, 0) Plugin có id 'com.android.application' không tìm thấy. – Borislav

+1

Tôi hy vọng bạn đang thêm vào build.gradle của ứng dụng, bạn cần chỉnh sửa trên toàn cầu. Tìm kiếm build.gradle khác trong dự án! @Borislav –

+0

Tôi đang chỉnh sửa tệp build.gradle nằm trong thư mục Gradle Scripts của dự án – Borislav

Các vấn đề liên quan