Android Studio Newb - autocomplete or just incorrectly installed?

Craig Lambie :

I am trying to learn Android Studio / Java for the first time. I am familiar with c#, vb.net, javascript and a few other languages.

The video: Android Studio for Beginners I am following, at 22:56 shows auto completion happening... However I am not getting anything, if I press CTRL+space I get nothing, and the IDE is throwing an error as below, and pictured here

Function invocation 'Button(...)' expected None of the following functions can be called with the arguments supplied. (Context!) defined in android.widget.Button (Context!, AttributeSet!) defined in android.widget.Button (Context!, AttributeSet!, Int) defined in android.widget.Button (Context!, AttributeSet!, Int, Int) defined in android.widget.Button

I suspect I have Android Studio set up wrong, or missing a component/ plugin. As a complete Newb, I also set it up from scratch, ie. installed it on Windows 10 x64 machine.

What should I check? I have

  • installed Java, Java JDK
  • reinstalled studio
  • checked on the autocomplete settings
  • refreshed cache
a_local_nobody :

The answer is simple:

That is not Java, it is Kotlin (https://kotlinlang.org/)

Try to recreate the project from scratch, just check the project configuration carefully when you create it (there should be check box to add support for kotlin or not at the start) to ensure that you are making JAVA files and NOT Kotlin files (Kotlin ends with .kt).

Alternatively, delete this MainActivity and create a new Java MainActivity OR , to get you started, with Kotlin the syntax would have been :

val button = findViewById<Button>(R.id.yourButtonID)

(this is entirely my own opinion, but I almost want to recommend that you just find a Kotlin tutorial instead, with your mixed background, Kotlin could potentially be an easier start, and also because Kotlin is so much nicer :P but this is my own opinion)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=133244&siteId=1