“访问隐藏字段" Android Kotlin代码在运行时出现错误 [英] "Accessing hidden field" error coming at run time in Android Kotlin code

查看:771
本文介绍了“访问隐藏字段" Android Kotlin代码在运行时出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Android Studio上的Kotlin中构建一个Android应用程序.我正在将其连接到Firebase和Firestore.

I am building an Android App in Kotlin on Android Studio. I am connecting it to Firebase and Firestore.

不幸的是,曾经使用了一段时间的代码现在已经开始在运行时中断,并且出现了一些错误,这些错误看起来应该在编译时就被捕获了.

Unfortunately, a code that used to work a while back, has started breaking now at run time with set of errors that look like should have been caught at compile time.

我正在"Pixel XL API 29"仿真器上对其进行测试.我尝试删除一些代码块等以找出可能发生的情况,但是错误消失了,因为删除了一段很长时间以来我什至没有碰到的代码:

I am testing it on "Pixel XL API 29" emulator. I tried removing some blocks of codes etc. to figure out what could be happening, but the errors go away on removing some piece of code which I didn't even touch since quite some time:

db = FirebaseFirestore.getInstance()
val userData = hashMapOf(
    "user-id" to "theuserid",
    "language" to "hindi"
)

db.document("Data/Users/$userId").set(userData,SetOptions.merge())

(我在这里也有其他事件侦听器等.为了简洁起见,我省略了它.而且我知道这是一个可选代码.拥有或不拥有侦听器都无济于事.)

