gpt4 book ai didi

android - Android Kotlin 代码运行时出现 "Accessing hidden field"错误

转载 作者:行者123 更新时间:2023-12-02 12:52:44 25 4
gpt4 key购买 nike

我正在 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的“更新”功能的方式,它似乎奏效了。不知道到底是什么使它起作用。我首先检查它是否为零,或 !! 的不同处理

老的:
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 调用被挂起,因为我每天的写入操作配额已经结束。不知道为什么电话没有失败,而是挂了。我没有调用我的失败事件监听器。

最佳答案

检查我在 Firestore 中“写入操作”的每日配额状态导致了突破。由于配额超过,我的 Firestore 通话被挂起。甚至没有调用失败事件监听器。

现在我改为“按需付费”的计划,它似乎工作正常。

关于android - Android Kotlin 代码运行时出现 "Accessing hidden field"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58479331/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com