Android Kotlin代码在运行时出现“访问隐藏字段”错误

时间:2019-10-21 03:10:34

标签: android firebase kotlin google-cloud-firestore

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

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

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

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

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

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

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

以下提到的错误。任何想法可能出什么问题吗?

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线程。

"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)

可能是什么原因造成的?


更新2:已设法解决

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

的不同处理

旧:

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()

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


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

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

"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

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

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事件侦听器。

1 个答案:

答案 0 :(得分:0)

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

现在,我更改为“随用随付”计划,它似乎运行良好。