android不喜欢.add-in firestore

bpzcxfmw  于 2021-09-13  发布在  Java
关注(0)|答案(1)|浏览(607)

因此,我试图将数据添加到firestore,由于某种原因,当应用程序到达.add所在的第95行时崩溃。
还有,我有 FirebaseFirestore db = FirebaseFirestore.getInstance(); 在代码的顶部,在类内部(oncreate之前),这样数据库就不会消亡。代码如下:

auth.createUserWithEmailAndPassword(RegisterEditTextEmail.getText().toString(), RegisterEditTextPassword.getText().toString())
                            .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                                @Override
                                public void onComplete(Task<AuthResult> task) {
                                    if(task.isComplete()){
                                        FirebaseUser user = auth.getCurrentUser();
                                        Map<String, Object> map = new HashMap<>();
                                        map.put("username", RegisterEditTextUsername);
                                        map.put("email", user.getEmail());
                                        map.put("uuid", user.getUid());
                                        map.put("description", "");
                                        db.collection("users")
                                                .add(map) // <------------HERE
                                                .addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
                                                    @Override
                                                    public void onSuccess(DocumentReference documentReference) {
                                                        Intent intent = new Intent(RegisterActivity.this, HomeActivity.class);
                                                        startActivity(intent);
                                                    }
                                                }).addOnFailureListener(new OnFailureListener() {
                                            @Override
                                            public void onFailure(@NonNull Exception e) {
                                                Toast.makeText(RegisterActivity.this, e.getMessage().toString(), Toast.LENGTH_LONG);
                                            }
                                        });
                                    }
                                }
                            });

现在是的,它正在创建一个帐户,并将帐户的其余数据放入firebase数据库,我知道这并不理想,但我不知道如何让auth也使用用户名之类的东西,所以现在就这样做(除非有人知道实现这一点的正确方法)。
但是现在,为什么android不喜欢这样呢?
以下是一些额外信息:logcat:

2021-07-26 17:48:47.290 7554-7554/? I/Zygote: seccomp disabled by setenforce 0
2021-07-26 17:48:47.292 7554-7554/? I/ample.create4m: Late-enabling -Xcheck:jni
2021-07-26 17:48:47.316 7554-7554/? E/ample.create4m: Unknown bits set in runtime_flags: 0x8000
2021-07-26 17:48:47.317 7554-7554/? W/ample.create4m: Unexpected CPU variant for X86 using defaults: x86
2021-07-26 17:48:48.055 7554-7554/com.example.create4me I/MultiDex: VM with version 2.1.0 has multidex support
2021-07-26 17:48:48.055 7554-7554/com.example.create4me I/MultiDex: Installing application
2021-07-26 17:48:48.055 7554-7554/com.example.create4me I/MultiDex: VM has multidex support, MultiDex support library is disabled.
2021-07-26 17:48:48.100 7554-7554/com.example.create4me I/FirebaseApp: Device unlocked: initializing all Firebase APIs for app [DEFAULT]
2021-07-26 17:48:48.142 7554-7585/com.example.create4me W/GooglePlayServicesUtil: Google Play Store is missing.
2021-07-26 17:48:48.165 7554-7554/com.example.create4me D/FirebaseAuth: Notifying id token listeners about user ( JKYcBvAKmuNDRhOIZ1RY4PfKWdj2 ).
2021-07-26 17:48:48.173 7554-7554/com.example.create4me I/FirebaseInitProvider: FirebaseApp initialization successful
2021-07-26 17:48:48.190 7554-7592/com.example.create4me D/libEGL: Emulator has host GPU support, qemu.gles is set to 1.
2021-07-26 17:48:48.189 7554-7554/com.example.create4me I/RenderThread: type=1400 audit(0.0:149): avc: denied { write } for name="property_service" dev="tmpfs" ino=9333 scontext=u:r:untrusted_app:s0:c101,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=1 app=com.example.create4me
2021-07-26 17:48:48.215 7554-7587/com.example.create4me I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to fallback implementation
2021-07-26 17:48:48.224 7554-7592/com.example.create4me D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
2021-07-26 17:48:48.227 7554-7592/com.example.create4me D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
2021-07-26 17:48:48.232 7554-7592/com.example.create4me D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
2021-07-26 17:48:48.425 7554-7554/com.example.create4me W/ample.create4m: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
2021-07-26 17:48:48.425 7554-7554/com.example.create4me W/ample.create4m: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
2021-07-26 17:48:48.787 7554-7590/com.example.create4me W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
2021-07-26 17:48:48.813 7554-7590/com.example.create4me D/EGL_emulation: eglCreateContext: 0xe1f1a3c0: maj 3 min 1 rcv 4
2021-07-26 17:48:48.887 7554-7590/com.example.create4me W/Gralloc3: mapper 3.x is not supported
2021-07-26 17:48:48.897 7554-7590/com.example.create4me E/eglCodecCommon: goldfish_dma_create_region: could not obtain fd to device! fd -1 errno=2
2021-07-26 17:48:49.245 7554-7554/com.example.create4me I/Choreographer: Skipped 31 frames!  The application may be doing too much work on its main thread.

