I'm unable to get the YouTubePlayerSupportFragment correctly compiled into my project. I've reviewed this post and this post and have implemented the suggestions there, but still no luck.
Here is what I have tried so far: I have the YouTube API saved in my libs folder. The dependencies section of my gradle file looks like this. You can see that I've tried to include the library using gradle. Whether I comment this line out or not (and sync, of course), I still have the same result.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.google.dagger:dagger:2.0.1'
apt 'com.google.dagger:dagger-compiler:2.0.1'
provided 'org.glassfish:javax.annotation:10.0-b28'
compile 'commons-codec:commons-codec:1.10'
compile 'org.apache.commons:commons-io:1.3.2'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
compile 'joda-time:joda-time:2.8.2'
compile 'com.google.android.gms:play-services:7.8.0'
// compile 'com.google.apis:google-api-services-youtube:v3-rev149-1.20.0'
}
Here is a screenshot to show how I have the YouTube API saved in the libs folder.
I followed the instructions from the Google Developers guide to download the zip file and understand which jars needed to be copied over. These instructions include the following:
Dependencies for all Platforms
The following are the jars from the libs folder required for
applications on all platforms: google-api-client-1.20.0.jar
google-oauth-client-1.20.0.jar google-http-client-1.20.0.jar
jsr305-1.3.9.jar google-http-client-gson-1.20.0.jar (when using GSON)
gson-2.1.jar google-http-client-jackson2-1.20.0.jar (when using
Jackson 2) jackson-core-$2.1.3.jar google-http-client-jdo-1.20.0.jar
(when using JDO) jdo2-api-2.3-eb.jar Android Dependencies
The following are the jars from the libs folder required for android
applications or a newer compatible version of each dependency:
google-api-client-android-1.20.0.jar (for SDK >= 2.1)
google-http-client-android-1.20.0.jar
Finally, I looked at the project structure, and it looks great here:
So why doesn't this thing resolve to a type? I'm completely at a loss. Thanks for any advice.
You have included the wrong YouTube SDK.
YouTubePlayerSupportFragment is part of the YouTube Player API package, that you can find here: https://developers.google.com/youtube/android/player/
Just download the JAR archive, put it in your 'libs' folder, and you'll be good to go.
Related
I am building an SDK for Android that should be exported as an .aar file.
The SDK has a list of dependencies defined in its build.gradle file, for example:
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.google.android.gms:play-services-ads:9.0.2'
My question is: how do i include these libraries in the .aar, so that it is self-contained and does not require the developer using it to add these libraries when using my SDK?
I have looked everywhere for this, but most answers don't seem to address this issue or don't work.
How do i include these libraries in the .aar
Not at all.
An .aar-file is not intended to contain it's own dependencies
You should use a dependency management system (like maven or ivy) to distribute your SDK in order to handle transitive dependencies.
enter image description here
when I download Google Play Services from SDK, I can't find the library. I downloaded another library from the internet but my project couldn't compile.
i used eclipse
1. 'compile 'com.google.android.gms:play-services:+' in your src/build.gradle e.g. like this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services:+'
}
2 Clean your project before running it.
You won't find anymore google_play_service_lib for eclipse. I noticed of this today. You have to download in other page (is easy to find on internet). After that you have to import it in your workspace and then set up the build path to make the bind. That will works
I'm trying to migrate an Android project developed with Eclipse ADT to Android Studio. I've already read the instructions mentioned here http://developer.android.com/sdk/installing/migrate.html and it works fine!
Gradle builds a new android project but I need to "hardcode"(modify manually) the gradle.build file in order to make the libraries work properly. All the other stuffs work fine.
This is the ADT project
MyApplication/
-->assets/
-->libs/
---->android-support-v7-appcompat.jar
---->android-support-design.jar
-->res/
-->src/
-->AndroidManifest.xml
-->project.properties
The first library is automatically recognized by Gradle, and it is substituted with
compile 'com.android.support:appcompat-v7:23.2.1'
in the grandle.build file.
Instead the "android-support-design.jar" is not recognized and it is added to the gradle.build as
compile file('libs/android-support-design.jar')
but it is not working at all.
At the moment, I need to manually substitute the
compile file('libs/android-support-design.jar')
with
compile 'com.android.support:design:23.2.1'
In order to make the build work effectively.
Is there any way to force Gradle to recognize that library and automatically import it? Can I download a version of that library that is recognized, anywhere? At the moment I'm taking both libraries from
<sdk>/extras/android/support/
Thank you all.
I need to "hardcode" the gradle.build file in order to make the libraries work properly
I'm not sure what you mean by "recognize" and "hardcode", but if you just have jar files that you can't use the compile line like for the support libraries, then you can use this line, which will take any jar file in the libs/ folder and compile it. You don't need to hard-code any of those.
compile fileTree(dir: 'libs', include: ['*.jar'])
Otherwise, you should already have these.
compile "com.android.support:appcompat-v7:23.2.1"
compile "com.android.support:design:23.2.1"
But, if you want to get fancy with Gradle, you can do something like this to keep all the support libraries the same version.
ext {
supportLibVersion = '23.2.1' // variable that can be referenced to keep support libs consistent
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
Let's pretend that I have a github repository at github.com/myprojects/myrepo
Let's also pretend that I have a project in IntelliJ with a build.gradle file that contains the following:
dependencies {
// android
compile 'com.android.support:appcompat-v7:21.0.0'
// google play services
compile 'com.google.android.gms:play-services:6.1.71'
}
I want to add my github project via Gradle so I imagine that the dependencies need to add something like:
compile 'github.com:myprojects:myrepo'
This obviously isn't how it works though since I get "Failed to resolve com.github:myprojects:myrepo
Actual examples which work:
compile 'com.github.satyan:sugar:1.3'
compile 'com.github.castorflex.smoothprogressbar:library:x.x.x'
Since I don't want to clone the repository into a libs folder, how can I add a compile command in the dependencies portion of my build.gradle file to compile from github so that I can simply add something like the following:
compile 'com.github.myprojects:myrepo'
compile 'com.github.castorflex.smoothprogressbar:library:x.x.x'
It works because this library is published in Central Maven.
compile 'github.com:myprojects:myrepo'
This obviously isn't how it works though since I get "Failed to resolve >com.github:myprojects:myrepo
It is not enough to push on github.
You have to publish you artifact on Central Maven or JCenter or a local maven. You can find some guides to publish on jcenter, for example this.
I'm trying to add a Leader Board to a Chrome cast project and am getting errors. Android project in Android Studio. In my gradle build - Error: more than one library with package name 'com.google.android.gms'
I understand why you don't want to use two different libraries with the same name, but not sure how to use the same library throughout the project. Here are the two uses of gms:
1) Main activity has dependency on 'CastCompanionLibrary-android-master' which then uses google-play-services_lib. I'm not sure which version of gms this uses, but the version number is referenced in the manifest. Is this just grabbing the version # of play services that they have installed on their phone?
2) BaseGameUtils - has dependency on com.google.android.gms:play-services:+ (I think this is grabbing the most recent version of play-services, but doesn't match the other one.
MainActivity gradle file
dependencies {
compile project(':BaseGameUtils')
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':CastCompanionLibrary-android-master')
}
CastCompanionLibrary-android-master dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':android-support-v7-appcompat')
compile project(':android-support-v7-mediarouter')
compile project(':google-play-services_lib')
}
BaseGameUtils dependencies {
compile 'com.android.support:appcompat-v7:20.0.+'
compile 'com.android.support:support-v4:20.0.+'
compile 'com.google.android.gms:play-services:+'
}
So, the problem (I think) is these two versions of com.google.android.gms, but how do I rectify it so that they all use the same version. I've had almost 2 years of working with Android, but this is my first question on stack overflow. Help is appreciated - Is there a guru out there that has the answer to this?
Seems like you have modified the gradle file for CCL since what you have there does not match with what CCL has in GitHub. The best approach is to only use the piece of play services that you need; for example CCL only needs the play-services-cast (besides the base, which will be pulled in automatically) so if you follow that pattern, things would look smaller (less possibility of running into the 64K dex limit) and less collisions.CCL, in Github, lists its dependency as:
compile 'com.google.android.gms:play-services-cast:6.5+' so you might want to start using versions and also follow the recomendation I just made (same applies for any other code that you have and uses play services; just pull in what you really need)