0

I got this error: "Call requires API level 11 (current min is 8): android.app.Activity#onCreateView" whenever I'm extending my class with FragmentActivity.

Isn't FragmentActivity compatible with API 8? and if not, is there away to make it compatible?

Thanks in advance.

Alahlavo
  • 21
  • 1
  • 5
  • Please provide a [mcve] demonstrating your problem, including where you are referencing `onCreateView()`. – CommonsWare Mar 26 '16 at 13:21
  • @CommonsWare Thanks for replying. I will edit my post. – Alahlavo Mar 26 '16 at 13:32
  • @Alahlavo Can you post you Activity and the error log.I think it's because some line is wrong in OnCreateView. – tiny sunlight Mar 26 '16 at 13:46
  • @tinysunlight Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); – Alahlavo Mar 26 '16 at 13:55
  • What's the error log? You can edit your quesition. – tiny sunlight Mar 26 '16 at 13:57
  • @tinysunlight The only error shown, is the one on the title - "Call requires API level 11 (current min is 8): android.app.Activity#onCreateView FragmentActivity" – Alahlavo Mar 26 '16 at 13:59
  • @Alahlavo you need to extend form the support library version of `FragmentActivity(android.support.v4.app.FragmentActivity)` Check your imports to see whether you are using this. Or you can use `AppCompactActivity` as well – dishan Mar 26 '16 at 14:00
  • @dishan FragmentActivity is already imported that way. I tried AppCompactActivity, and it does the same thing (same error). – Alahlavo Mar 26 '16 at 14:03
  • @Alahlavo You can use FragmentActivity but you can't override onCreateView. – tiny sunlight Mar 26 '16 at 14:10
  • @tinysunlight I don't understand, I don't have any method named oncreateview, but only onCreate – Alahlavo Mar 26 '16 at 14:11
  • You can read the error log. Some method you use trigger onCreateView. – tiny sunlight Mar 26 '16 at 14:17
  • @tinysunlight That's embarrassing, I just had to clean my project as it seems. I'm sorry for wasting your time. and thanks for all your replies gentleman. – Alahlavo Mar 26 '16 at 14:25
  • @Alahlavo It's really embarrassing! – tiny sunlight Mar 26 '16 at 15:37

2 Answers2

0

Switch the class you're importing from the regular one to the one on the support library, The regular fragment and fragementActivity are only avialbe from android 3.0 (hence API 11) and that is the cause for the error you're getting.

crazyPixel
  • 2,301
  • 5
  • 24
  • 48
0

Add

compile 'com.android.support:support-v4:23.0.0'

in build.gradle.

android.app.Activity#onCreateView is added on API 11.

You can set minSdkVersion to 11 or just don't use this method.

tiny sunlight
  • 6,231
  • 3
  • 21
  • 42