Inheritance java class in Kotlin


Hello, I'm android developer and I'm trying kotlin.

I have some problems and I don’t understand.

I’m trying to create android Activity in kotlin with these code:

class MyKotlinActivity(): Activity()  {

  public override fun onCreate(savedInstanceState : Bundle?) {
  val test = findViewById(
  if (test is TextView)
           test.setText(“Test complete”);


But it crashes with exception:

ERROR/AndroidRuntime(7974): FATAL EXCEPTION: main   java.lang.NoSuchMethodError:   at ru.demand.MyKotlinActivity.onCreate(MyKotlinActivity.kt:17)   at   at   at   at$1500( ...

In Java this code looks like these one:

public class MyActivity extends Activity {   /** Called when the activity is first created. */   @Override   public void onCreate(Bundle savedInstanceState)   {   super.onCreate(savedInstanceState);   setContentView(R.layout.main);   startActivity(new Intent(this,MyKotlinActivity.class));   } }

What I’m doing wrong?

P.S. I’m sorry for my English. Is it possible to speak in Russia here?


You are doing everything correctly, but there's some problem possibly inside dex. We are working on it right now. Will keep you informed.


Hi I had the same problem but after update to Kotlin plugin version   0.1.2352 (installed from nightly build) this problem was repaired. Thanks Kotlin team


Yes, this problem is now fixed in the trunk. Will be rolled out in the next milestone, meanwhile you can use a nightly build. Good luck.