'Failed resolution of: Lcom/sun/net/httpserver/HttpServer when running AuthorizationCodeInstalledApp in android studio kotlin
i trying to make application with google calendar api and following google documentation. but I found this error and showed it to AuthorizationCodeInstalledApp function
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/sun/net/httpserver/HttpServer;
can someone tell me how this can happen and how to solve it? this is my code
@Throws(IOException::class)
private fun getCredentials(HTTP_TRANSPORT: NetHttpTransport): Credential? {
// Load client secrets.
val `in`: InputStream = assets.open(CREDENTIALS_FILE_PATH)
val clientSecrets =
GoogleClientSecrets.load(JSON_FACTORY, InputStreamReader(`in`))
// Build flow and trigger user authorization request.
val tokenFolder = File(
"${getExternalFilesDir(null)}${File.separator.toString() + TOKENS_DIRECTORY_PATH}"
)
if (!tokenFolder.exists()) {
tokenFolder.mkdirs()
}
val acct = GoogleSignIn.getLastSignedInAccount(this)
val username = acct?.id
val flow = (GoogleAuthorizationCodeFlow.Builder(
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES
)
.setDataStoreFactory(FileDataStoreFactory(tokenFolder))
.setAccessType("offline")).build()
val receiver = (LocalServerReceiver.Builder().setPort(8888)).build()
//returns an authorized Credential object.
return AuthorizationCodeInstalledApp(flow, receiver).authorize(username)
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
