我正在YouTube视频下面的帮助下构建位置跟踪器应用。 “ https://www.youtube.com/watch?v=17HqLBkuX-E” 在build.gradle模块中,我替换了CardView和recyclerview行,而不是视频中的行,因为它们用红色下划线表示“根据androix进行更改”。这些是我用于cardview和recyclerview的代码
def make_masks(trainloader,cam_dict):
masks=[]
print('start->', masks)
for idx, (img, target) in enumerate(trainloader):
if idx==10:
datapath = './datab2/gradcam_masks.h5py'
masks_tensor = np.asarray(masks)
print('maksks->',masks_tensor.shape)
with h5py.File(datapath, 'w') as hf:
hf.create_dataset('saliencys', data=masks)
break
torch_img, normed_torch_img = normalize_image(img.cuda())
for gradcam, gradcam_pp in cam_dict.values():
mask, _ = gradcam(normed_torch_img)
# print('mask->',mask.shape)
# mask = cv2.resize(mask[0], (224, 224))
mask = mask.squeeze()
# print('mask->',mask)
heatmap, result = visualize_cam(mask, torch_img)
# print('heatpmap->',heatmap.shape,'result->',result.shape)
# images.append(torch.stack([torch_img.squeeze().cpu(), heatmap, result], 0))
img = img.squeeze()
img = (img).permute(1, 2, 0)
print(mask.shape)
masks.append(mask)
if idx % 10000 == 0: print(idx, '/', trainloader.dataset.data.shape[0], '%')
并且我已经用
更改了布局文件androidx.cardview.widget.CardView
implementation 'androidx.recyclerview:recyclerview:1.0.0'
尝试同步该错误时,出现标题错误。 这是我的布局文件
<androidx.recyclerview.widget.RecyclerView
.
.
.
</androidx.recyclerview.widget.RecyclerView>
这是我的build.gradle(Project:)
<?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>
这是我的buld.gradle(Module:app)
// 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
}
答案 0 :(得分:1)
从应用程序gradle文件中删除行androidx.cardview.widget.CardView
(在依赖关系中)
答案 1 :(得分:1)
实现'androidx.recyclerview:recyclerview:1.0.0'
实现'androidx.cardview:cardview:1.0.0'
您尚未添加实现前缀。 您可以如上所述使用。