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 trialLucas Santos
19,315 PointsDid not get AppCompatActivity, instead got ActionBarActivity
I have been following along in this course fine until now because for some reason my "FunFactsActivity.java" file is different then the one shown in the video.
It looks like this:
package com.teamtreehouse.funfacts;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class FunFactsActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fun_facts);
}
}
This gives me an error with a red line under:
public class FunFactsActivity extends ActionBarActivity
it says:
class FunFactActivity must either be declared abstract or implement abstract method 'getSupportFragmentManager()' in 'Callback'
in the video the code is the same but instead of extends ActionBarActivity
it's extends AppCompatActivity
and when I tried switching to that it gave me an error as well on AppCompatActivity which turned red.
Assistance is appreciated, thank you.
1 Answer
Seth Kroger
56,414 PointsSince you changed the class manually, you likely didn't add the class's import statement toward the top of the code.
Click to place the cursor on the red-underlined AppCompatActivity. Then either type Alt+Enter or click the red lightbulb to the left. In the drop-down menu that shows up, select Import Class. That should fix the error.
Lucas Santos
19,315 PointsLucas Santos
19,315 PointsWhen I click on the red lightbulb or press Alt Enter it only gives me one option and thats to create class 'AppCompatActivity'
I do not see import at all
Lucas Santos
19,315 PointsLucas Santos
19,315 PointsIv been reading and it says it has something to do with my build.gradle file. If you know of anything or if this is of any use let me know.
This is my file:
Ben Deitch
Treehouse TeacherBen Deitch
Treehouse TeacherHey Lucas!
Here's the build.gradle from the app as I have it:
You're using an older version (19) of the support library which doesn't yet include the AppCompatActivity class. Updating your build.gradle should fix your issues, and if you don't have the right version installed on your computer it should prompt you to download them.
Lucas Santos
19,315 PointsLucas Santos
19,315 PointsBen Deitch Thank you.