Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Error in Android Studio

>Solution :

Welcome to Stackoverflow!

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())

PS: please edit your question to properly show the images and/or use a text code snippet.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading