'Kotlin "D/skia: --- Failed to create image decoder with message 'unimplemented'" Error preventing functionality of button at login/registration screen
Hello I am currently facing an issue with my Kotlin code in Android SDK. For the purposes of a small personal project I am trying to get a simple change password functionality working with a nodeJS file and mongoDB. However I've run into the issue while writting up some code to this end. It seems that my change_password function doesn't want to launch the sequence to input the new password due to the following error "D/skia: --- Failed to create image decoder with message 'unimplemented'" which is only visible in the debug mode. I am not even certain where to start debugging this issue, so I'm hoping someone here might be able to help. Bellow I have provided my MainActivity file where the change_password function is present. Additionally I have provided the xml layout files involved in these operations.
MainActivity File
import android.Manifest
import android.app.Activity
import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothDevice
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.Button
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import com.afollestad.materialdialogs.MaterialDialog
import com.example.accentus_login.R.id.*
import com.example.accentus_login.Retrofit.INodeJS
import com.example.accentus_login.Retrofit.RetrofitClient
import com.github.javiersantos.materialstyleddialogs.MaterialStyledDialog
import com.rengwuxian.materialedittext.MaterialEditText
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.home_page.*
import org.jetbrains.anko.toast
class MainActivity : AppCompatActivity() {
lateinit var myAPI: INodeJS
var compositeDisposable = CompositeDisposable()
var m_bluetoothAdapter: BluetoothAdapter? = null
lateinit var m_pairedDevices: Set<BluetoothDevice>
val REQUEST_ENABLE_BLUETOOTH=1
internal lateinit var change_pass_confirm_button: Button
companion object{
val EXTRA_ADDRESS: String = "Device_address"
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
//Init API
val retrofit = RetrofitClient.instance
myAPI = retrofit.create(INodeJS::class.java)
//m_bluetoothAdapter = BluetoothAdapter.getDefaultAdapter()
//if (m_bluetoothAdapter==null){
// toast("this device doesn't support bluetooth")
// return
//}
//if(!m_bluetoothAdapter!!.isEnabled) {
// val enableBluetoothIntent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
// if (ActivityCompat.checkSelfPermission(
// this,
// Manifest.permission.BLUETOOTH_CONNECT
// ) != PackageManager.PERMISSION_GRANTED
// ) {
// ActivityCompat.requestPermissions(
// this@MainActivity,
// arrayOf(Manifest.permission.BLUETOOTH, Manifest.permission.BLUETOOTH_ADMIN),REQUEST_ENABLE_BLUETOOTH)
// }
// startActivityForResult(enableBluetoothIntent, REQUEST_ENABLE_BLUETOOTH)
//}
//select_device_refresh.setOnClickListener{ pairedDeviceList() }
//change_pass_confirm_button = findViewById(R.id.change_pass_confirm_button);
login_button.setOnClickListener{
login(edt_email.text.toString(),edt_password.text.toString())
}
register_button.setOnClickListener{
register(edt_email.text.toString(),edt_password.text.toString())
}
change_pass_button.setOnClickListener{
change_password(edt_email.text.toString())
}
}
private fun login(email: String, password: String) {
compositeDisposable.add(myAPI.loginUser(email, password)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe{ message ->
if (message.contains("encrypted_password"))
Toast.makeText(this@MainActivity,"Login Successful",Toast.LENGTH_SHORT).show()
else
Toast.makeText(this@MainActivity,message,Toast.LENGTH_SHORT).show()
setContentView(R.layout.home_page);
})
}
private fun change_password(email: String) {
val change_pass_view = LayoutInflater.from(this@MainActivity)
.inflate(R.layout.change_pass, null)
MaterialStyledDialog.Builder(this@MainActivity)
.setTitle("Change Password")
.setDescription("Enter New Password")
.setCustomView(change_pass_view)
.setNegativeText("Cancel")
.onNegative { materialDialog: MaterialDialog -> materialDialog.dismiss() }
.setPositiveText("Confirm")
.onPositive { materialDialog: MaterialDialog ->
val password = change_pass_view.findViewById(R.id.new_pass) as MaterialEditText
//val con_password = change_pass_view.findViewById(R.id.con_new_pass) as MaterialEditText
if (password != password)
Toast.makeText(this@MainActivity, "Password Doesn't Match", Toast.LENGTH_SHORT)
.show()
else
compositeDisposable.add(myAPI.ChangePass(email, password)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { message ->
Toast.makeText(this@MainActivity, message, Toast.LENGTH_SHORT).show()
})
}
}
private fun register(email: String, password: String) {
val enter_name_view = LayoutInflater.from(this@MainActivity)
.inflate(R.layout.enter_name_layout,null)
MaterialStyledDialog.Builder(this@MainActivity)
.setTitle("Register")
.setDescription("Last Step: Enter your Name")
.setCustomView(enter_name_view)
.setIcon(R.drawable.ic_user)
.setNegativeText("Cancel")
.onNegative{ materialDialog: MaterialDialog-> materialDialog.dismiss() }
.setPositiveText("Register")
.onPositive { materialDialog: MaterialDialog ->
val edt_name = enter_name_view.findViewById<View>(edt_name) as MaterialEditText
compositeDisposable.add(myAPI.registerUser(email,edt_name.text.toString(), password)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe{ message ->
Toast.makeText(this@MainActivity,message,Toast.LENGTH_SHORT).show()
})
}.show()
}
private fun pairedDeviceList(){
if (ActivityCompat.checkSelfPermission(
this,
Manifest.permission.BLUETOOTH_CONNECT
) != PackageManager.PERMISSION_GRANTED
) {
ActivityCompat.requestPermissions(
this@MainActivity,
arrayOf(Manifest.permission.BLUETOOTH, Manifest.permission.BLUETOOTH_ADMIN),REQUEST_ENABLE_BLUETOOTH)
}
m_pairedDevices = m_bluetoothAdapter!!.bondedDevices
val list : ArrayList<BluetoothDevice> = ArrayList()
if(m_pairedDevices.isNotEmpty()) {
for(device : BluetoothDevice in m_pairedDevices) {
list.add(device)
Log.i("device", ""+device) // device logged as string
}
} else {
toast("no paired bluetooth devices found")
}
val adapter = ArrayAdapter(this,android.R.layout.simple_list_item_1,list)
select_device_list.adapter=adapter
select_device_list.onItemClickListener= AdapterView.OnItemClickListener{ _, _, position, _ ->
val device: BluetoothDevice= list[position]
val address: String = device.address
val intent = Intent(this, ControlActivity::class.java)
intent.putExtra(EXTRA_ADDRESS,address)
startActivity(intent)
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode==REQUEST_ENABLE_BLUETOOTH){
if(resultCode== Activity.RESULT_OK) {
if (m_bluetoothAdapter!!.isEnabled) {
toast("Bluetooth has been enabled")
} else {
toast("Bluetooth has been disabled")
}
} else if (resultCode == Activity.RESULT_CANCELED)
toast("Bluetooth enabling has been canceled")
}
}
override fun onStop() {
compositeDisposable.clear()
super.onStop()
}
override fun onDestroy() {
compositeDisposable.clear()
super.onDestroy()
}
XML Login Page
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/gradient_bg" tools:context=".MainActivity"> <LinearLayout android:layout_margin="16dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" > <TextView android:text="@string/accentus" android:textSize="30sp" android:textColor="@android:color/white" android:layout_gravity="center_horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <com.rengwuxian.materialedittext.MaterialEditText android:id="@+id/edt_email" android:hint="@string/email" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textEmailAddress" app:met_iconLeft="@drawable/ic_user" app:met_baseColor="@android:color/white" app:met_textColorHint="@android:color/white" app:met_primaryColor="@android:color/white" app:met_iconPadding="0dp"/> <com.rengwuxian.materialedittext.MaterialEditText android:id="@+id/edt_password" android:hint="@string/password" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textPassword" app:met_iconLeft="@drawable/ic_lock" app:met_baseColor="@android:color/white" app:met_textColorHint="@android:color/white" app:met_primaryColor="@android:color/white" app:met_iconPadding="0dp"/> <LinearLayout android:orientation="horizontal" android:weightSum="2" android:layout_width="match_parent" android:layout_height="wrap_content"> <com.google.android.material.button.MaterialButton android:id="@+id/register_button" android:text="@string/register_account" android:layout_marginEnd="8dp" android:textSize="11sp" style="@style/Widget.MaterialComponents.Button" android:layout_weight="1" android:layout_width="0dp" android:layout_height="wrap_content"> </com.google.android.material.button.MaterialButton> <com.google.android.material.button.MaterialButton android:id="@+id/login_button" android:text="@string/login" android:layout_marginStart="8dp" android:textSize="11sp" style="@style/Widget.MaterialComponents.Button.UnelevatedButton" android:layout_weight="1" android:layout_width="0dp" android:layout_height="wrap_content"> </com.google.android.material.button.MaterialButton> </LinearLayout> <LinearLayout android:orientation="horizontal" android:weightSum="2" android:layout_width="match_parent" android:layout_height="wrap_content"> <com.google.android.material.button.MaterialButton android:id="@+id/change_pass_button" android:text="@string/forgot_password" android:layout_marginStart="125dp" android:textSize="11sp" style="@style/Widget.MaterialComponents.Button.UnelevatedButton" android:layout_weight="1" android:layout_width="0dp" android:layout_height="wrap_content"> </com.google.android.material.button.MaterialButton> </LinearLayout> </LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout>
XML Change Password Page
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gradient_bg"
tools:context=".MainActivity">
<LinearLayout
android:layout_margin="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" >
<TextView
android:text="@string/change_password"
android:textSize="30sp"
android:textColor="@android:color/white"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/login_email"
android:hint="@string/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
app:met_baseColor="@android:color/white"
app:met_textColorHint="@android:color/white"
app:met_primaryColor="@android:color/white"
app:met_iconPadding="0dp"/>
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/new_pass"
android:hint="@string/new_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
app:met_baseColor="@android:color/white"
app:met_textColorHint="@android:color/white"
app:met_primaryColor="@android:color/white"
app:met_iconPadding="0dp"/>
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/con_new_pass"
android:hint="@string/confirm_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
app:met_iconLeft="@drawable/ic_lock"
app:met_baseColor="@android:color/white"
app:met_textColorHint="@android:color/white"
app:met_primaryColor="@android:color/white"
app:met_iconPadding="0dp"/>
<LinearLayout
android:orientation="horizontal"
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Please let me know if you think there is any other information necessary to understand why this is going on.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
