I am trying to integrate Admob in my App, but Android Studio can't find those libraries:
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
This is my top-level gradle:
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
}
}
allprojects {
repositories {
jcenter()
}
}
And this project-level gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.tomhogenkamp.personalcalc"
minSdkVersion 16
targetSdkVersion 24
versionCode 4
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:24.1.1'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.github.yukuku:ambilwarna:2.0.1'
}
apply plugin: 'com.google.gms.google-services'
I have added Admob in more apps, but I had no troubles with this.
Can anyone help me?
Thanks!
It looks like you're missing the dependency for ads. Your build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.github.yukuku:ambilwarna:2.0.1'
}
should have an additional line:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-ads:9.4.0'
compile 'com.github.yukuku:ambilwarna:2.0.1'
}
For more info, we recently wrote a blog post about the ways to import the Mobile Ads SDK with Firebase. There's also an episode of the Mobile Ads Garage that covers this.
Open SDK Manager - > Extras - > Install Google Repositories & Google Play Services
If you have already updated these, share error log displaying exact error
make sure that the google play service is properly installed
Open SDK manager and install google play service.
then add this line to the Gradle (Module)
compile 'com.google.android.gms:play-services:9.4.0'
Related
I am trying to add Firebase Job Dispatcher to my project, but I am unable to build because of this error:
Gradle sync failed: Could not find
com.firebase:firebase-jobdispatcher:[version]. Required by: project
:[module]
My build.gradle file looks like this:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 2
versionName "1.0.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
zipAlignEnabled true
}
}
}
repositories {
mavenCentral()
maven {url "https://clojars.org/repo/"}
}
dependencies {
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
compile 'com.firebase:firebase-jobdispatcher:0.5.2'
compile 'com.facebook.stetho:stetho:1.4.2'
compile 'com.jakewharton:butterknife:8.4.0'
apt 'com.jakewharton:butterknife-compiler:8.4.0'
compile 'frankiesardo:icepick:3.2.0'
provided 'frankiesardo:icepick-processor:3.2.0'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support:design:25.3.0'
compile 'com.android.support:support-v13:25.3.0'
compile 'com.google.code.gson:gson:2.7'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/volley.jar')
}
Additionally, I have version 45 of the Google Repository and version 39 of Google Play Services installed via the SDK manager.
According to the documentation on the firebase-jobdispatcher Github page, this should be the only thing I need to add the dependency. My project does not rely on GCM, so I'm not sure what is going on. Is there something I'm missing here?
Apparently, Gradle could not resolve the dependency using Maven Central alone. Adding JCenter to my list of repositories fixed the issue:
repositories {
jcenter() // new
mavenCentral()
maven {url "https://clojars.org/repo/"}
}
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'
Referring question here.
Problem is that i am including something which is repeated.
Can somebody help me figure which one is causing problem?
And this error started arising when i added twitter sdk.
build.gradle
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 23
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.sony.login_signup"
minSdkVersion 15
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.android.support:design:23.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.shamanland:facebook-like-button:0.1.8'
compile 'com.google.android.gms:play-services:+'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'com.github.curioustechizen.android-ago:library:1.3.0'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile('com.twitter.sdk.android:twitter:1.9.0#aar') {
transitive = true;
}
}
If you do:
gradle -q dependencies
It should output a tree of all gradle dependencies and their dependencies. If you trace the dependency tree you will find which ones are using support-v4 and their versions, to tell you where the problem is.
EDIT:
This should be run on a command line / terminal. Gradle is just another program...
https://docs.gradle.org/current/userguide/tutorial_gradle_command_line.html
To do this, make sure that "gradle" is in your environment PATH (this is different depending on if you're Windows or Mac, but if you search you will find it).
Then run the command from the folder where your "build.gradle" and "settings.gradle" files are located (your project "root" folder typically).
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
I am using android-studio 0.6.1 and have all necessary google repositories installed in SDK manager: however when I try to build a project, gradle says about unresolved dependency:
Unresolved dependencies:
Error:com.google.maps.android:android-maps-utils:+
My build.gradle looks like this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
}
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 12
targetSdkVersion 19
versionCode 1
versionName '0.1'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile project(':library')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.google.android.gms:play-services:+'
compile 'com.google.maps.android:android-maps-utils:+'
}
I know I can just import all necessary instruments in library folder, however I would like to resolve this problem. Do you have any suggestions?
EDIT:
Found a way to solve it:
Looks like the problem was in absense of
compile 'com.android.support:support-v4:19.0.1'
in build.gradle, also I had to empty 'library' folder and delete the line in order to avoid 'duplicate packages' problem with support libraries:
compile project(':library')
So my final build.gradle file looks like this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
}
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 12
targetSdkVersion 19
versionCode 1
versionName '1.0'
}
repositories {
mavenCentral()
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.google.android.gms:play-services:4.4+'
compile 'com.android.support:support-v4:19.0.1'
compile 'com.google.maps.android:android-maps-utils:0.3+'
}
The error is
Unresolved dependencies:
Error:com.google.maps.android:android-maps-utils:+
I'd say double check that you've got the dependency correctly defined. Looking at the Map Utils website leads me to believe you might want to declare the dependency with a version.
Replace
compile 'com.google.maps.android:android-maps-utils:+'
to
compile 'com.google.maps.android:android-maps-utils:0.3+'
Do a Gradle Sync and everything should build correctly.
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
// Support Libraries
compile 'com.google.android.gms:play-services:4.1.32'
compile 'com.android.support:support-v4:19.0.1'
compile 'com.google.maps.android:android-maps-utils:0.3+'
}
com.google.android.gms:play-services:3.1.36 can be downloaded by going to your SDK Manager and installing the Extras->Google Repository package (you may want to install the Extras->Android Support Repository as well while you are there). These allow Gradle to automatically use these resources without the need for library projects or jars manually added to your project.
Try to replace this:
compile 'com.google.maps.android:android-maps-utils:0.3+'
with this
compile 'com.google.android.gms:play-services-maps:9.4.0'