Anyone get the chromecast android examples working in android studio?

无人久伴 提交于 2019-12-10 09:51:59

问题


I've had a terrible time trying to get these to load without errors. Either the support frameworks fail or the cast api. Anyone have a repeatable method?

The github examples say 'coming soon' for loading into android studio.


回答1:


I haven't converted one of the test projects over but i have been able to create a new project that works with the chromecast device.

  1. First create a new project.

  2. Create a libs folder in the root of your applications module folder

  3. From the Chromecast SDK download copy the GoogleCastSdkAndroid.jar file into your libs folder.

  4. In your applications module build.gradle file update the dependencies at the bottom of the build script to read like the following.

    dependencies {
        compile "com.android.support:appcompat-v7:18.0.+"
        compile "com.android.support:mediarouter-v7:18.0.+"
        compile files('libs/GoogleCastSdkAndroid.jar')
    }
    

You should be good to go with the use of all the external dependencies required for the cast code. Don't forget to open up the SDK manager and make sure you have the Android SDK tools installed and updated.

In order to do the above method with the sample apps you would have to convert them over to the gradle build system. As i'm new to this i can't really help you there.

good luck




回答2:


It's a bit challenging to get all the libraries setup correctly in Eclipse, but the readme for eclipse and the Install Cast Eclipse give the information.

We find that using the Android Support Libraries w/ resources is the trickiest part:

B. Support Library Setup:

To develop for Google Cast, you need both the Cast SDK and three Android Support Libraries, listed below. All Android Support Libraries can be found at (SDK install location)/extras/android/support/.

  1. android-support-v4
  2. android-support-v7-appcompat
  3. android-support-v7-mediarouter

However, since v4 is bundled with v7-appcompat in the Android Support Libraries, you will only need to install the two v7 support libraries listed. See the below link for detailed step-by-step instructions for importing the two v7 libraries into your workspace.

http://developer.android.com/tools/support-library/setup.html#libs-with-res

After creating both support libraries as projects in your workspace:

  1. Right click on v7-mediarouter and select Properties.
  2. Select Android, and in the Libraries list, add v7-appcompat.



回答3:


I just going this working: https://github.com/googlecast/MediaRouter-Cast-Button-android/

I got it working by doing the following:

build.gradle

dependencies {
    compile "com.android.support:appcompat-v7:21.0.3"
    compile "com.android.support:mediarouter-v7:21.0.3"
    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'com.android.support:support-v13:21.0.3'
    compile 'com.android.support:support-v4:21.0.3'
}

I also set the minSdkVersion to 13 and the targetSdkVersion/compileSdkVersion to 21 in build.grandle and AndroidManifest.xml



来源:https://stackoverflow.com/questions/18885438/anyone-get-the-chromecast-android-examples-working-in-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!