What doesn't my code that works here work in Android Studio? | Sololearn: Learn to code for FREE!

+1

What doesn't my code that works here work in Android Studio?

can anyone help me with this? I wrote this code here, and it worked, but when I try and transfer the same code to AS, it doesn't work. I think I must be missing something quite fundamental, but I don't know what. Any help would be much appreciated. My code is below. Many thanks. import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import kotlinx.android.synthetic.main.activity_ceaser_bit.* class CeaserBit : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_ceaser_bit) val s = readLine(textInputEditText) println(message = "The original mmessage is: $s."); var message = "" var shift = readLine(this.textInputEdit2)!!.toInt() for (cd in s) var i = cd.toInt() i += shift if (i > 'z'.toInt()) {i -= 26} val c: Int = i.toChar() message += c } println(message = "encrypted message is: $message.");

6/18/2020 3:06:24 PM

Phillipa Austin-Seymour

3 Answers

New Answer

+3

hi Philipia Autin it is good question if u seen above "import androidx" this is a library which can be imported in gradle based project but sololearn only compile kotlin standard libraries which androidx an external the other thing is sololearn compiler can compile only jvm based project but this is a android project which needs android sdk the limitation of sololearn doesnot support gradle based project, android sdk..... so u will not able to compile this code, keep it as it is in android studio

+1

+1

U can remove " :AppCompatActivity()" which is supper class , " from override fun to to setContentView(R.layout.activity_ceaser_bit)" and replace override fun fun ur own function like "fun ceaser", and finally remove " androidx" library then it will work fine here Warning: u will not get any ui like HTML