Android Studio: canot import com.google.android.youtube - android

I got the jar file and also pasted it in lib folder of my project. Got the API key , and also wrote compiling code but still cannot import com.google.android.youtube
dependencies {
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-vision:10.0.1'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.google.android.gms:play-services-places:10.0.1'
compile 'com.google.apis:google-api-services-youtube:v3-rev157-1.21.0'
}

The dependency: compile files('libs/YouTubeAndroidPlayerApi.jar') have two occurrences in your gradle file. Also edit the dependency: compile 'com.google.apis:google-api-services-youtube:v3-rev157-1.21.0' to compile 'com.google.apis:google-api-services-youtube:v3-rev181-1.22.0'. You can find more information here. After updating the gradle file, build your project once again.

I found here an issue about Android Player API of YouTube. The issue is all about YouTube APIs should have support via gradle and a documentation of it. I found here in this issue that one of the community created a github on how to add YouTube Android Player API into Android application via Gradle. So you may look on this on how to use it.
For more information, check this related SO question.

Related

Integrate FirebaseUI to app/build.gradle cause crash at runtime

Adding
compile 'com.firebaseui:firebase-ui-auth:2.3.0'
into dependencies of the app/build.grandle File, cause an Error every Time I call FirebaseAuth.getInstance(). Before I added the new gradle Dependency, every FirebaseAuth.getInstance() Call works fine and also I was able to load Data from FirebaseDatabase.
Iam doing this Tutorial: FirebaseUI for Android — Auth. What did I wrong?
Update 1: Put the calls into an Try/Catch Block doesnt work. The Debbuger does not step into the catch Part.
UPDATE 2:
What is the Error? Answer: I dont get an Error. The Logcat Box do not print any Error Message. Also I cant figgure out the error via debugging, becaus the Catch-Block dont get reached.
My app/build.gradle:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:26.0.1'
compile 'com.android.support:cardview-v7:26.0.1'
testCompile 'junit:junit:4.12'
//Firebase
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
//FirebaseUI
compile 'com.firebaseui:firebase-ui-auth:2.3.0'
compile('com.facebook.android:facebook-android-sdk:4.22.1') // Required only if Facebook login support is required
}
apply plugin: 'com.google.gms.google-services'
To solve this, change this lines of code:
compile 'com.firebaseui:firebase-ui-auth:2.3.0'
with
compile 'com.firebaseui:firebase-ui-auth:1.2.0'
Make sure to using right version number for firebase-ui-auth at gradle. You can read the official document: https://firebase.google.com/docs/android/setup
Just check the compatibility:
FirebaseUI Version Firebase/Play Services Version
2.3.0 11.0.4
If you want to use the firebase-ui 2.3.0 you have to use firebase 11.0.4.
Use:
//Firebase
compile 'com.google.firebase:firebase-auth:11.0.4'
compile 'com.google.firebase:firebase-database:11.0.4'
//FirebaseUI
compile 'com.firebaseui:firebase-ui-auth:2.3.0'

Android Studio Error- failed to resolve support-v4:24.0.0

Greeting
I am new to Android Studio and I run my app and I got the following error:
Failed to resolve: com.android.support: support-v4:24.0.0-beta1
I need to know the reason behind this error and how to fix it.
Can any Android Studio expert help me in this?
THANKS
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.andoid.support: support-v4:25.3.1'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:support-v4:25.1.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.1.1'
}
I need to know the reason behind this error
In your module's build.gradle file (e.g., app/build.gradle), you have a line like:
compile 'com.android.support:support-v4:24.0.0-beta1'
I do not know why you are requesting an out-of-date beta of this library.
how to fix it
Change the version number to something more current. Ideally, you set your compileSdkVersion to be 25, then use:
compile 'com.android.support:support-v4:25.3.1'
as version 25.3.1 is the now-current version of this library.

Android libraries: versions conflict issue

I've the below dependence in my Android app build.gradle
compileSdkVersion 25
buildToolsVersion "25.0.2"
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.6.0'
compile 'com.google.firebase:firebase-appindexing:10.0.1'
compile 'com.google.firebase:firebase-ads:10.0.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
}
but getting an error about versions compatibility, as shown below, what is the one to be changed here, i could not figure it out :(
I had same problem what i did was compile the higher version of libraries ,which were creating this error,in app:gradle only.
for example in your case
compile 'com.android.support:mediarouter-v7:25.0.0'
Add this in app:gradle.
There may be more like this mediarouter libraries if it still give error add them jst like this(making them higher version).
First you need to find out where's what consists of a conflicting version of the library. The easiest way to do so is to:
Open Terminal pane in your Android Studio.
Type in: ./gradlew androidDependencies
Find the row that represents the ENCLOSING library consisting of a conflict.
Then just use exclude statement for the conflicting library, like so:
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
(the example assuming com.android.support.test.espresso:espresso-core:2.2.2 was the ENCLOSING library, and com.android.support:support-annotations being the conflict)

Unable to use Snackbar after updating Android Studio

I have recently updated my Android Studio version to 2.3
I am working on a project now and I've noticed that I am unable to import Snackbar class. I never had that problem before.
I can use it by adding compile 'com.nispok:snackbar:2.6.1' and I can import it then, but I don't think I should have to do that instead of just using Android's android.support.design.widget.Snackbar;
This is are my dependencies from build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
I have also tried to play around with DataBinding concept in my project but I don't think this could cause that issue?
Thank you.
You are missing the compile 'com.android.support:design:25.2.0' in your dependencies. As the library is not added you are unable to get the Snackbar class.

In Android Studio, all com.android.support libraries must use the exact same version

I recently upgraded to Android Studio 2.3. and this error started appearing:
Here is my list of libraries:
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/wekaSTRIPPED.jar')
compile('com.mikepenz:materialdrawer:5.8.1#aar') { // Material Drawer
transitive = true
}
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.jakewharton:butterknife:8.5.1'
compile 'com.google.dagger:dagger:2.9'
compile 'com.github.wendykierp:JTransforms:3.1'
compile 'com.afollestad.material-dialogs:commons:0.9.3.0'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.github.paolorotolo:appintro:4.1.0'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.borax12.materialdaterangepicker:library:1.9'
compile 'com.evernote:android-job:1.1.7' // Scheduling library
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
annotationProcessor 'com.google.dagger:dagger-compiler:2.9'
Any idea on how to solve this?
I had the problem like you when updating to Android Studio 2.3. I solved by I searched in my project all support library using 25.1.1 (I searched 25.1.1) and replace with 25.2.0. I think many code using 25.1.1, in your library and your project.
You can open external lib in your project to show all dependency. You should update to new library version(lib using support library):
For ex:
https://github.com/mikepenz/MaterialDrawer - new version is 5.8.2 using 25.2.0

Categories

Resources