1
1
.
.
2
2
.
.
1
1
C
C
r
r
e
e
a
a
t
t
e
e
P
P
r
r
o
o
j
j
e
e
c
c
t
t
I
I
n
n
f
f
o
o
This tutorial shows how to create Jetpack Compose Project.
C
C
r
r
e
e
a
a
t
t
e
e
P
P
r
r
o
o
j
j
e
e
c
c
t
t
Start Android Studio
File
New
New Project
Phone and Tablet
Empty Compose Activity
Next
Name: TestCompose
Finish
New Empty Compose Activity
Name: TestCompose
R
R
e
e
s
s
u
u
l
l
t
t
This will create following files
MainActivity.kt with default generated code in Kotlin (which is why it has extension .kt)
strings.xml that contains application strings (for Localization so that you don't hard code them)
AndroidManifest.xml that contains application configuration
MainActivity.kt (generated code)
package com.example.testcompose
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.Text
import androidx.compose.material.*
import androidx.compose.ui.platform.setContent
import androidx.ui.tooling.preview.Preview
import com.example.testcompose.ui.TestComposeTheme
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
TestComposeTheme {
Surface(color = MaterialTheme.colors.background) {
Greeting("Android")
}
}
}
}
}
@Composable
fun Greeting(name: String) {
Text(text = "Hello $name!")
}
@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
TestComposeTheme {
Greeting("Android")
}
}
strings.xml
<resources>
<string name="app_name">TestCompose</string>
</resources>
Output