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

Failing on Android 4.1 and 4.2 #10

Closed
safinahmed opened this issue Jul 17, 2013 · 8 comments
Closed

Failing on Android 4.1 and 4.2 #10

safinahmed opened this issue Jul 17, 2013 · 8 comments

Comments

@safinahmed
Copy link

I have successfully implemented you plugin on Android 2.7 using PhoneGap 2.7.0, but when testing in version 4.1 and 4.2 I get the following error

W/dalvikvm(1074): threadid=17: thread exiting with uncaught exception (group=0x40a71930)

Do you have any idea how I might fix this ?

I was able to pinpoint it to this call in the JS side app.service.enableTimer
But on the Java side, I have logging statement everywhere, and it doesn't show anything

Thanks in advance

@safinahmed
Copy link
Author

data.ServiceRunning was returning false the first time around for some reason, but now it's ok

@greips
Copy link

greips commented Aug 20, 2013

@safinahmed
I think I'm facing the same problem as you. Could you tell me how you solved it?

Thx :)

@safinahmed
Copy link
Author

Hey greips, I would, but all that happened was that I ran it once in debug mode (so I could pinpoint the error) and it started working from that point on
The first time around data.ServiceRunning was returning false as I mentioned (not sure why)
After that I tried debugging again and data.ServiceRunning was already returning true and everything started going smoothly

Sorry I couldn't be more helpful and good luck

@teusink
Copy link

teusink commented Aug 20, 2013

Maybe the service started bit to early in your scripts? (before Phonegap
was fully loaded?). Not sure, just guessing here :).

2013/8/20 safinahmed [email protected]

Hey greips, I would, but all that happened was that I ran it once in debug
mode (so I could pinpoint the error) and it started working from that point
on
The first time around data.ServiceRunning was returning false as I
mentioned (not sure why)
After that I tried debugging again and data.ServiceRunning was already
returning true and everything started going smoothly

Sorry I couldn't be more helpful and good luck


Reply to this email directly or view it on GitHubhttps://github.com//issues/10#issuecomment-22943023
.

www.teusink.org
www.droidpapers.org

@greips
Copy link

greips commented Aug 20, 2013

@safinahmed ok... i thought you just hack into the code.

@teusinkorg nice to see you here as well :P I put my code as a response in your opened issue for 2.8, and there you can see this sequence:
08-19 18:50:14.679: D/BackgroundServicePluginLogic(27704): Check if the service is running?
08-19 18:50:14.684: D/BackgroundServicePluginLogic(27704): Service is running?
08-19 18:50:14.699: D/BackgroundServicePluginLogic(27704): Exception - null
08-19 18:50:14.719: W/dalvikvm(27704): threadid=23: thread exiting with uncaught exception (group=0x4123a930)

so I guess the problem is related to the answer to the question "Service is running?" It might return null or something unexpected and then it crashes...

@teusink
Copy link

teusink commented Aug 20, 2013

@greips Hi :)

It fails on this command:
service.isServiceRunning()

This is the function:
private boolean isServiceRunning()
{
boolean result = false;

// Return Plugin with ServiceRunning true/ false
ActivityManager manager = (ActivityManager)this.mContext.getSystemService(
Context.ACTIVITY_SERVICE);
for (RunningServiceInfo service : manager.getRunningServices(Integer.
MAX_VALUE)) {
if (this.mServiceName.equals(service.service.getClassName())) {
result = true;
}
}
return result;
}
Source:
https://github.com/Red-Folder/Cordova-Plugin-BackgroundService-Source/blob/e904dfab1dd6ac7ba1f68a8809509c3758cd176a/src/com/red_folder/phonegap/plugin/backgroundservice/BackgroundServicePluginLogic.java

It is strange that the function would return null. As it boolean is
initialized with false. So I guess that it has to do something with either
ActivityManager or RunningServiceInfo (that is returning null), so it fails
within the function. As I do not suffer from this error I cannot test it
out.

Perhaps the developer knows.

2013/8/20 greips [email protected]

@safinahmed https://github.com/safinahmed ok... i thought you just hack
into the code.

@teusinkorg https://github.com/teusinkorg nice to see you here as well
:P I put my code as a response in your opened issue for 2.8, and there you
can see this sequence:
08-19 18:50:14.679: D/BackgroundServicePluginLogic(27704): Check if the
service is running?
08-19 18:50:14.684: D/BackgroundServicePluginLogic(27704): Service is
running?
08-19 18:50:14.699: D/BackgroundServicePluginLogic(27704): Exception - null
08-19 18:50:14.719: W/dalvikvm(27704): threadid=23: thread exiting with
uncaught exception (group=0x4123a930)

so I guess the problem is related to the answer to the question "Service
is running?" It might return null or something unexpected and then it
crashes...


Reply to this email directly or view it on GitHubhttps://github.com//issues/10#issuecomment-22943423
.

www.teusink.org
www.droidpapers.org

@greips
Copy link

greips commented Aug 20, 2013

@teusinkorg Actually i think it fails at line 151:

Log.d(TAG, "Service is running?");

EDITED:

Actually, looking at the code it might fail at the startService() when the bind is failed... That's the only difference I can see.

@Red-Folder
Copy link
Owner

It's the same issue as #7

I'm putting comments on that issue at it's got the logcat

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