Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't add LocalBroadcastManager to project in Android Studio

I think I've tried everything now...

I've been all over stack overflow, I've even consulted the android doc

Most of the posts here show how to add the .jar file in Eclipse "android tools -> add support library" or something

So I've tried to do it how the doc tells me, by going to build.gradle, and adding compile 'com.android.support:support-v4:19.0.0' to the dependencies

but even if I add it, and rebuild the project, I still can't import android.support.v4.content.LocalBroadcastManager... it doesn't even know what android.support is...

So is there anyone who can help me with this? the issue is getting very annoying, and it's slowed me down by hours...

Edit: I have updated the Android SDK, and made sure that the library exists in the sdk folder, so I know it's there... I just can't make android studio add it for some reason...

Edit 2: Only by navigating to the exact file path, manually, and then copying said path I was able to access the file... Still, I'd very much like to know what I can do to make this a more painless process...

like image 907
Electric Coffee Avatar asked Nov 27 '22 21:11

Electric Coffee


1 Answers

Make sure your library got added successfully.

Check the following things.

1.Your build.gradle should be like

   dependencies {
          compile 'com.android.support:support-v4:19.0.+'
   }

2.File > Project Structure > Modules >Dependency Tab There should not be any red mark in dialog showing error if they are fix them.

enter image description here

3.Check your Module_Name.iml file

It should have this entry in last section

<orderEntry type="library" exported="" name="support-v4-19.0.0" level="project"/>

If its there with no entry close you studio delete .iml file and open studio again wait for gradle sync to be complete.You .iml file will be created again check for entry.

If every thing is fine do sync Your project with gradle again using this lovely tiny gradle button in toolbar.

enter image description here

like image 190
Piyush Agarwal Avatar answered Dec 05 '22 10:12

Piyush Agarwal