• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Facing problem with code

I am facing a problem with my code. App wont build.

I am unable also to select an option from the drop down menu to select progress to complete code. All that is available is Gone
Pav.
Here is the code:
@RequiresApi(Build.VERSION_CODES.M)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val rollButton=findViewById<Button>(R.id.rollButton)
val resultsTextview=findViewById<TextView>(R.id.resultsTextView)
findViewById<SeekBar>(R.id.seekBar)

rollButton.setOnClickListener {

val rand=Random().nextInt(SeekBar.generateViewId())
resultsTextview.text=rand.toString()
}
 
IMG_20221120_061845224.jpg IMG_20221120_061758540.jpg
IMG_20221120_061845224.jpg
IMG_20221120_061758540.jpg
What's the building error message? Some screenshots?
Resource compilation failed. Failed to compile values. [But there are no errors]
 

Attachments

  • 146887-098dbbb24b6edb19ae19d9228664ee5c.jpg
    146887-098dbbb24b6edb19ae19d9228664ee5c.jpg
    4.9 KB · Views: 81
Last edited:
Hi, thanks for replying. I have checked the problems tab. It states there no problems with ide. I looked at the logcat. It says " Incorrectly called build layer on view. ShortcutAnd Widgetcontainer destroying layer. Does that ring any bells?

The code I was given. should allow me to select progress from the drop down menu, but I can only select, generate view id, or gone or pav. Do you think that is the cause?
 
It looks like there is a problem with the line findViewById<SeekBar>(R.id.seekBar), which is not being used in the rest of the code.

One possible solution would be to remove this line from the code, as it is not being used and is likely causing the build to fail.

Here is the revised code:

Code:
@RequiresApi(Build.VERSION_CODES.M)
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    val rollButton=findViewById<Button>(R.id.rollButton)
    val resultsTextview=findViewById<TextView>(R.id.resultsTextView)

    rollButton.setOnClickListener {
        val rand=Random().nextInt(SeekBar.generateViewId())
        resultsTextview.text=rand.toString()
    }
}

I hope this helps! Let me know if you have any questions.
 
Back
Top Bottom