1

I'm working on an android app that isn't using an AppCompat based theme, and I'm trying to add chromecast integration using cwac-mediarouter library but I can't seem to get the action provider button to show up.

Relevant code bits: https://gist.github.com/Keirathi/0038ae45fad08b766e79

The basic idea (for testing purposes) is to have an option in the action bar to go to my chromecast activity. From the chromecast activity, I will have the route selector button, and once it's connected I will output logs here.

Whenever I run the app, I can get to my chromecast activity, but the route selector button never shows up in the action bar and my output TextView is just populated with the MediaRouter default route (the tablet that I am running the app from).

I feel like I'm just missing something simple, but I can't figure it out :(

Keirathi
  • 397
  • 1
  • 5
  • 18
  • 1
    Try removing `addControlCategory(CastMediaControlIntent.categoryForCast(getResources().getString(R.string.app_id)))` and see what happens. – CommonsWare Sep 15 '14 at 22:06
  • @CommonsWare same thing. I actually already had it removed locally for testing that, but put it in there anyways because my end goal is being able to connect to a remote server. In another demo app I tried (one not using your library), the app_id works correctly and I can access the route selector button just fine. – Keirathi Sep 15 '14 at 22:12
  • 1
    "my end goal is being able to connect to a remote server" -- I'm not sure what that has to do with using the Cast SDK. The biggest difference that I see between your code and my demo (which you indicated elsewhere is working) is that you are trying to use it with the Cast SDK. I have not tried that and it's entirely possible that it is interfering somehow. You might try making a copy of my demo where you attach the Cast SDK and see if it starts breaking. – CommonsWare Sep 15 '14 at 22:23
  • @CommonsWare: Nope, it doesn't start breaking. In your demo app, if I add the google cast SDK and then .addControlCategor(CastMediaControlIntent.categoryForCast(getResources().getStr‌​ing(R.string.app_id)), I still get the media route button. Then connecting to my chromecast shows uniqueId=com.google.android.cms blah blah blah in the RouteInfo that your demo dumps to the screen. So it's working correctly. This just doesn't make any sense to me why it shouldn't be working in my app :( – Keirathi Sep 16 '14 at 00:05
  • 1
    Is there anything unusual in your `AppTheme`? How did you add the library to your project (e.g., are you using Android Studio and adding the `compile` directive to pull down the AAR artifact)? If you launch straight to `ChromecastActivity`, rather than starting first at `MainActivity`, do you get different results? – CommonsWare Sep 16 '14 at 00:12
  • Launching directly to ChromecastActivity didn't change anything. Still no button. But I did notice something in the LogCat that I hadn't noticed before. Whenever ChromecastActivity starts, I get this in my logs "W/ResourceType﹕ Entry identifier 0x37 is larger than entry count 0x17". It's hard to find information on that error with a basic google search, but it seems that it might have something to do with the style files. – Keirathi Sep 16 '14 at 01:29
  • Agreed that [style files may be the source of the difficulty](http://stackoverflow.com/questions/12897871/xml-layout-entry-identifier-0x11a-is-larger-than-entry-count-0xb2). Is there anything unusual in your `AppTheme`? How did you add the library to your project (e.g., are you using Android Studio and adding the `compile` directive to pull down the AAR artifact)? – CommonsWare Sep 16 '14 at 10:49
  • (Caveat: I know nothing about the themes or how they work) I don't see anything particularly unusual. As far as the libraries, yes I am use Android Studio, but the project was originally and Eclipse project and it set up more like one of them. IE, no gradle. To add the 3 sdk libraries I needed (appcompat, mediarouter, google play services), I had to import them as modules. Then I added your library as a jar. I did some more debug testing last night, and the line that causes the resource error is the actionProvider.setRouteSelector(selector) line. – Keirathi Sep 16 '14 at 15:11
  • Going from there, I set both the /res/values/styles.xml and /res/values-v11/styles.xml (this seems to be the main style sheet for the app) to the nearly default one you are using in your demo app. But I'm still getting the resource error when trying to add the selector to the media route button. – Keirathi Sep 16 '14 at 15:13

1 Answers1

2

Then I added your library as a jar.

There is your problem, because I'm a moron. You can't just use the JAR -- you need the Android library project. I will fix the project to remove the JAR.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Ah, yep that fixed it. I really appreciate all of your patience helping me figure this out. I know it's generally frowned upon on SO to keep a long string of questions going, but you genuinely helped me out. I do kind of feel dumb for not trying to import it was a module earlier, I was just under the impression that I was doing it right :( It's really just a shame that this project isn't gradle based, or I likely never would have had this issue. Thanks again! – Keirathi Sep 17 '14 at 04:26