We were using AdMob with out Firebase, we don't need Firebase integration and we are just trying to ad below in dependencies:
dependencies {
compile 'com.google.firebase:firebase-ads:9.4.0'
}
It's not resolving the AdMob variables, we are stuck here. We tried all clean, make project steps. Someone faced this issue?
...
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:xx.x.x'
compile 'com.google.firebase:firebase-ads:9.6.0'
}
...
apply plugin: 'com.google.gms.google-services'
Have you tried apply plugin: 'com.google.gms.google-services'after dependencies.
If not., add and sync once. Hope this will help.
for more details. read this document.
https://firebase.google.com/docs/admob/android/quick-start
If you're not using Firebase, it's best to avoid using any of the Firebase gradle dependencies. Instead, use this one to import the Google Mobile Ads SDK by itself:
dependencies {
compile 'com.google.android.gms:play-services-ads:9.6.0'
}
You'll need to make sure the Google Repository has been downloaded by your SDK manager. If it's not, don't worry -- Android Studio will prompt you.
If you're interested, we wrote a blog post about the different ways of importing the SDK, and what your app will get with each one.
Hope that helps!
Related
Android Studio and Google Maps dependencies have finally defeated me. I did have it working but had to change some things to get my app to use the correct API Key.
Now I click on run and it say's build successful, but it doesn't actually run the project on the simulator and it puts a whole load of red circles with white exclamation marks in the messages window. Nothing happens if you click on those circles and there's no explanation as to what they mean.
I've a feeling it's saying there are dependencies of the dependencies I've included but I've moved away from individual Play service includes and included the whole lot, with the whole support library and still nothing happens.
Can anyone tell me what's going on, or how I can fix this, or even where I look next to find out why this won't run.
These are my dependencies in my build.gradle.
dependencies {
compile files('libs/jackson-annotations-2.9.0.jar')
compile files('libs/jackson-databind-2.9.0.jar')
compile files('libs/jackson-core-2.9.0.jar')
compile 'com.google.android.gms:play-services:11.0.4'
compile 'com.android.support:appcompat-v7:25.2.0'
}
apply plugin: 'com.google.gms.google-services'
This is the error
This is where it says the build was successful
Thanks
Change compile 'com.google.android.gms:play-services:11.0.4' to compile 'com.google.android.gms:play-services-maps:11.8.0' // you dont need use all play-services
And try again!
I think that you have a dependency conflict, i suggest in this case to use the version 11.0.2:
compile 'com.google.android.gms:play-services:11.0.2'
btw, loading all the Play Services Library is not necessary to use Google Maps,
use only this dependency:
compile 'com.google.android.gms:play-services-maps:11.0.2'
I'm trying to setup OneSignal push notifocation in my Android app. I have changed my build.gradle to include the required dependencies (or so I think).
No matter what I do I keep getting
Failed to resolve: com.onesignal:OneSignal:3.4.3
or
Could not find com.onesignal:OneSignal:3.4.3
Can anyone give me a slight push please? Thanks in advance :-)
I should mention that I have checked the trouble shooting section on OneSignals home page. All is in order.
Here's the dependencies section of my gradle file:
dependencies {
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.google.firebase:firebase-analytics:9.6.0'
compile 'com.google.firebase:firebase-crash:9.6.0'
compile files('src/main/libs/simple-xml-2.7.jar')
compile files('src/main/libs/date4j.jar')
compile files('src/main/libs/picasso-2.5.2.jar')
compile 'com.onesignal:OneSignal:3.4.3#aar'
compile 'com.google.android.gms:play-services-gcm:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
}
The OneSignal SDK is hosted on Maven Central so I would first make sure you can access this from your system. Next double check the following as well.
Make sure you're using Android Studio version 1.4.0 or newer.
Go to File>Settings. Search for Offline work and uncheck that option.
Add the following to your .gradle file.
Root build.gradle
repositories {
mavenCentral()
}
4. Try restarting Android Studio and then going to Tool>Android>Sync Project again.
5.Try building OneSignal's example Android Studio project. If this works then the problems is related to your project.
Screenshots for some of these steps below.
https://documentation.onesignal.com/docs/troubleshooting-android
Well... what finally fixed this issue for me was to replace
mavenCentral()
with
jcenter()
go figure... :-)
I am developing my first app in android and I need some custom controls. So I want to know if I can use any github project in my app directly? If so then do I have have add any copyright or license information in my app anywhere? Also I want to know how I can use this below project in my app?
https://github.com/hdodenhof/CircleImageView
https://github.com/mutualmobile/CardStackUI
Note: The app which i am developing will be released as a commercial app
Thanks in advance,
IamHuM
CircleImageView readme, and CardStackUI readme both mention the right Gradle dependencies:
dependencies {
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.mutualmobile.android:cardstack:0.5.2'
}
That fits the Android basic project setup:
The most simple Android project has the following build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.1.0"
}
Add your own dependencies to your project.
If you looked at the README file carefully, you will find this:
dependencies {
...
compile 'de.hdodenhof:circleimageview:2.1.0'
}
That basically tells you how to install the library.
Go to your build.gradle file (Note that there are two of them, go to the one that says "Module: app"). Scroll to the very bottom and you'll see something like this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.+'
}
Yours might be slightly different, but you get the idea :)
Now add the line you found in the README to here, so it becomes:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.+'
compile 'de.hdodenhof:circleimageview:2.1.0' // this line!
}
Now do a gradle sync by pressing on the top!
Just do the same thing with the other library!
You have the IDE answers above :) Regarding licences - any commercial app complies with licences, you must understand the licences of the projects you use, and give the appropriate credit accordingly, github projects are usually Apache 2, which in a nutshell means that you can use it freely, but must:
include a copy of the licence (Apache 2)
formally mention the usage of any third-party library you are using by name and by the licence it complies to.
Other licences have other meanings and some might even be unwanted - there are some licences that you would ABSOLUTELY NOT want to use on a client app, but can be used on server side mechanisms.
Read about BSD, GPL, LGPL, and when in doubt - seek legal help (make sure they specialize in exactly that - licencing).
The place to do it could be inside the setting.
(e.g. have a look at the facebook app, inside app settings->terms & policies->More Resources->Third Party Notices), or, depending on the nature of your app - even outside, if you need the user to agree to terms of service or anything else.
In a lot of apps this would usually mean a webview directing to a webpage with all the info, since it's a lot to put in your app and would bloat it.
Check under LICENCE.txt or in the README.txt that are published with the projects.
For more info, refer to The StackExchange OpenSource resources.
Remember - you are liable, and yes - that means someone can sue if you do not handle this properly.
"open source is free speech, not free beer" :)
good luck!
I'm new to Gradle and I need to make sure that my Android project has the latest dependencies with regards to RxAndroid and RxJava. Forgive me for my ignorance but could someone explain how I go about to make sure that the libraries I include in my project are the latest ones? Where does Gradle downloads these libraries from? Is there a central repository? Is GitHub the source? It's not clear from the code shown below:
build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'io.reactivex:rxandroid:1.0.1'
compile 'io.reactivex:rxjava:1.0.14'
}
I would really appreciate if someone could shed some light with regards to this topic.
Gradle downloads them from Maven or other repos. I don't believe GitHub hosts the libraries themselves, but the link to download the libraries could be found on GitHub.
To ensure they are the latest version, you will have to go the library's web page(Git hub page usually) and check if a latest version has been released.
If I am not wrong, you could add a + sign at the end and when you sync Gradle with work in offline mode turned off, it should fetch the latest version of the library.
Eg:
compile 'com.android.support:appcompat-v7:23.3.0+'
compile 'io.reactivex:rxandroid:1.0.1+'
The above line will ensure that 1.0.1 is the min version that you will download and if there are any higher version, it will download that instead.
WARNING : this is not a safe thing to do, because the latest version of library will be automatically downloaded and the changes in the newer version of the library might have breaking changes, and break your app. For instance the methods you use from a library might be removed in the new library or even worse things could happen and it has to me. I suggest you set some time apart once every few weeks and see if there are new updates and consider if it is safe to update.
Deciding to add a library to your project must be carefully thought through, as you are making the project dependent on it and if that library dies out or is buggy, your project too will be screwed. Incase you didn't, I suggest you read this on how being careless with adding dependencies literally broke the internet.
You can just add a plus to the end of each, although it's not recommended as sometimes new libs will break your code.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0+'
compile 'io.reactivex:rxandroid:1.0.1+'
compile 'io.reactivex:rxjava:1.0.14+'
}
Here are the latest:
dependencies {
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'io.reactivex:rxandroid:1.2.0' // Upgraded
compile 'io.reactivex:rxjava:1.1.5' // Upgraded
testCompile 'junit:junit:4.12'
}
check here
I have an android application that I have to run on my laptop (I didn't develop it). The thing is, first I had an error that said Plugin with id 'com.android.application' not found so I fixed adding this to the build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
that works, then I go to compile the project and I have an error like this:
Project with path ':AppData:Local:Android:sdk:extras:google:google_play_services:libproject:google-play-services_lib' could not be found in root project 'Aplicacion'.
in the file build.gradle I have this:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':AppData:Local:Android:sdk:extras:google:google_play_services:libproject:google-play-services_lib')
}
it seems like I have to add a library to the project path,but I don't know which one and neither where is it. So, what things should I see to fix it? thanks
It looks like you're attempting to add Google Play Services as a dependency to your Gradle-based Android app. I'd like to suggest to just follow the instructions provided by Google:
If you want to add the full Play Services library as dependency, then add:
compile 'com.google.android.gms:play-services:8.3.0'
Alternatively, you can also selectively add the submodules/APIs relevant to your app. I.e. if all you need is Google Maps, the that would be:
compile 'com.google.android.gms:play-services-maps:8.3.0'
A full list of all individual submodules/APIs can be found on that same instructions page.
To add Google Play services to an app see the following documentation here