我使用 kotlin 在 Intellij Idea 中实现了一个项目。这是没有错误的工作。这是我的 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)
Run Code Online (Sandbox Code Playgroud)
这意味着我们在 java 1.8 中有这个类,并且我们在 android studio 中添加了它。和 android studio 使用外部库中的所有方法加载此类。但我们不能在项目类中使用这些方法!
任何人都可以帮助我吗?
Android 有自己的java.whatever类实现,也可以有不同的接口,尤其是在最近的 Java 版本中添加的内容时。在https://developer.android.com/reference/java/math/BigInteger.html你可以看到即使是最新的 Android API (25) 也没有这个方法。因此,即使您成功编译了该程序,它也将无法在设备上实际运行。
外部<1.8>库不用于 Android 项目,如果您查看模块依赖项,您不应该看到它。
更新- 此方法和其他“值精确”方法已添加到 Android API 31 中。
| 归档时间: |
|
| 查看次数: |
1809 次 |
| 最近记录: |