“跑步”一词的意思是:

07/26 17:50:07: Launching 'app' on Genymobile Samsung Galaxy S10.
App restart successful without requiring a re-install.
$ adb shell am start -n "com.example.create4me/com.example.create4me.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 7492 on device 'genymobile-samsung_galaxy_s10-192.168.108.101:5555'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/MultiDex: VM with version 2.1.0 has multidex support
    Installing application
    VM has multidex support, MultiDex support library is disabled.
I/FirebaseApp: Device unlocked: initializing all Firebase APIs for app [DEFAULT]
W/GooglePlayServicesUtil: Google Play Store is missing.
D/FirebaseAuth: Notifying id token listeners about user ( JKYcBvAKmuNDRhOIZ1RY4PfKWdj2 ).
I/FirebaseInitProvider: FirebaseApp initialization successful
D/libEGL: Emulator has host GPU support, qemu.gles is set to 1.
I/RenderThread: type=1400 audit(0.0:147): avc: denied { write } for name="property_service" dev="tmpfs" ino=9333 scontext=u:r:untrusted_app:s0:c101,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=1 app=com.example.create4me
I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to fallback implementation
D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
W/ample.create4m: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
    Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
D/: HostConnection::get() New Host Connection established 0xe1f4c320, tid 7529
D/: HostComposition ext GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_1 
W/: Process pipe failed
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
D/EGL_emulation: eglCreateContext: 0xe1f1a3c0: maj 3 min 1 rcv 4
W/Gralloc3: mapper 3.x is not supported
D/: createUnique: call
D/: HostConnection::get() New Host Connection established 0xe1f4c460, tid 7529
D/: HostComposition ext GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_1 
E/eglCodecCommon: goldfish_dma_create_region: could not obtain fd to device! fd -1 errno=2
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@5d48787
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@97fc4d0
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
W/System: Ignoring header X-Firebase-Locale because its value was null.
D/FirebaseAuth: Notifying id token listeners about user ( JKYcBvAKmuNDRhOIZ1RY4PfKWdj2 ).
W/System: Ignoring header X-Firebase-Locale because its value was null.
W/GooglePlayServicesUtil: Google Play Store is missing.
E/GooglePlayServicesUtil: GooglePlayServices not available due to error 9
W/Firestore: (23.0.3) [GrpcCallProvider]: Failed to update ssl context: com.google.android.gms.common.GooglePlayServicesNotAvailableException
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.create4me, PID: 7492
    java.lang.RuntimeException: Found conflicting getters for name getText on class androidx.appcompat.widget.AppCompatEditText
        at com.google.firebase.firestore.util.CustomClassMapper$BeanMapper.<init>(CustomClassMapper.java:629)
        at com.google.firebase.firestore.util.CustomClassMapper.loadOrCreateBeanMapperForClass(CustomClassMapper.java:377)
        at com.google.firebase.firestore.util.CustomClassMapper.serialize(CustomClassMapper.java:177)
        at com.google.firebase.firestore.util.CustomClassMapper.serialize(CustomClassMapper.java:140)
        at com.google.firebase.firestore.util.CustomClassMapper.serialize(CustomClassMapper.java:104)
        at com.google.firebase.firestore.util.CustomClassMapper.convertToPlainJavaTypes(CustomClassMapper.java:78)
        at com.google.firebase.firestore.UserDataReader.convertAndParseDocumentData(UserDataReader.java:231)
        at com.google.firebase.firestore.UserDataReader.parseSetData(UserDataReader.java:75)
        at com.google.firebase.firestore.DocumentReference.set(DocumentReference.java:167)
        at com.google.firebase.firestore.DocumentReference.set(DocumentReference.java:147)
        at com.google.firebase.firestore.CollectionReference.add(CollectionReference.java:121)
        at com.example.create4me.RegisterActivity$1$1.onComplete(RegisterActivity.java:95)
        at com.google.android.gms.tasks.zzj.run(Unknown Source:4)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
I/Process: Sending signal. PID: 7492 SIG: 9
2g32fytz

2g32fytz1#

您将收到以下错误:
java.lang.runtimeexception:在类androidx.appcompat.widget.AppCompatedText上找到了名称gettext的冲突getter
因为您正在向Map添加以下值:

map.put("username", RegisterEditTextUsername);

这个 RegisterEditTextUsername 对象很可能是edittext,这样的对象无法添加到firestore。要解决此问题,请更改以上代码行:
致:

map.put("username", RegisterEditTextUsername.getText().toString());

相关问题