androidkotlindependenciesmodifier

How can I fix this issue ; Cannot access '<init>': it is private in 'WifiUtils'


I have problem i tried to add an external library i found on github with no success, and had in error in Android Studio, Can someone Help me ?

package com.example.holobexchange

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.thanosfisherman.wifiutils.WifiUtils
class vip : AppCompatActivity() {









    override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_vip)

    var WifiUtils =  WifiUtils(this)









    }
}

Code snippet

error

Error in Android Studio


Solution

  • It looks like you are using this WiFi library. As per its documentation, the WiFi utils class is intended to be used as a factory. This means that instead of using a constructor, you can directly use the factory method:

    val wifiUtils = WifiUtils.withContext(getApplicationContext())