用于信标的Roximity SDK崩溃

时间:2016-03-24 12:33:30

标签: android sdk proximity beacon

我的Roximity SDK不断崩溃,

这是我的Gradle:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':cropper')
compile project(':main')
compile project(':ROXIMITY_SDK_1_3_73')
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.code.gson:gson:2.2.4'
compile 'org.slf4j:slf4j-api:1.7.10'
compile 'com.google.android.gms:play-services-base:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'org.apache.httpcomponents:httpmime:4.5.2'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.android.support:appcompat-v7:23.1.1'

} 我的清单:

我根据文档页面上提到的说明http://docs.roximity.com/mobile/android/integration使用代码, 在onCreate:

ROXIMITYEngine.startEngineWithOptions(this.getApplicationContext(),  R.drawable.ic_launcher, null, this, null);
createBroadcastRecievers();

定义:

private void createBroadcastRecievers(){
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(ROXConsts.MESSAGE_FIRED);
    intentFilter.addAction(ROXConsts.BEACON_RANGE_UPDATE);
    intentFilter.addAction(ROXConsts.WEBHOOK_POSTED);

    LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, intentFilter);
}
private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        if(intent.getAction().equals(ROXConsts.MESSAGE_FIRED)) {
            MessageParcel messageParcel = (MessageParcel)intent.getParcelableExtra(ROXConsts.EXTRA_MESSAGE_PARCEL);
            handleMessageFired(messageParcel);
        } else if (intent.getAction().equals(ROXConsts.BEACON_RANGE_UPDATE)){
            String rangeJson = intent.getStringExtra(ROXConsts.EXTRA_RANGE_DATA);
            handleBeaconRangeUpdate(rangeJson);
        }
    }
};

现在它的行为非常奇怪。有时它根本没有检测到信标并发送空包作为响应。 有时会检测到信标几分钟,并且在一两次更新后大多会崩溃。 这是崩溃报告: 致命异议:主要                                                                             过程:

  

java.lang.NullPointerException:尝试从字段中读取' java.lang.String android.location.Location.mProvider'在null   对象参考                                                                                       在android.location.Location.set(Location.java:131)                                                                                       在android.location.Location。(Location.java:124)                                                                                       在com.roximity.sdk.location.RoxLocation。(RoxLocation.java:30)                                                                                       在com.roximity.sdk.actions.b.b(ActionManager.java:265)                                                                                       在com.roximity.sdk.actions.b.c(ActionManager.java:213)                                                                                       在com.roximity.sdk.beacons.c.c(RangingManager.java:169)                                                                                       在com.roximity.sdk.beacons.c.b(RangingManager.java:107)                                                                                       在com.roximity.sdk.beacons.c.a(RangingManager.java:84)                                                                                       在com.roximity.system.ble.d.j(BluetoothScanController.java:286)                                                                                       在com.roximity.system.ble.f.run(BluetoothScanController.java:257)                                                                                       在android.os.Handler.handleCallback(Handler.java:739)                                                                                       在android.os.Handler.dispatchMessage(Handler.java:95)                                                                                       在android.os.Looper.loop(Looper.java:145)                                                                                       在android.app.ActivityThread.main(ActivityThread.java:5835)                                                                                       at java.lang.reflect.Method.invoke(Native Method)                                                                                       在java.lang.reflect.Method.invoke(Method.java:372)                                                                                       在   com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1399)                                                                                       在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

我已经尝试了几乎所有可能的解决方案,它不是应用程序端的问题,也没有通过更改推荐的代码来解决。 任何解决方案将受到高度赞赏。

1 个答案:

答案 0 :(得分:1)

希望有所帮助的一些事情:

  • 我看到的最关注的事情是com.roximity.roximitysdkstarterkit.R.raw.roxstore来电中的第二个参数ROXIMITYEngine.startEngineWithOptions()。该文档将该参数描述为“将为通知显示的可绘制ID,例如R.drawable.ic_launcher”。将此参数替换为应用程序资源目录中drawable的id。
  • 从您的gradel依赖项看起来您可能正在使用不受支持的SDK版本 1.3.71 。与Google Play Services 8.4.0一起运行的最早支持的SDK版本为 1.3.73 。确保您使用受支持的.aar并将其正确链接到您的项目。
  • Android兼容性v7,用于支持较旧版本的Android,依赖性也似乎缺少您的gradel依赖项。请务必将compile 'appcompat-v7:23.1.1'添加到依赖项列表中。
  • 您正在编辑整个Google Play服务库的依赖项中也会出现这种情况,并且还包含各个模块的行,而这在技术上并不错误 - 您应该考虑仅导入所需的Google Play服务模块你编码。关于ROXIMITY v1.3.73 SDK,唯一需要的模块是; base,gcm和location。

修改

查看崩溃堆栈跟踪,当尝试从Location对象检索mProvider字段时,显示的错误是空引用。似乎这次崩溃是代码期望一个Location对象的结果,可能来自FusedLocationApi,而是接收null。也许对FusedLocationApi如何以及为什么可能返回null对象的一些研究将是您继续努力的好地方。

以下是一些可以帮助您入门的链接:

Why is FusedLocationApi.getLastLocation null

FusedLocationApi.getLastLocation always null