4

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...

Electric Coffee
  • 11,733
  • 9
  • 70
  • 131

3 Answers3

19

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

Piyush Agarwal
  • 25,608
  • 8
  • 98
  • 111
  • please read what it says under "Edit:" I specifically put that there to not get the kind of answer you just gave me... note that I added the edit immediately after I posted the question. – Electric Coffee Jan 13 '14 at 15:07
  • 1
    @ElectricCoffee your edit was not there when I read question and wrote the answer. It doesnt means that you down vote some one answer you is gonna try helping you. If you will make edit while writing answer how could I know. Atleast you should put comment before downvote. – Piyush Agarwal Jan 13 '14 at 18:40
  • I can't un-downvote it... sorry... you need to make an edit for me to do that, it was a haste desicion, and I immediately regretted doing it... but the first "Edit" was there from the very start – Electric Coffee Jan 13 '14 at 19:05
  • the problem was that I didn't hit sync project with gradle files... I didn't think I needed to... sorry for the inconvenience – Electric Coffee Jan 13 '14 at 19:16
  • I had added it in my last answer. But I think you did not read and made me to edit that let me add that as well now so it can help others. – Piyush Agarwal Jan 13 '14 at 19:24
  • oh I did see it, and thanks for the solution... but it seemed weird to check it as the right answer after downvoting it... – Electric Coffee Jan 13 '14 at 19:35
  • @ElectricCoffee don't worry it happens. – Piyush Agarwal Jan 13 '14 at 19:42
8

Try adding one of those dependencies to your app level build.gradle :

AndroidX

implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'

Support Library

implementation 'com.android.support:localbroadcastmanager:28.0.0'

Then sync project with Gradle files.

Community
  • 1
  • 1
Ananth
  • 2,597
  • 1
  • 29
  • 39
  • 4
    Hey @ElectricCoffee, I stumbled upon this question because I was having trouble with LocalBroadcastManager. Later, when I figured out what was wrong, I answered that for someone who would find themselves in my place. Thank you for asking the question though. – Ananth Aug 28 '19 at 17:23
  • @Vipul If your issue is not solved by these answers, post your issue as a separate Question and people will take a look over it. – Ananth Oct 24 '19 at 10:27
  • @Ananth same question here – Vipul Oct 24 '19 at 10:35
  • 1
    for androidX: implementation "androidx.legacy:legacy-support-core-utils:1.0.0" – Samrat Jan 12 '20 at 11:53
  • 1
    @ElectricCoffee it's 2023 and I found this answer useful. – Ian Brindley Jun 25 '23 at 18:35
1

After lot of searching and R&D i found some solution. This is working for me i hope this is helping you.

implementation 'androidx.legacy:legacy-support-core-utils:1.0.0'

If you not use Androidx please add this line

implementation 'android.legacy:legacy-support-core-utils:1.0.0'
Samset
  • 109
  • 7