0

I'm trying do this https://github.com/mmoamenn/LuckyWheel_Android. But at the moment of compile the proyect this error appear throw the Title Error. i´ve try the add the vectors without the BitMapFactory, but without result...

MainActivity: The drawables are Vectors

package com.trustlyapps.drinkgame

import android.graphics.BitmapFactory
import android.graphics.Color
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.bluehomestudio.luckywheel.LuckyWheel
import com.bluehomestudio.luckywheel.WheelItem
class MainActivity : AppCompatActivity() {


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

    val luckywheel = findViewById<LuckyWheel>(R.id.luckywheel)

    val wheelItems: MutableList<WheelItem> = ArrayList()

    wheelItems.add(
        WheelItem(
            Color.LTGRAY,
            BitmapFactory.decodeResource(resources, R.drawable.ic_baseline_timer_24), "1"
        )
    )
    wheelItems.add(
        WheelItem(
            Color.BLUE,
            BitmapFactory.decodeResource(resources, R.drawable.ic_glass_shot_solid), "1"
        )
    )
    wheelItems.add(
        WheelItem(
            Color.BLACK,
            BitmapFactory.decodeResource(resources, R.drawable.ic_hand_yo_nunca), "1"
        )
    )
    wheelItems.add(
        WheelItem(
            Color.GRAY,
            BitmapFactory.decodeResource(resources, R.drawable.ic_host), "1"
        )
    )
    wheelItems.add(
        WheelItem(
            Color.RED,
            BitmapFactory.decodeResource(resources, R.drawable.ic_question_solid), "1"
        )
    )
    wheelItems.add(
        WheelItem(
            Color.BLACK,
            BitmapFactory.decodeResource(resources, R.drawable.ic_reload),
            "1"
        )
    )

    luckywheel?.addWheelItems(wheelItems)

    luckywheel?.setLuckyWheelReachTheTarget { }


   }}
Siniestre
  • 11
  • 2

1 Answers1

0

Vector drawables aren't bitmap images, so you can't decode them as bitmaps - that's why BitmapFactory is returning null.

There's some solutions here (I've linked to probably the simplest one!)

cactustictacs
  • 17,935
  • 2
  • 14
  • 25