[英]Could not get unknown property 'roomVersion' for root project 'RoomWordSample' of type org.gradle.api.Project
I am trying to learn about Android room from https://codelabs.developers.google.com/codelabs/android-room-with-a-view-kotlin/#3我正在尝试从https://codelabs.developers.google.com/codelabs/android-room-with-a-view-kotlin/#3了解 Android 房间
Fourth part is about updating Gradle files.第四部分是关于更新 Gradle 文件。 It gives several code snippets to include in
它提供了几个代码片段以包含在
build.gradle (Module: app)
build.gradle(模块:app)
I have included all the implementations, plugins etc mentioned on the page.我已经包含了页面上提到的所有实现、插件等。
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.testing.roomwordsample"
minSdkVersion 18
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/atomicfu.kotlin_module'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
// Room components
implementation "androidx.room:room-runtime:$rootProject.roomVersion"
kapt "androidx.room:room-compiler:$rootProject.roomVersion"
implementation "androidx.room:room-ktx:$rootProject.roomVersion"
androidTestImplementation "androidx.room:room-testing:$rootProject.roomVersion"
// Lifecycle components
implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.archLifecycleVersion"
kapt "androidx.lifecycle:lifecycle-compiler:$rootProject.archLifecycleVersion"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$rootProject.archLifecycleVersion"
// Kotlin components
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.coroutines"
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.coroutines"
// Material design
implementation "com.google.android.material:material:$rootProject.materialVersion"
// Testing
testImplementation 'junit:junit:4.12'
androidTestImplementation "androidx.arch.core:core-testing:$rootProject.coreTestingVersion"
}
ext {
roomVersion = '2.2.5'
archLifecycleVersion = '2.2.0'
coreTestingVersion = '2.1.0'
materialVersion = '1.1.0'
coroutines = '1.3.4'
}
But build has failed and gives this error.但是构建失败并给出了这个错误。
Could not get unknown property 'roomVersion' for root project 'RoomWordSample' of type org.gradle.api.Project.
无法为 org.gradle.api.Project 类型的根项目“RoomWordSample”获取未知属性“roomVersion”。
This is what build window is showing.这就是构建 window 显示的内容。 Error window
错误 window
Step 5 of the Codelab instructions indicate you should add the ext-block containing the version strings to the Project build.gradle
. Codelab 说明的第 5 步表明您应该将包含版本字符串的 ext 块添加到项目
build.gradle
中。 You added it to the app module build.gradle
.您已将其添加到应用程序模块
build.gradle
。
Cut this text from the app module build.gradle
and paste it into the project build.gradle
:从应用程序模块
build.gradle
中剪切此文本并将其粘贴到项目build.gradle
:
ext {
roomVersion = '2.2.5'
archLifecycleVersion = '2.2.0'
coreTestingVersion = '2.1.0'
materialVersion = '1.1.0'
coroutines = '1.3.4'
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.