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

Fake ServiceInfo doesn't contain processName, causing LeakCanary failure #4090

Closed
Egorand opened this issue Nov 8, 2018 · 1 comment · Fixed by #4092
Closed

Fake ServiceInfo doesn't contain processName, causing LeakCanary failure #4090

Egorand opened this issue Nov 8, 2018 · 1 comment · Fixed by #4092
Milestone

Comments

@Egorand
Copy link

Egorand commented Nov 8, 2018

Description

Unit tests ran with RobolectricTestRunner fail with the following exception:

java.lang.NullPointerException
	at com.squareup.leakcanary.internal.LeakCanaryInternals.isInServiceProcess(LeakCanaryInternals.java:114)
	at com.squareup.leakcanary.LeakCanary.isInAnalyzerProcess(LeakCanary.java:182)
	at com.squareup.cash.CashApp.onCreate(CashApp.java:45)
        ...

The stack trace points to the following code in LeakCanary codebase:

ComponentName component = new ComponentName(context, serviceClass);
ServiceInfo serviceInfo;
try {
  serviceInfo = packageManager.getServiceInfo(component, 0);
} catch (PackageManager.NameNotFoundException ignored) {
  // Service is disabled.
  return false;
}

// this line causes the crash
if (serviceInfo.processName.equals(mainProcess)) {

Debugging shows that the value of processName is null.

Robolectric & Android Version

Robolectric: 4.0.1
Android: compileSdk = 28, targetSdk = 28, minSdk = 21

@Egorand
Copy link
Author

Egorand commented Nov 8, 2018

Happy to provide more info or create a project that reproduces the issue if needed.

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

Successfully merging a pull request may close this issue.

2 participants