试图将模块添加到项目中。找不到ID为'kotlin-android'的插件

时间:2019-07-02 07:48:52

标签: android gradle module

我正在尝试将epub阅读器库添加到已经创建的项目中。我想作为一种方式添加到项目中的库是Folio Reader库(https://github.com/FolioReader/FolioReader-Android)。我已将此库下载到我的计算机上,并尝试通过文件->新建->导入模块将其添加。但是,在此过程中,我收到此错误:

ERROR: Plugin with id 'kotlin-android' not found.

此文件位于Folio Reader库的build.gradle文件中。

build.gradle文件:

apply plugin: 'com.android.library'
apply from: '../config/quality/quality.gradle'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

ext {
bintrayRepo = 'maven'
bintrayName = 'folioreader'

publishedGroupId = 'com.folioreader'
libraryName = 'FolioReader'
artifact = 'folioreader'

libraryDescription = 'An epub reader for Android'

siteUrl = 'https://github.com/FolioReader/FolioReader-Android'
gitUrl = 'https://github.com/FolioReader/FolioReader-Android.git'

libraryVersion = versions.folioreaderSdk

developerId = 'mobisystech'
developerName = 'Folio Reader'
developerEmail = 'mahavir@codetoart.com'

licenseName = 'FreeBSD License'
licenseUrl = 'https://en.wikipedia.org/wiki/FreeBSD_Documentation_License#License'
allLicenses = ["FreeBSD"]
}

android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion versions.androidCompileSdk

defaultConfig {
    minSdkVersion versions.androidMinSdk
    targetSdkVersion versions.androidTargetSdk
    versionCode versions.projectVersionCode
    versionName versions.projectVersionName
    vectorDrawables.useSupportLibrary = true
}

sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src/main/java']
        res.srcDirs = ['res']
    }
    test {
        java.srcDirs = ['src/test/java']
    }
}

packagingOptions {
    exclude 'META-INF/ASL2.0'
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
    exclude 'META-INF/services/javax.annotation.processing.Processor'
}

lintOptions {
    abortOnError false
    lintConfig file("lint.xml")
}

checkstyle {
    ignoreFailures = true
}
}

apply from: '../folioreader/bintray/installv1.gradle'
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')

implementation "androidx.appcompat:appcompat:$versions.appcompat"
implementation "androidx.constraintlayout:constraintlayout:$versions.constraintLayout"
implementation "androidx.recyclerview:recyclerview:$versions.recyclerview"
implementation "com.google.android.material:material:$versions.material"
testImplementation 'junit:junit:4.12'

implementation 'org.slf4j:slf4j-android:1.7.25'
implementation 'com.daimajia.swipelayout:library:1.2.0@aar'

//Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:$versions.kotlin"

implementation 'org.greenrobot:eventbus:3.1.1'

implementation "com.fasterxml.jackson.core:jackson-core:$versions.jackson"
implementation "com.fasterxml.jackson.core:jackson-annotations:$versions.jackson"
implementation "com.fasterxml.jackson.core:jackson-databind:$versions.jackson"
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:$versions.jackson"
implementation "com.google.code.gson:gson:$versions.gson"

implementation "com.squareup.retrofit2:retrofit:$versions.retrofit"
implementation "com.squareup.retrofit2:converter-jackson:$versions.retrofit"
implementation "com.squareup.retrofit2:converter-gson:$versions.retrofit"

// R2 modules
api("com.github.codetoart:r2-shared-kotlin:$versions.r2SharedKotlin") {
    changing = true
}
api("com.github.codetoart:r2-streamer-kotlin:$versions.r2StreamerKotlin") {
    exclude group: "org.slf4j", module: "slf4j-api"
    changing = true
}

// Only ReflectionUtils in Spring framework is used
implementation 'org.springframework:spring-core:4.3.19.RELEASE'

// Lifecycle
implementation "androidx.lifecycle:lifecycle- 
extensions:$versions.lifecycle"
}
apply from: '../folioreader/bintray/bintrayv1.gradle'

我已经尝试过这里发布的一些答案,但是它们不起作用。 我该如何解决这个问题?

编辑:

我添加了

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.4-3"

在我的依赖项中,并收到以下错误:

ERROR: Could not get unknown property 'versions' for object of type org.gradle.api.internal.plugins.DefaultExtraPropertiesExtension.

它发生在同一build.gradle文件的第20行:

libraryVersion = versions.folioreaderSdk

更新到新版本不起作用:

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.40"

2 个答案:

答案 0 :(得分:1)

查看Github上的库结构,看来您需要执行以下操作

  • 转到您的项目级别的build.gradle文件(而不是模块级别的build.gradle)
  • 查看库的project level build.gradle file中的存储库,依赖项,然后将其复制到您的项目级build.gradle文件(包括kotlin-gradle-plugin依赖项)

注意:如果以前没有使用过<div [ngClass]='myda.percentage.canceled |precntColors'> </div> 变量语法,则可以在root directory of the github repository中找到该库的那些变量。

在这种情况下,写

External

将解决以下问题(您可以在项目中直接编写)

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin"` 

答案 1 :(得分:0)

尽管这个问题有时间,但也许对于仍然需要解决此问题的人来说,我在项目的主“ build.gradle”文件中使用以下内容来解决它:

`allprojects {
    configurations.all {
        resolutionStrategy {
            cacheChangingModulesFor 0, 'seconds'
        }
    }
}`