I’m starting to learn Android (I have some base in java) and I’m using the last version of android studio. Firstly there is no way to change language from kotlin to java (or it’s very well hide). Every video that I watched are on older versions of android studio and everything is different.
I decided to use kotlin but it still not working (video still don’t show the same things that I have). Here is some code that should show "Hello World" that I found on the Internet but there is a lot of error. So I suppose Android Studio is not correctly configure :
xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="example.app.javatpoint.helloworld.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
Error:
android.support.constraint.ConstraintLayout (both)
kotlin:
package example.app.javatpoint.helloworld
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}
Error:
v7 /
AppCompatActivity /
override /
onCreate /
setContentView /
R
Can you please also tell me which language is the best (I would like to create android game).
(Sorry for my bad English, I’m French)
2
Answers
Remove the Android Studio whatever you have install.Download the latest version of Android Studio.Make sure that java is install is install Properly.
And Android Studio install properly.Use the androidx.constraintlayout.widget.ConstraintLayout it the latest don’t use android that’s why it is showing the error.
And change tools:context="example.app.javatpoint.helloworld.MainActivity" to this tools:context=".MainActivity"
Regarding the language, I was using Java 7 years ago then I moved to Kotlin, I can tell that Kotlin is better and easy to use.
Also, I recommend you check the dependencies inside your project
build.gradle app-level
and check if they are AndroidX or support libraries.