Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.lang.RuntimeException:在类androidx.appcompat.widget.AppCompatImageView上发现名称isImportantForAccessibility的冲突获取程序_Java_Firebase_Google Cloud Firestore_Hashmap_Getter - Fatal编程技术网

java.lang.RuntimeException:在类androidx.appcompat.widget.AppCompatImageView上发现名称isImportantForAccessibility的冲突获取程序

java.lang.RuntimeException:在类androidx.appcompat.widget.AppCompatImageView上发现名称isImportantForAccessibility的冲突获取程序,java,firebase,google-cloud-firestore,hashmap,getter,Java,Firebase,Google Cloud Firestore,Hashmap,Getter,我想将图像保存到哈希映射中,以便在CartActivity中显示它,但它显示了此错误 2020-03-30 17:26:55.420 28869-28869/com.example.naturalmart E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.naturalmart, PID: 28869 java.lang.RuntimeException: Found conflicting getters

我想将图像保存到哈希映射中,以便在CartActivity中显示它,但它显示了此错误

2020-03-30 17:26:55.420 28869-28869/com.example.naturalmart E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.naturalmart, PID: 28869
    java.lang.RuntimeException: Found conflicting getters for name isImportantForAccessibility on class androidx.appcompat.widget.AppCompatImageView
        at com.google.firebase.firestore.util.CustomClassMapper$BeanMapper.<init>(com.google.firebase:firebase-firestore@@21.4.1:629)
        at com.google.firebase.firestore.util.CustomClassMapper.loadOrCreateBeanMapperForClass(com.google.firebase:firebase-firestore@@21.4.1:377)
        at com.google.firebase.firestore.util.CustomClassMapper.serialize(com.google.firebase:firebase-firestore@@21.4.1:177)
        at com.google.firebase.firestore.util.CustomClassMapper.serialize(com.google.firebase:firebase-firestore@@21.4.1:140)
        at com.google.firebase.firestore.util.CustomClassMapper.serialize(com.google.firebase:firebase-firestore@@21.4.1:104)
        at com.google.firebase.firestore.util.CustomClassMapper.convertToPlainJavaTypes(com.google.firebase:firebase-firestore@@21.4.1:78)
        at com.google.firebase.firestore.UserDataReader.convertAndParseDocumentData(com.google.firebase:firebase-firestore@@21.4.1:231)
        at com.google.firebase.firestore.UserDataReader.parseSetData(com.google.firebase:firebase-firestore@@21.4.1:75)
        at com.google.firebase.firestore.DocumentReference.set(com.google.firebase:firebase-firestore@@21.4.1:166)
        at com.google.firebase.firestore.DocumentReference.set(com.google.firebase:firebase-firestore@@21.4.1:146)
        at com.example.naturalmart.ProductDetailsActivity.addingToCartList(ProductDetailsActivity.java:200)
        at com.example.naturalmart.ProductDetailsActivity.access$300(ProductDetailsActivity.java:60)
        at com.example.naturalmart.ProductDetailsActivity$2.onClick(ProductDetailsActivity.java:124)
        at android.view.View.performClick(View.java:6319)
        at android.widget.TextView.performClick(TextView.java:11202)
        at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:967)
        at android.view.View$PerformClick.run(View.java:23995)
        at android.os.Handler.handleCallback(Handler.java:751)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6816)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1567)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1455)
我的Build.Gradle文件:

