Q:

Android kotlin - upload image with Volley error: Accidental override: The following declarations have the same JVM signature

fun UploadToServer(klein: Bitmap, mitte: Bitmap){

        val baos = ByteArrayOutputStream()
        klein.compress(Bitmap.CompressFormat.JPEG, 90, baos)
        val imageBytes = baos.toByteArray()
        val imageString = Base64.encodeToString(imageBytes, Base64.DEFAULT)

        val request = object:StringRequest(Request.Method.POST, "http://www.xxxx.com/uploadimage.php", object: Response.Listener<String> {
            override fun onResponse(response: String) {
                // Display the first 500 characters of the response string.
                Log.d("letsSee", "Success! JSON: " + response)
            }
        }, object: Response.ErrorListener {
            override fun onErrorResponse(volleyError:VolleyError) {
                Toast.makeText(this@UploadImage, "Some error occurred -> " + volleyError, Toast.LENGTH_LONG).show()
            }
        }) {
            protected val params:Map<String, String>

                @Throws(AuthFailureError::class)
                get() {
                    val parameters = HashMap<String, String>()
                    parameters.put("klein", imageString)
                    return parameters
                }

        }
        val rQueue = Volley.newRequestQueue(this@UploadImage)
        rQueue.add(request)

    }

What is this and what do I need to do here? I'm starting to regret using Kotlin even though Java is plain disgusting. Thanks in advance

A:

Use this instead:
override fun getParams(): MutableMap<String, String> {
    val parameters = HashMap<String, String>()
    parameters.put("klein", imageString)
    return parameters
}

Kotlin has two forms of the Map object: Map and MutableMap. MutableMap is equal to Java's Map, while Map is Kotlin's own thing.

