Android Studio configures the Kotlin development environment and creates a new HelloWorld

My Android studio version is 4.0.2

  • First create a java language project without writing business code, first configure the Kotlin environment, and then create a new kotlin project. File->Setting->Plugins, install the kotlin plugin, as shown below:

  • After the installation is complete, select Tools->kotlin->Config Kotlin in Project

  • In the small box that pops up, select "Android with Gradle". The meaning of these two options may be that if the project is a java basic project, select "java with gradle", and if it is an android project, select "Android with gradle".

  • Create a new project KotlinWorld2and select the development languagekotlin

  • Automatically generate MianActivity code as follows:

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }
}
  • running result:

Guess you like

Origin blog.csdn.net/zhangjin1120/article/details/119654567#comments_26480100