簡體   English   中英

嘗試導入庫並最終找到ID為'com.android.application'的插件

[英]Tried importing a library and ended up with Plugin with id 'com.android.application' not found

我只是嘗試將庫導入到我的android項目中,並最終找到了這個Plugin with id 'com.android.application' not found. 錯誤。 我應該從jhlabs導入“ Filters.jar”文件,但不小心導入了另一個項目的“ gradle-wrapper.jar”。 我被困在這里,似乎沒有任何作用。 我也意外刪除了項目級別的build.gradle文件,其中包含以下代碼:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

    buildscript {

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


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

    allprojects {
        repositories {
            google()
            jcenter()
        }
    }

    task clean(type: Delete) {
        delete rootProject.buildDir
    }

我試圖按照此答案導入庫,

https://stackoverflow.com/a/35369267/9504498

我顯然搞砸了,我嘗試了許多解決方案,但沒有任何效果。 請幫我解決這個錯誤,我被困在這里。

如何獲得項目級別的build.gradle文件? 以及如何解決此Plugin with id 'com.android.application' not found.

任何幫助將不勝感激,謝謝。

您需要遵循可以從Android Studio創建的示例項目的結構,將build.gradle重新添加到項目中。

通常,項目結構如下:

app              -> (your app module)   
gradle  
build.gradle     ->  (project build.gradle)   
gradlew  
gradlew.bat  
local.properties   
settings.gradle

出現以下錯誤:

找不到ID為“ com.android.application”的插件。

是因為gradle在您的項目build.gradle中找不到插件,所以將以下代碼添加到您的項目 build.gradle中

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

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


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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

如@ daniel-nugent所說,要添加一個jar庫,請嘗試:

如何使用新的Gradle Android Build System手動包含外部aar包

嘗試了許多選項,但沒有任何效果,最后,創建了一個名稱與前一個相同的新項目,並指定了確切的程序包名稱,然后將前一個項目中的“ main”復制到了新項目中,並編輯了應用程序級別build.gradle從上一個項目復制,現在一切恢復正常。 將嘗試通過遵循@ daniel-nugent方法導入.jar庫。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM