Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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,441 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,441 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.