试图将模块添加到项目中.找不到Gradle DSL方法:"versionName()" [英] Trying to add module to project. Gradle DSL method not found: 'versionName()'

查看:405
本文介绍了试图将模块添加到项目中.找不到Gradle DSL方法:"versionName()"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to add a epub reader library to a project I have already created. The library I am trying to add to my project as a moduel is the Folio Reader Library (https://github.com/FolioReader/FolioReader-Android). I have downloaded this library on my computer and have tried adding it through File -> New -> Import Module. However, during the process I received countless errors. My current one is this:

Gradle DSL method not found: 'versionName()'
Possible causes:
The project 'FolioReader-Android-master' may be using a version of the 
Android Gradle plug-in that does not contain the method (e.g. 
'testCompile' was added in 1.1.0).
Upgrade plugin to version 3.4.1 and sync project

The project 'FolioReader-Android-master' may be using a version of Gradle 
 that does not contain the method.
Open Gradle wrapper file

The build file may be missing a Gradle plugin.
Apply Gradle plugin

此文件是为库声明依赖项的文件.

This file is the file where the dependencies are declared for the Library.

FolioReader-Android-master:

FolioReader-Android-master:

build.gradle file:

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

buildscript {
apply from: 'versions.gradle'

repositories {
    google()
    jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.4.1'


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

    //moj
    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
    classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.11"
    classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'



}
}

allprojects {

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

repositories {
    mavenLocal()
    google()
    jcenter()
    maven { url "https://jitpack.io" }
    }
}

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

错误本身指出,出现问题是因为项目使用的Gradle插件版本可能不包含该方法.我已将版本更新为最新版本,但是仍然收到此错误.关于如何解决这个问题有什么建议吗?

The error itself states that the problem arises because the project is using a version of the Gradle plug-in may not contain the method. I have updated the version to the newest one, however I still receive this error. Any suggestions on how I can solve this problem?

推荐答案

build.gradle

android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
    applicationId "your package name"
    minSdkVersion 18
    targetSdkVersion 28
    versionCode 1
// this is versionName
        versionName "1.0" 
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

这篇关于试图将模块添加到项目中.找不到Gradle DSL方法:"versionName()"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