Android Build a Simple Android App with Java Basic Android Programming Accessing Views in Code: Declaring Variables

my funFactsActivity did not look like the screen and I could not declare the variables even though I imported everything

my funActivity looked like this:

package com.weebly.httpscollegepeerhelp.funfacts

import android.support.v7.app.AppCompatActivity
import android.os.Bundle


class FunFactsMainActivity  :  AppCompatActivity() {


    protected override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_fun_facts_main)
    }
}

when I delete everything and put in what he has it still shows error.

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,426 Points

This looks like Kotlin code, not Java. It seems like you've created the project )or just that file) using Kotlin. Try creating a new project and make sure you don't click or mark any Kotlin-related features.

So does the other 2 files under the folder java have to be in java too? ExampleUnitTest and ExampleInstrumentedTest

Maciej Czuchnowski
Maciej Czuchnowski
36,426 Points

Yes, everything should be .java instead of .kt here. This whole course is based on Java. There are other Treehouse courses that use Kotlin for Android development.