Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switched to 0.10.3 and app crashes #151

Closed
rterek opened this issue May 10, 2016 · 6 comments
Closed

Switched to 0.10.3 and app crashes #151

rterek opened this issue May 10, 2016 · 6 comments

Comments

@rterek
Copy link

rterek commented May 10, 2016

I've had an app working for a couple of months, and recently have been using version 0.10.1. I just upgraded to 0.10.3 and rebuilt, ran on a Note 4 with Android 5.1.1, and I get a crash on init:

05-09 22:23:16.884 9534-9534/com.nothing.nothing E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.nothing.nothing, PID: 9534
java.lang.RuntimeException: Unable to instantiate service com.estimote.sdk.service.BeaconService: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.ContentResolver android.content.Context.getContentResolver()' on a null object reference
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3653)
at android.app.ActivityThread.access$2000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6872)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.ContentResolver android.content.Context.getContentResolver()' on a null object reference
at com.estimote.sdk.cloud.internal.AnalyticsManager.(AnalyticsManager.java:73)
at com.estimote.sdk.cloud.internal.AnalyticsManager.getInstance(AnalyticsManager.java:63)
at com.estimote.sdk.service.BeaconService.(BeaconService.java:248)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.Class.newInstance(Class.java:1690)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3650)
at android.app.ActivityThread.access$2000(ActivityThread.java:197) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:6872) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) 

Did I miss a memo? Do I need to change something in my code? I'm not doing anything with the cloud. . .

@martinklimek
Copy link

Hello @rterek ,

It sounds like there is an issue with Context provided during Estimote SDK initialisation. You should provide application context. Like here: EstimoteSDK.initialize(getApplicationContext(), "APP ID", "APP TOKEN");. Let me know if it helps!

@rterek
Copy link
Author

rterek commented May 10, 2016

But I need to init/start Estimote from an Android Service, so I have been doing:

public class MyService extends Service {
. . .
private BeaconManager beaconManager;
. . .
@OverRide
public void onCreate() {
Log.d(MyTag, "In onCreate");
beaconManager = new BeaconManager(this);
}

How can I deal with this moving forward? I'm building a library that is to be used by multiple apps, and I need a Service for control issues.

Thanks!

@pawelDylag
Copy link
Contributor

Hello @rterek!

There is no problem with that - Service itself extends ContextWrapper which extends Context. And as you might know, every Context holds reference to a singleton ApplicationContext which represents your basic app context, and which lasts for as long as your app is running. You can simply init Estimote SDK inside your Service by using EstimoteSDK.initialize(getApplicationContext(), "APP ID", "APP TOKEN");
The problem is with Analytics, which uses Context to gather data via ContentProviders. Soon we will release 10.4 with this problem fixed - so you don't need to worry about contexts. As for now, I suggest you to use this workaround :)

@rterek
Copy link
Author

rterek commented May 11, 2016

Thanks, got it - I think I was a bit bleary eyed last night when I was dealing with this issue. Cheers!

@pawelDylag
Copy link
Contributor

No problem, I forgive you :) Keep calm and wait for 0.10.4 with simplified contexts :)

@AjayDamco
Copy link

Hi All,
I am getting an error when I try to the get the Telemetry information in Xamarin estimote SDK-1.0.3 for android.
Xamarin estimote beaconManager.StartTelemetryDiscovery(); caused exception You need to initialize SDK first :java.lang.NullPointerException: You need to initialize SDK first. EstimoteSDK.initialize(applicationContext, appId, appToken)

But I unable to find any such initialize(applicationContext, appId, appToken) method in Xamarin Estimote SDK-1.0.3 in android.

Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants