```* What went wrong: Execution failed for task ':...
# detekt
i
Copy code
* What went wrong:
Execution failed for task ':android:app:detekt'.
> java.lang.IllegalStateException: Analyzing /Users/user/StudioProjects/_work/rt-mlk-mobile-kmm/android/app/src/main/java/ru/rt/mlk/android/infrastructure/connectivity/AndroidConnectivityStatus.kt led to an exception. 
  The original exception message was: java.lang.IllegalArgumentException: Missing extension point: org.jetbrains.kotlin.com.intellij.treeCopyHandler in container org.jetbrains.kotlin.com.intellij.core.CoreApplicationEnvironment$1@14a4044f
  Running detekt '1.19.0' on Java '11.0.11+9' on OS 'Mac OS X'
  If the exception message does not help, please feel free to create an issue on our GitHub page.
Copy code
package ru.rt.mlk.android.infrastructure.connectivity

import android.content.Context
import android.net.ConnectivityManager
import android.net.Network
import android.util.Log
import ru.rt.mlk.shared.utils.network.ConnectivityStatus

class AndroidConnectivityStatus(private val context: Context) : ConnectivityStatus() {

    private val connectivityManager: ConnectivityManager? = null

    private val networkCallback = object : ConnectivityManager.NetworkCallback() {
        override fun onAvailable(network: Network) {
            Log.d("Connectivity status", "Connected")
            onNetworkAvailable()
        }

        override fun onLost(network: Network) {
            Log.d("Connectivity status", "Disconnected")
            onNetworkLost()
        }
    }

    override fun start() {
        try {
            val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
            connectivityManager.registerDefaultNetworkCallback(networkCallback)
        } catch (e: Exception) {
            Log.d("Connectivity status", "Failed to start: ${e.message.toString()}")
            e.printStackTrace()
            onNetworkLost()
        }
    }

    override fun stop() {
        connectivityManager?.unregisterNetworkCallback(networkCallback)
    }
}
Looks like all pretty usual, but somewhy detekt fails
b
Could you provide the full stacktrace? (running the same command with
--stacktrace
)
i
there are some mesh in output, but i think it is better to show you output as is
May it be consequence of compilation error? Somewhy app builds successful, but app targeted with api 21 and registerDefaultNetworkCallback works only from api 24. I’ve add implementation for lower api and detekt stop fails
b
Do this happens if you remove the formatting plugin from detekt? Could you try ktlint and see if it fails? It seems that the issue is there. Otherwise I think that you should create an issue in detekt to track this
i
i did not remove autocorrect plugin, but i’d disable autocorrect by comment the line
autoCorrect = true
and this helps
g
Small follow up. That’s a bug in Detekt. Should be fixed with this https://github.com/detekt/detekt/pull/4545