后台-插件-广告管理-内容页广告位一(手机)

您现在的位置是:首页 > 开发类 > 移动开发移动开发

【错误记录】Android Studio 4.2.1 编译报错 ( Kotlin 版本推荐设置 1.5.0 )

2021-06-05 09:11:20移动开发人已围观

简介A problem occurred evaluating project ':app'.> org/jetbrains/kotlin/cli/common/PropertiesKt

文章目录

  • 一、报错信息
  • 二、解决方案





一、报错信息



将 Android Studio 版本升级成最新的 4.2.1 4.2.1 4.2.1 版本 , 出现如下错误 ;

在这里插入图片描述

Build file 'D:\project\workspace\MyApplication\app\build.gradle' line: 3

A problem occurred evaluating project ':app'.
> org/jetbrains/kotlin/cli/common/PropertiesKt

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'.

Caused by: java.lang.NoClassDefFoundError: org/jetbrains/kotlin/cli/common/PropertiesKt
	at org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper.apply(KotlinPluginWrapper.kt:72)
	at org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper.apply(KotlinPluginWrapper.kt:46)
	at org.gradle.api.internal.plugins.ImperativeOnlyPluginTarget.applyImperative(ImperativeOnlyPluginTarget.java:43)
	at org.gradle.api.internal.plugins.RuleBasedPluginTarget.applyImperative(RuleBasedPluginTarget.java:51)
	at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:177)
	at org.gradle.api.internal.plugins.DefaultPluginManager.access$100(DefaultPluginManager.java:51)
	at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:272)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:395)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:387)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:150)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:84)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
	at org.gradle.api.internal.plugins.DefaultPluginManager.lambda$doApply$0(DefaultPluginManager.java:157)
	at org.gradle.configuration.internal.DefaultUserCodeApplicationContext.apply(DefaultUserCodeApplicationContext.java:43)
	at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:156)
	at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:136)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:160)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:42)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:97)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:183)
	at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:49)
	at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.java:37)
	at org.gradle.api.Script$apply.callCurrent(Unknown Source)
	at build_4v59u06a4akwxz4coi4m1783q.run(D:\project\workspace\MyApplication\app\build.gradle:3)
	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
	... 126 mor




二、解决方案



这是由于 Android Studio 版本 , Kotlin 版本 , Gradle 版本 , Gradle 插件版本 , 不匹配导致 ;

如何知道当前的最合适版本 , 创建一个新的支持 Kotlin 的工程即可 ;

顶级 Project 构建脚本 build.gradle 如下 :

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = "1.5.0"
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.2.1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

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

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
    }
}

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

对应的 Gradle 版本配置 gradle-wrapper.properties 中配置脚本如下 :

#Wed Jun 02 14:21:29 CST 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

由上面的配置文件可知 , Android Studio 4.2.1 4.2.1 4.2.1 版本 , 对应的 Gradle 版本 6.7.1 6.7.1 6.7.1 , Gradle 插件版本 4.2.1 4.2.1 4.2.1 , Kotlin 版本 1.5.0 1.5.0 1.5.0 ;


这里将 Kotlin 版本设置成 1.5.0 1.5.0 1.5.0 , 发现编译完成 , 问题解决 ;

文章来源:https://blog.csdn.net/han1202012/article/details/117467378

Tags:androidstudio 

很赞哦! ()

后台-插件-广告管理-内容页广告位二(手机)

相关文章

后台-插件-广告管理-内容页广告位三(手机)
后台-插件-广告管理-内容页广告位四(手机)

文章评论

留言与评论(共有 0 条评论)
   
验证码:

本栏推荐

站点信息

  • 文章统计60050篇文章
  • 浏览统计4401次浏览
  • 评论统计1个评论
  • 标签管理标签云
  • 统计数据:统计代码
  • 微信公众号:扫描二维码,关注我们