(I had other event listeners etc. too here. I have omitted it for brevity. And also that I know it's an optional code. Having or not having the listeners is not making difference.)

所以我想知道这是怎么回事.在执行应用程序时,执行甚至没有达到我最近更新的代码部分.

So I am wondering what's going on here. While executing the app, the execution is not even reaching the part of code that I was recently updating.

以下提到的错误.知道可能出什么问题了吗?

Mentioned below are the errors. Any idea what could be going wrong?

W/DynamiteModule: Local module descriptor class for providerinstaller not found.
I/DynamiteModule: Considering local module providerinstaller:0 and remote module providerinstaller:0
W/ProviderInstaller: Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
D/ApplicationLoaders: Returning zygote-cached class loader: /system/framework/android.hidl.base-V1.0-java.jar
    Returning zygote-cached class loader: /system/framework/android.hidl.manager-V1.0-java.jar
    Returning zygote-cached class loader: /system/framework/android.hidl.base-V1.0-java.jar
I/com.prash.pryst: The ClassLoaderContext is a special shared library.
I/chatty: uid=10133(com.prash.pryst) AsyncTask #1 identical 2 lines
I/com.prash.pryst: The ClassLoaderContext is a special shared library.
W/com.prash.pryst: Accessing hidden field Ldalvik/system/BaseDexClassLoader;->pathList:Ldalvik/system/DexPathList; (greylist, reflection, allowed)
    Accessing hidden field Ldalvik/system/DexPathList;->nativeLibraryDirectories:Ljava/util/List; (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden field Ldalvik/system/DexPathList;->systemNativeLibraryDirectories:Ljava/util/List; (greylist, reflection, allowed)
    Accessing hidden field Ldalvik/system/DexPathList;->nativeLibraryPathElements:[Ldalvik/system/DexPathList$NativeLibraryElement; (greylist, reflection, allowed)
    Accessing hidden method Ldalvik/system/DexPathList;->makePathElements(Ljava/util/List;)[Ldalvik/system/DexPathList$NativeLibraryElement; (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->arrayBaseOffset(Ljava/lang/Class;)I (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->copyMemory(JJJ)V (greylist, linking, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->objectFieldOffset(Ljava/lang/reflect/Field;)J (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->getByte(J)B (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->getByte(Ljava/lang/Object;J)B (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->getLong(J)J (greylist,core-platform-api, linking, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->putByte(JB)V (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->putByte(Ljava/lang/Object;JB)V (greylist,core-platform-api, linking, allowed)
V/NativeCrypto: Registering com/google/android/gms/org/conscrypt/NativeCrypto's 284 native methods...
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
W/com.prash.pryst: Accessing hidden field Ljava/nio/Buffer;->address:J (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Ljava/security/spec/ECParameterSpec;->getCurveName()Ljava/lang/String; (greylist, reflection, allowed)
I/ProviderInstaller: Installed default security provider GmsCore_OpenSSL
I/com.prash.pryst: Background young concurrent copying GC freed 30650(1701KB) AllocSpace objects, 0(0B) LOS objects, 19% free, 4294KB/5360KB, paused 1.123ms total 123.775ms
I/com.prash.pryst: Background concurrent copying GC freed 9816(280KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 6122KB/11MB, paused 5.428ms total 120.330ms
V/FA: Inactivity, disconnecting from the service
I/com.prash.pryst: Background young concurrent copying GC freed 81625(2972KB) AllocSpace objects, 1(188KB) LOS objects, 5% free, 11MB/11MB, paused 1.023ms total 204.780ms
W/com.prash.pryst: Accessing hidden field Ljava/net/Socket;->impl:Ljava/net/SocketImpl; (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden field Ljava/io/FileDescriptor;->descriptor:I (greylist, JNI, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/security/x509/AlgorithmId;->get(Ljava/lang/String;)Lsun/security/x509/AlgorithmId; (greylist, reflection, allowed)
    Accessing hidden method Lsun/security/x509/AlgorithmId;->getName()Ljava/lang/String; (greylist,core-platform-api, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Ljava/security/spec/ECParameterSpec;->setCurveName(Ljava/lang/String;)V (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Ldalvik/system/BlockGuard;->getThreadPolicy()Ldalvik/system/BlockGuard$Policy; (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Ldalvik/system/BlockGuard$Policy;->onNetwork()V (greylist, linking, allowed)
I/com.prash.pryst: Background young concurrent copying GC freed 144924(6470KB) AllocSpace objects, 2(136KB) LOS objects, 23% free, 13MB/16MB, paused 526us total 240.717ms



更新: 阅读评论后,我认为该问题可能超出了所显示的警告范围.我查看了线程转储,发现相当多的线程处于等待"状态,其中之一是Firestore线程.


Update: After reading the comments, I felt that the issue could be beyond the warnings that are shown. I looked at thread dump, and I see that quite a few threads are in "Waiting" state, and one of them is Firestore thread.

"FirestoreWorker@12477" daemon prio=5 tid=0x2ca nid=NA waiting
  java.lang.Thread.State: WAITING
      at sun.misc.Unsafe.park(Unsafe.java:-1)
      at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230)
      at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2109)
      at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1132)
      at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:849)
      at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1092)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
      at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(com.google.firebase:firebase-firestore@@21.2.0:224)
      at java.lang.Thread.run(Thread.java:919)

这可能是什么原因造成的?

What could be causing this?

更新2:可以解决

我正在尝试各种各样的东西,并更改了将"Long"参数传递给firestore的"update"功能的方式,这似乎奏效了.不确定究竟是什么使它起作用.我先检查它是否为零,或者对!!

I was trying various stuff, and changed the way I was passing "Long" parameter to "update" function of firestore, and it seems to have worked. Not sure exactly what made it work. Me checking for it to be zero first, or different handling of !!

旧:

db = FirebaseFirestore.getInstance()
batch = db.batch()
batch.update(
 db.document("sunday"), "checked-items",
 FieldValue.increment(itemTable["sunday"]?.checkedItems?.toLong()!!)
)
batch.commit()

新功能:

db = FirebaseFirestore.getInstance()
batch = db.batch()
if ( itemTable["sunday"]!!.checkedItems > 0 ) {
 batch.update(
 db.document("sunday"), "checked-items",
 FieldValue.increment(itemTable["sunday"]!!.checkedItems.toLong())
 )
}
batch.commit()

我应该将其发布为答案吗?

Should I post this as answer?

更新3:并且它不再起作用.

进行了一些微不足道的更改,例如添加日志事件等,然后再次中断.即使撤消所有更改,该错误也不会消失.我现在很确定,它与我对代码所做的更改无关.看了线程转储,这就是我现在所拥有的:

Made some trivial changes like adding log events etc and it broke again. Even after undoing all the changes the error is not going. I am quite sure now that it is not connected to the changes I am making to the code. looked at thread dump, and this is what I have now:

"FirestoreWorker@12487" daemon prio=5 tid=0x3de nid=NA waiting
  java.lang.Thread.State: WAITING
      at sun.misc.Unsafe.park(Unsafe.java:-1)
      at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230)
      at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2109)
      at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1132)
      at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:849)
      at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1092)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
      at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(com.google.firebase:firebase-firestore@@21.2.0:224)
      at java.lang.Thread.run(Thread.java:919)

以下是线程转储"屏幕的外观: https://photos.app.goo.gl/g5VEgK16RdJ7oCVj7

Here's how the Thread dump screen looks like: https://photos.app.goo.gl/g5VEgK16RdJ7oCVj7

这是运行"屏幕上的警告的样子

And this is how the warnings on the Run screen look like

W/com.prash.pryst: Accessing hidden field Ldalvik/system/BaseDexClassLoader;->pathList:Ldalvik/system/DexPathList; (greylist, reflection, allowed)
    Accessing hidden field Ldalvik/system/DexPathList;->nativeLibraryDirectories:Ljava/util/List; (greylist, reflection, allowed)
    Accessing hidden field Ldalvik/system/DexPathList;->systemNativeLibraryDirectories:Ljava/util/List; (greylist, reflection, allowed)
    Accessing hidden field Ldalvik/system/DexPathList;->nativeLibraryPathElements:[Ldalvik/system/DexPathList$NativeLibraryElement; (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Ldalvik/system/DexPathList;->makePathElements(Ljava/util/List;)[Ldalvik/system/DexPathList$NativeLibraryElement; (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->arrayBaseOffset(Ljava/lang/Class;)I (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->copyMemory(JJJ)V (greylist, linking, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->objectFieldOffset(Ljava/lang/reflect/Field;)J (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->getByte(J)B (greylist,core-platform-api, linking, allowed)
V/NativeCrypto: Registering com/google/android/gms/org/conscrypt/NativeCrypto's 284 native methods...
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->getByte(Ljava/lang/Object;J)B (greylist,core-platform-api, linking, allowed)
    Accessing hidden method Lsun/misc/Unsafe;->getLong(J)J (greylist,core-platform-api, linking, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->putByte(JB)V (greylist,core-platform-api, linking, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->putByte(Ljava/lang/Object;JB)V (greylist,core-platform-api, linking, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
W/com.prash.pryst: Accessing hidden field Ljava/nio/Buffer;->address:J (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Ljava/security/spec/ECParameterSpec;->getCurveName()Ljava/lang/String; (greylist, reflection, allowed)
I/ProviderInstaller: Installed default security provider GmsCore_OpenSSL
W/com.prash.pryst: Accessing hidden field Ljava/net/Socket;->impl:Ljava/net/SocketImpl; (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden field Ljava/io/FileDescriptor;->descriptor:I (greylist, JNI, allowed)
W/com.prash.pryst: Accessing hidden method Lsun/security/x509/AlgorithmId;->get(Ljava/lang/String;)Lsun/security/x509/AlgorithmId; (greylist, reflection, allowed)
    Accessing hidden method Lsun/security/x509/AlgorithmId;->getName()Ljava/lang/String; (greylist,core-platform-api, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Ljava/security/spec/ECParameterSpec;->setCurveName(Ljava/lang/String;)V (greylist, reflection, allowed)
W/com.prash.pryst: Accessing hidden method Ldalvik/system/BlockGuard;->getThreadPolicy()Ldalvik/system/BlockGuard$Policy; (greylist,core-platform-api, linking, allowed)
W/com.prash.pryst: Accessing hidden method Ldalvik/system/BlockGuard$Policy;->onNetwork()V (greylist, linking, allowed)
V/FA: Inactivity, disconnecting from the service


更新4:最终解决

因此,就像还有很多其他事情一样,此问题也与我所做的代码更改完全无关. Firestore的呼叫被挂起了,因为我的每日写操作配额已结束.不知道为什么通话没有失败,而是挂了.我没有调用我的Failure事件侦听器.

So, like how many of the other things turn out, this issue was also quite unrelated to the code changes I was making. Firestore calls were getting hung, because my daily quota of write operations had got over. Not sure why the calls were not failing, but were rather hung. I was not getting my Failure event listeners invoked.

推荐答案

在Firestore中检查我的每日写操作"配额的状态带来了突破.由于配额用完,我的Firestore通话被挂断了.即使失败事件侦听器也没有被调用.

Checking the status of my daily quotas of 'write operations' in Firestore led to the breakthrough. My Firestore calls were getting hung due to quota getting over. Even the failure event listeners were not being invoked.

现在,我更改为随用随付"计划,它似乎运行良好.

Now I changed to the plan of "pay as you go", and it seems to be working fine.

这篇关于“访问隐藏字段" Android Kotlin代码在运行时出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