【发布时间】:2019-06-10 09:28:13
【问题描述】:
在 Android Studio (3.3.0) 的新更新之后,我从 Gradle 同步中收到错误消息“错误:原因:无效类型代码:68”。即使在项目中,它也是在更新之前创建的并且根本没有改变。 我尝试重新安装 Android Studio,但也没有帮助,所以肯定有一些与我的项目不兼容的东西,但它没有说明是什么以及为什么。
应用分级:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "cz.cubeit.cubeit"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
}
项目等级:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.11'
ext.anko_version='0.10.7'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
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()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
【问题讨论】:
-
您是否尝试过删除 .gradle 文件夹,然后“将项目与 Gradle 文件同步”+ clean + make。 Windows 中的文件夹位于 C:\Users\
\.gradle -
是的,我做到了,在这种情况下,即使删除“.idea”文件夹也无济于事,因为在创建新项目时也会发生这种情况
-
我在家用电脑上遇到了同样的问题,但在我的办公室电脑上一切都很好。我正在开发同一个项目,使用相同的 Gradle 包装器和相同的 AS 版本。
-
接受的这个答案的解决方案也适用于
cause: invalid type code: 4A
标签: java android android-studio kotlin