Black Bird Black Bird - 11 months ago 59
Android Question

Can't load FragmentManager

I tried creating an Android app. using tabs in Android Studio. I ran into the issue where all my fragment imports were causing the error

Cannot Resolve Symbol 'FragmentManager'
, and anything else associated with fragments within my program. I made sure I was importing the correct support files:


Image of Errors

I checked to make sure I was calling active fragments in my layout files, similar issue explained [here].

I made sure I had the latest Android SDK Build-tools, shown [here].

I [re-synced the Gradle Files].

Tools > Android > Sync Project with Gradle Files

I even imported a pre-made application from the Android Developer guides, [Creating Swipe Views with Tabs], and the error was not going away. Which made me think that there was possibly something wrong with Android Studio. I recently updated to Version 0.8.14 and I noticed the file structure changed a bit, it is now more streamlined.

Application Structure

Which lead me back to poke around within the gradle files. I opened up the build.gradle and verified that there were no issues from the minSdk version and then did one last check on possible errors with Gradle.

apply plugin: ''

android {
compileSdkVersion 15
buildToolsVersion "20.0.0"

defaultConfig {
applicationId ""
minSdkVersion 15
targetSdkVersion 15
versionCode 1
versionName "1.0"
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), ''

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

Check out my answer for the [solution].

Answer Source

While this was not my question, I stumbled upon [this] thread, that suggests that you add other dependencies to the build for the support build library. Add this line within the dependencies section:

compile ''

(For more clarification, using the previous code, you would add this beneath the compile fileTree(dir: 'libs', include: ['*.jar']).

Once you've added this, Android Studio would point out the gradle files have changed and that you should re-sync them. Once the sync is complete, it should resolve the not being able to find the fragments!

Gradle Sync