Fragmentactivity Cannot Be Resolved to a Type

Cannot resolve symbol FragmentActivity

Try removing this section from Basegameutile gradle

 configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}

It prevents the inclusion of the support library.

This section is used when there is a dependency conflict between 2 or more modules because both of them include the support library .

To prevent one of them from including the same dependency use this section.

FragmentActivity cannot be resolved to a type

After waiting a long time for this answer, I have sorted things out, and I think that many other people will need a simple solution for this question.

Warning: This solution is for the eclipse user who uses Indigo or lower version. Still looking for solutions users who use other IDE's for android.

When extending the FragmentActivity for your application with version of 2.2 or lower, you can download the android.supportv4.jar from here or you can get this from your android-sdk directory ..\android-sdk\extras\android\support\v4 and put into your project.

If there are no directory libs in your project, create libs directory and paste the android.supportv4.jar file in this directory.

From eclipse project workspace:
Select project/application in which you want to use. Right click on Project and select Properties option. In this select Java build path and select the tab Libraries

Sample Image

Now click on Add Jar. It will display current list of projects with selected current project.

Expand this and go to the libs directory and select android.supportv4.jar file then click ok. It will display in list box now. Remember add the jar file as relative path path not as absolute path, so whenever if you change the directory of your project or open in another machine then will detect automatically for the project directory. Now click on Ok to close the Properties dialog.

You are able to import the android.support.v4.app.FragmentActivity; by placing mouse over the FragmentActivity or pressing the ctrl+shift+o to import missing files.

Hope you can got now FragmentActivity class.

If you are using the eclipse juno, then no need to worry for downloading the support jar file. It will automatically put into the libs directory and automatically added to your project path. If in case not then go through the Properties option and add it.

One more thing If you need to support your application for lower version then build with the higher version and add your this line into your androidmanifest.xml file

<uses-sdk
android:minSdkVersion="3"
android:targetSdkVersion="15" />

this will now support for 1.5 to 4.0.1 version devices.

Android Studio and android.support.v4.app.Fragment: cannot resolve symbol

The symptom of this problem is usually that the build works fine from the command line (which means your build.gradle file is set up right) but you get syntax highlighting errors in the IDE. Follow This Steps To Solve The Problem: Click on Tools from the toolbar usually at the top part of your IDE, and then navigate to Android then navigate to Sync Project with Gradle Files button. We realize it's less than ideal that the IDE can't just take care of itself instead of forcing you to manually sync at the right time; we're tracking progress on this in https://code.google.com/p/android/issues/detail?id=63151

(Unsolvd) Android FragmentActivity error

It is because of your compiledSdkVersion. You should set it to 21 or higher because @android:style/Theme.Material.Light.DialogWhenLarge.NoActionBar was introduced in API Level 21. See here.

The import android.support.v13.app.FragmentActivity cannot be resolved

Change the "import android.support.v13.app.FragmentActivity" to "import android.support.v4.app.FragmentActivity"

For the undefined part, try this syntax:

public class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
public ScreenSlidePagerAdapter (android.support.v4.app.FragmentManager fm) {
super(fm);
}

and:

@Override
public android.support.v4.app.Fragment getItem(int position) {
return ScreenSlidePagerAdapter.create(position);
}

Original suggestion: Have you added the libraries to your build path? Just right-click on the project and the menu item "Java Build Path" will be listed. Select this and add the libraries to your path.

can not extend FragmentActivity

To add v4 support library, follow steps:

  • Right click on your project folder
  • Build path-> Configure build path
  • Add External Jars
  • Select "android-support-v4.jar" file (It'll be located in Android "android-sdk-windows\extras\android\support")
    then press OK.

Android Fragment cannot resolve add method

@Courtesy To Md

Use import android.support.v4.app.Fragment instead import android.app.Fragment

android.support.v4.app.Fragment is the Fragment class in the android support library, which is a compatibility package that allows you to use some of the newer features of Android on older versions of Android.Reference

Please add this in your gradle dependencies

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


Related Topics



Leave a reply



Submit