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

No static method startForegroundService #1084

Closed
xiaolvzi opened this issue Aug 8, 2018 · 3 comments
Closed

No static method startForegroundService #1084

xiaolvzi opened this issue Aug 8, 2018 · 3 comments

Comments

@xiaolvzi
Copy link

xiaolvzi commented Aug 8, 2018

Hello, below is the error log:

08-08 11:33:26.681 17300-17321/com.pandaabc.stu E/AndroidRuntime: FATAL EXCEPTION: LeakCanary-Heap-Dump
    Process: com.pandaabc.stu, PID: 17300
    java.lang.NoSuchMethodError: No static method startForegroundService(Landroid/content/Context;Landroid/content/Intent;)V in class Landroid/support/v4/content/ContextCompat; or its super classes (declaration of 'android.support.v4.content.ContextCompat' appears in /data/app/com.pandaabc.stu-1/split_lib_dependencies_apk.apk)
        at com.squareup.leakcanary.internal.HeapAnalyzerService.runAnalysis(HeapAnalyzerService.java:49)
        at com.squareup.leakcanary.ServiceHeapDumpListener.analyze(ServiceHeapDumpListener.java:36)
        at com.squareup.leakcanary.RefWatcher.ensureGone(RefWatcher.java:156)
        at com.squareup.leakcanary.RefWatcher$1.run(RefWatcher.java:117)
        at com.squareup.leakcanary.AndroidWatchExecutor$3.run(AndroidWatchExecutor.java:79)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:135)
        at android.os.HandlerThread.run(HandlerThread.java:61)

This error crashed my app.

I did this :

//leakcanary
debugImplementation ('com.squareup.leakcanary:leakcanary-android:1.6.1'){
    exclude group: 'com.android.support'

}
releaseImplementation ('com.squareup.leakcanary:leakcanary-android-no-op:1.6.1'){
    exclude group: 'com.android.support'

}

Because there is some error in Manifest when I add the leakcanary dependency, I can't build sucessfully, so I exclude the com.android.support, below is the manifest merger error :

Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(25.4.0) from [com.android.support:preference-v7:25.4.0] AndroidManifest.xml:25:13-35

@JakeWharton
Copy link
Member

26.1.0 or newer is required. The support library stopped using manifest metadata for version tracking.

If you want to force all of the support libraries to the same version you can use this snippet: https://github.com/JakeWharton/SdkSearch/blob/e5c57c064c146edb0b863a0f3e2bba25fd2215a3/build.gradle#L155-L164. Use a version like 27.1.1 or 28.0.0-rc01. 25.x is years old. So is 26.x...

@xiaolvzi
Copy link
Author

xiaolvzi commented Aug 8, 2018

Hi @JakeWharton

Yes, after updating to 27.1.1, the error has gone.

So I can't use Leakcanary if I use 25.+??

@JakeWharton
Copy link
Member

JakeWharton commented Aug 8, 2018 via email

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

2 participants