I am new to android coding and was trying to add the youtube API to my APP. But i keep hitting on this error.I have tried the solutions from other links but I am not able to resolve the issue.Can someone help me out?
My app->build.gradle looks like this
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.vidhya.youtubeplayer"
minSdkVersion 11
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
comple files('libs/YouTubeAndroidPlayerApi.jar')
}
My gradle->build.gradle looks this way
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
} }
allprojects {
repositories {
jcenter()
}
}
What am I doing wrong? Kindly help.
Change
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
comple files('libs/YouTubeAndroidPlayerApi.jar')
}
to
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile files('libs/YouTubeAndroidPlayerApi.jar')
}
Related
I've seen a lot of other questions on SO about this topic, but they're all dealing with things I don't think are relevant to my situation, so I'm making a new question.
In my android app, I am hoping to utilize firebase as my database. However, after copying the google services json file into my 'app' folder, and adding the necessary dependencies in my 'build.gradle' file, it's giving an error, saying 'plugin with id "com.google.gms.google-services" not found'. I'll include the code for my build.gradle, please let me know if I made a mistake somewhere!
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.xlr8.jackson.doctrineoropinion"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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:24.2.1'
testCompile 'junit:junit:4.12'
classpath 'com.google.gms:google-services:3.0.0'
}
buildscript {
dependencies {
}
}
Notes:
I have tried several options such as:
move classpath 'com.google.gms:google-services:3.0.0' to the bottom in buildscript/dependencies
Change classpath 'com.google.gms:google-services:3.0.0' to classpath 'com.google.gms:google-services:1.3.0-beta1'
Thanks in advance!
First you doing it wrong way its not way to add google play services.You need to compile google play service in project level build gradle first like this
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
and then add libraries you need in app level build.gradle 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.android.support:design:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.google.firebase:firebase-messaging:9.6.0'
I am trying to add facebook login. I am following the facebook quick starts. But I am getting the following error.
`
Error:(24, 0) Gradle DSL method not found: 'compile()'
Possible causes:<ul><li>The project 'FacebookAdd' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>`
and the gradle.build files.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
dependencies {
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.psycho.ayush.facebookadd"
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
}
P.S. I have gone through almost every question related to this on this site.
It looks like you have two dependencies sections please try this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
}
and remove this
dependencies {
compile 'com.facebook.android:facebook-android-sdk:[4,5)'}
When I sync the gradle files it is showing the error :
Error:(26, 0) Gradle DSL method not found: 'ompile()'
Possible causes:The project 'Athletto' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper fileThe build file may be missing a Gradle plugin.
Apply Gradle plugin
I searched for various solutions but none of them worked.I don't know which plugin I have to use.Here are my gradle files :
build.gradle (Module ) :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.hp.athletto"
minSdkVersion 16
targetSdkVersion 16
multiDexEnabled=true
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
ompile 'com.android.support:design:23.0.1'
compile 'com.github.vajro:MaterialDesignLibrary:1.6'
compile 'com.android.support:cardview-v7:23.2.0'
compile('com.github.afollestad.material-dialogs:commons:0.8.5.6#aar') {
transitive = true
}
}
build.gradle ( Project) :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0-alpha1'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
You have a typing error: change ompile to compile 'com.android.support:design:23.0.1' on line 3 of dependencies.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
ompile 'com.android.support:design:23.0.1'//<--error here
compile 'com.github.vajro:MaterialDesignLibrary:1.6'
compile 'com.android.support:cardview-v7:23.2.0'
compile('com.github.afollestad.material-dialogs:commons:0.8.5.6#aar') {
transitive = true
}
}
I have new clear android app. I want to add volley to my app to make HTTP request. I am developing app with Android studio using Gradle. Here is screenshot for my app:
Ass you see i am going to add volley to my app adding this line of code com.mcxiaoke.volley:library-aar:1.0.0 to build.gradle file
I tried to add Retrofit too. But it gives same type of error: Failed to resolve: bla bla bla.
So i think in my situation gradle can not sync any other library different than com.android......
And i have tried add this lines of code to my build.gradle too. but nothing is changing
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
repositories {
mavenCentral()
}
}
Please advise
Edit: After comments added build.gradle files for project and for module.
Project:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Module:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "domain.testgradle"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.mcxiaoke.volley:library:1.0.19'
}
Volley is now published by the Android Open Source Project on jCenter:
dependencies {
compile 'com.android.volley:volley:1.0.0'
}
You can use
com.mcxiaoke.volley:library-aar:1.0.1
Or its latest version (Not aar)
compile 'com.mcxiaoke.volley:library:1.0.19'
And set
buildToolsVersion "23.0.1"
and use
'com.google.code.gson:gson:2.3'
Add this
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:+'
compile 'com.mcxiaoke.volley:library:1.0.19'
}
i'm having a hard time to make AS with gradle 1.1 work with Roboeletric. I've readed a few tutorials e try some things but none seen to work.
This is my Project build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'org.robolectric:robolectric-gradle-plugin:1.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
The robo eletric got download and all and here is my module build.gradle:
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "br.com.boozeprice"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
apply plugin: 'org.robolectric'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
compile project(':androidcore')
compile project(':persistencecore')
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:2.4'
}
The gradle compiles and all but it seens that i don't have the library in project, i can't import the roboeletric classes neither their annotations.
Am i missing something?
Thank you in advance.
What i did to make it work was to change this line on the gradle file:
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:2.4'
To this:
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'org.robolectric:robolectric:2.4
And now works like a charm