gpt4 book ai didi

android - 无法为 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 类型的对象获取未知属性 'androidx'

转载 作者:行者123 更新时间:2023-12-03 03:10:50 25 4
gpt4 key购买 nike

我正在尝试在下面的 YouTube 视频的帮助下构建一个位置跟踪器应用程序。
"https://www.youtube.com/watch?v=17HqLBkuX-E "
在 build.gradle 模块中,我已将 CardView 和 recyclerview 行替换为视频中的行,因为它们用红色下划线表示“根据 android 进行更改”。所以这些是我用于cardview和recyclerview的代码

androidx.cardview.widget.CardView
implementation 'androidx.recyclerview:recyclerview:1.0.0'

我已经改变了布局文件
<androidx.recyclerview.widget.RecyclerView
.
.
.
</androidx.recyclerview.widget.RecyclerView>

当我尝试同步它时,我遇到了上述错误。
这是我的布局文件
<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.recyclerview.widget.RecyclerView>

这是我的 build.gradle(Project:)
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
google()
jcenter()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.google.gms:google-services:4.2.0'

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

allprojects {
repositories {
google()
jcenter()
maven{
url "https://maven.google.com"
}
maven{
url "https://maven.fabric.io/public"
}

}
}

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


这是我的 buld.gradle(Module:app)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.locationtracker2019"
minSdkVersion 19
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'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

androidx.cardview.widget.CardView
implementation 'androidx.recyclerview:recyclerview:1.0.0'

implementation "com.google.firebase:firebase-database:10.2.0"
implementation "com.google.firebase:firebase-auth:10.2.0"
implementation "com.firebaseui:firebase-ui-auth:1.2.0"
implementation "com.firebaseui:firebase-ui-database:1.2.0"


implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

最佳答案

implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'



您还没有添加实现前缀。
你可以使用上面提到的。

关于android - 无法为 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 类型的对象获取未知属性 'androidx',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59475842/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com