【发布时间】:2017-07-21 22:00:31
【问题描述】:
我在 Intellij Idea 中使用 kotlin 实现了一个项目。这是没有错误的工作。这是我的 Intellij 项目照片,没有错误
但是当我在 Android Studio 中实现这个项目时,我得到了错误,因为工作室在 BigInteger 类中找不到这个方法
longValueExact()
Android Studio 项目照片:
我的计算机中有一个 JDK (v 1.8)。但在 Itellij 项目中,此方法有效,而在 android studio 中无效。
我在 android studio 中打开 java.math.BigInteger 类并看到 longValueExact() 方法:
open class AuthKey(val key: ByteArray) {
constructor(key: ByteBuffer) : this(key.array())
init {
if (key.size != 256)
throw RuntimeException("AuthKey must be 256 Bytes found ${key.size} bytes")
}
// see https://core.telegram.org/mtproto/description#key-identifier
// SHA1 generates 20 bytes long hash, authKeyId is the lower 8 bytes
val keyId = CryptoUtils.substring(CryptoUtils.SHA1(key), 12, 8)
fun getKeyIdAsLong() = BigInteger(keyId).longValueExact()
}
class TempAuthKey(key: ByteArray, val expiresAt: Int) : AuthKey(key)
这意味着我们在 java 1.8 中有这个类,我们在 android studio 中添加了这个。和 android studio 用外部库中的所有方法加载这个类。但是我们不能在项目类中使用这些方法!
谁能帮帮我?
【问题讨论】:
-
请添加代码而不是附加图像。
标签: java-8