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?) {
  super.onCreate(savedInstanceState)
  setContentView(R.layout.main)
  val test = findViewById(R.id.test)
  if (test is TextView)
           test.setText(“Test complete”);
  }

}

But it crashes with exception:

ERROR/AndroidRuntime(7974): FATAL EXCEPTION: main   java.lang.NoSuchMethodError: android.app.Activity.onCreate   at ru.demand.MyKotlinActivity.onCreate(MyKotlinActivity.kt:17)   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)   at android.app.ActivityThread.access$1500(ActivityThread.java:117) ...

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.