使用解析android sdk抛出异常

ubbxdtey  于 2022-12-09  发布在  Android
关注(0)|答案(1)|浏览(140)

我尝试在我的应用中初始化Parse Android SDK,但每当我尝试保存对象解析时都会引发NullPointerException

06-27 15:22:54.643 25869-25869/glassstones.net.creche E/APP: java.lang.NullPointerException: value for name X-Parse-App-Display-Version == null

我在其他几个项目中使用过parse,但从来没有看到抛出这个异常。下面是我初始化Parse的方法:

ParseObject.registerSubclass(ParseMessage::class.java)
        val config = Parse.Configuration.Builder(context)
                .clientKey("")
                .applicationId(appId)
                .server(baseUrl)
                .build()
        Parse.setLogLevel(Parse.LOG_LEVEL_DEBUG)
        Parse.initialize(config)

这就是我保存对象的方式:

val message = ParseMessage()
        message.content = "Blah blah"
        message.saveInBackground {
            if (it == null) {
                Log.e("APP", "Good")
            } else {
                Log.e("APP", it.message)
            }
        }

相关性:

parseVersion = "1.17.3"
androidBuildToolsVersion = "27.0.3"
androidMinSdkVersion = 21
androidTargetSdkVersion = 27
androidCompileSdkVersion = 27
qhhrdooz

qhhrdooz1#

我在JAVA(而不是Kotlin)中遇到了同样的问题,并设法解决了它:
将de dependencies更改为最新版本的parse-community(我使用的是parse-android):

//    implementation 'com.parse:parse-android:1.16.3'
    implementation "com.github.parse-community.Parse-SDK-Android:parse:4.1.0"

与此问题有关:https://github.com/parse-community/Parse-SDK-Android/issues/1012
也许跟你在Kotlin发生的事有关。

相关问题