我已经为 Room 数据库添加了库。这是一个 androidX 库。我对库了解不多(我是初学者),也不了解 AndroidX。我得到了这些明显的合并错误,在重新寻找解决方案时,我发现了 AndroidX 库。所以我想将我的项目迁移到 AndroidX,但 Android Studio 无法解析这些库中的任何一个。我的构建gradle(应用程序):apply plugin: 'com.android.application'apply plugin: 'kotlin-android'apply plugin: 'kotlin-android-extensions'android { compileSdkVersion 28 defaultConfig { applicationId "com.financetracker.financetracker" minSdkVersion 15 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }}dependencies { def room_version = "2.1.0-alpha04" implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.0.0-beta01' implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01' implementation 'com.google.android.material:material:1.0.0-beta01' implementation 'androidx.constraintlayout:constraintlayout:1.1.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.1.0-alpha4' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4' implementation 'androidx.cardview:cardview:1.0.0-beta01' implementation "androidx.room:room-runtime:$room_version" annotationProcessor "androidx.room:room-compiler:$room_version"}我的构建 gradle(项目): buildscript { ext.kotlin_version = '1.3.21' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.3.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } }allprojects { repositories { google() jcenter() }}
2 回答
芜湖不芜
TA贡献1796条经验 获得超7个赞
尝试将这些添加到您的项目build.gradle文件中,
buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.google.com' }
mavenCentral()
}
...
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://maven.google.com' }
}
}
添加回答
举报
0/150
提交
取消