我的Build.Gradle文件是:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {

    compileSdkVersion 29
    buildToolsVersion "28.0.3"

    defaultConfig {
        applicationId "com.example.naturalmart"
        minSdkVersion 23
        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'
        }
    }
    compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.daimajia.slider:library:1.1.5@aar'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-analytics:17.2.3'
    implementation 'com.google.firebase:firebase-core:17.2.3'
    implementation 'com.google.firebase:firebase-database:19.2.1'
    implementation 'com.google.firebase:firebase-storage:19.1.1'
    implementation 'com.firebaseui:firebase-ui-database:3.2.2'
    implementation 'com.firebaseui:firebase-ui-firestore:6.2.1'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.github.firdausmaulan:GlideSlider:1.5.1'
    implementation 'net.steamcrafted:materialiconlib:1.1.5'
    implementation 'com.github.rey5137:material:1.2.5'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'io.paperdb:paperdb:2.6'
    implementation 'com.cepheuen.elegant-number-button:lib:1.0.2'
    implementation 'com.google.android.material:material:1.2.0-alpha02'
    implementation 'de.hdodenhof:circleimageview:3.1.0'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.navigation:navigation-fragment:2.2.1'
    implementation 'androidx.navigation:navigation-ui:2.2.1'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-firestore:21.4.1'
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'com.facebook.shimmer:shimmer:0.5.0'
    implementation 'io.reactivex.rxjava3:rxjava:3.0.1'
    api 'com.google.android.material:material:1.2.0-alpha05'
    implementation 'com.google.firebase:firebase-auth:19.3.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

问题来自这一行:

cartMap.put("image", productImage);
您已将
productImage
声明为:

private ImageView productImage;
而且不可能将
ImageView
保存到Firestore,因为Firestore只能包含列出的数据类型。您得到的错误是Firestore客户端表示它不知道如何处理您传入的类型



如果您想将图像数据本身存储在Firestore中,则必须将其存储起来。但现在更常见的是,将该图像的路径(或其下载URL)存储在Firestore中。

可能是您的
gradle.build
文件未正确配置为androidXAt,您收到了哪一行特定的代码错误?还请添加模型类的内容。我已经从firebase存储加载了此活动的图像,但我想在“添加到购物车Btn”上添加OnClick Listener,以将此特定产品的数据保存在Firestore文档中。我不确定这是什么意思。但我知道,您遇到的错误是由我在这里描述的内容引起的:您无法将
ImageView
字段写入数据库。我使用上载任务将一个活动中的图像上载到firebase存储中,然后在我的主产品活动中使用“model.getImage”方法显示该图像,现在我想显示一个活动的图像购物车活动中的特定产品这是一个用例。但是,如果您查看您的问题,您发布的例外情况是您试图将
ImageView
写入Firestore,这是不受支持的。要删除该异常,请删除此行
cartMap.put(“image”,productImage)
。放置位图后,如何从Firestore加载该位图。
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {

    compileSdkVersion 29
    buildToolsVersion "28.0.3"

    defaultConfig {
        applicationId "com.example.naturalmart"
        minSdkVersion 23
        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'
        }
    }
    compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.daimajia.slider:library:1.1.5@aar'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-analytics:17.2.3'
    implementation 'com.google.firebase:firebase-core:17.2.3'
    implementation 'com.google.firebase:firebase-database:19.2.1'
    implementation 'com.google.firebase:firebase-storage:19.1.1'
    implementation 'com.firebaseui:firebase-ui-database:3.2.2'
    implementation 'com.firebaseui:firebase-ui-firestore:6.2.1'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.github.firdausmaulan:GlideSlider:1.5.1'
    implementation 'net.steamcrafted:materialiconlib:1.1.5'
    implementation 'com.github.rey5137:material:1.2.5'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'io.paperdb:paperdb:2.6'
    implementation 'com.cepheuen.elegant-number-button:lib:1.0.2'
    implementation 'com.google.android.material:material:1.2.0-alpha02'
    implementation 'de.hdodenhof:circleimageview:3.1.0'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.navigation:navigation-fragment:2.2.1'
    implementation 'androidx.navigation:navigation-ui:2.2.1'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-firestore:21.4.1'
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'com.facebook.shimmer:shimmer:0.5.0'
    implementation 'io.reactivex.rxjava3:rxjava:3.0.1'
    api 'com.google.android.material:material:1.2.0-alpha05'
    implementation 'com.google.firebase:firebase-auth:19.3.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
cartMap.put("image", productImage);
private ImageView productImage;