Where to get gradle aar for Google Ads? - android

I'm attempting to update a Unity game to use a newer version of Google Services Ads. We currently have play-services-ads-9.0.1.aar included in the game assets. But we'd really like to update it to a new version like 15.0.1. I know in Android I can just add com.google.android.gms:play-services-ads:15.0.1 to my gradle file and it'll pull the aar in automatically.
Is there an easy way I can just download that aar so I can replace it in my Unity assets?

There's 15.0.0.:
https://maven.google.com/com/google/android/gms/play-services-ads/15.0.0/play-services-ads-15.0.0.aar
I've found it on THIS site, but I'm afraid that replacing one library might not work... Instead of that maybe just update your Mobile Ads Unity plugin?

You should never manually download & add these libraries!
Cons: These libraries have their own other dependency & downloading each & every one will be a great pain!
Instead, simply add the dependency in gradle & it'll do the rest.

Related

Cost of importing libraries

I've been working on an Android app project. I'm using quite a few libraries (because why redo work that someone else has done to make other people's life easier?).
My question is: what are the costs of importing libraries in a project? (I'm talking about the implementation XXX.YYY:v2.0.0 type of line added in the build.gradle dependencies list.)
Just as an example (though please provide a more encompassing answer): when compiling and publishing my application, does it take all of the libraries' classes and methods and put them in my application, thus making it much heavier than it would need to be?
Each library dependency requires an additional download while you compile your app. So these will increase the amount of time required to compile.
The code for each library is included in your final APK so they will increase the size.
For Every Library a download is necessary In order to built your app.
e.g If you want Libraries regarding to Firebase then You download the Library by adding the Firebase Project to your App. In build.gradle File you see the dependencies after you add them to Your Project App.

Using Dependencies or import Module from Github?

I have one doubt regarding using library from GitHub to Android Studio if anyone help me to solve my doubt, I would be thankful.
My question is
if we want to use library from GitHub , we have two option
either we can use dependencies to import library in project
or we can download the library from GitHub and use it as a module in our project
from above option which one would be good way to use library? (from all perspective)
Dependency
Because whenever a new version of a library arrives you don't have
to continuously check and look for it, let your build tool take care
of that. It can be cumbersome to regularly download and manage
different versions of libraries. That's where build tools like
Gradle comes in and informs you about an update and download it for
you.
You should always use library from github via using dependencies. Why?
You probably won't have times to check and fix the bugs of the library in the future.
You need more time to learn about the library nuts and bolts to maintain and update the library in the future.
You probably don't have enough expertise about the domain of the library.
You need to catch and recreate the bugs you found in your system. So, you need to keep an exact version of each libraries in your project.
You can update and change your dependencies easily without afraid of introducing new bugs.
Make your project clean.

If the package is removed from Gradle, what will happen with my project?

I don't have much experiences with Android development and I have a doubt about the dependencies using Gradle. For example:
If I construct an Android app using Gradle dependecies and the package provider (for example picasso) remove the package from the repository, what will happens with my project? Will I lose the components? Or It makes a local copy of the binaries and my project will kept working normally?
Thanks a lot for help me to understand better how does it works.
You should keep a backup copy of the library you are installing as a dependency, but you shouldn't really worry about it ahead of the time that much.
It is quite rare, but it could get removed due to many reasons. There have been such instances in other cases where someone responsible for managing some package has just decided to remove it or alter it.
This does not just apply to Gradle but to any such dependency your application depends on, from any hosted package management solution. This same advice therefore applies to systems like NPM as well.
What you should ask yourself at some point in the development would be "Can I build this in 5 years again to fix a bug on a fresh machine with all the data I have and probably still have access to in 5 years?", because your local dependency cache might be long gone at that point anyways and the downloads for the library might be gone from the internet as well. It is a good practice to tuck them away somewhere in the same repository as the rest of the code, just in case.
Gradle downloads and caches all the dependencies when you perform Sync, you can see it at the bottom of your Android Studio.
If in the new version of library was deleted some packages, we have two options:
You update library version in your project and this package was removed for your project too
You use the old version of library and package still accessible from your project.
First, you should read that :
What is dependency management ?
The dependency cache
Short answer to your question : your project will still build unless your cache is cleared or if the dependency's version changes
But a package usually does not disappear from a repository (edit : as lu.koerfer underlined it in a comment, packages are not deleted from repository). If so, there might be a replacement package with a different name/group and you should update your dependencies to make it build properly again instead of relying on the cache.
If you will remove the dependency that you using, your project will still be able to use the library you willing to use.
until other dependency with same name / group will override your older dependency
You can read more about how gradle works, and how gradle manage his cache dependencies

Create an Android Library that uses google play services

I need to create an Android Library that uses google's gcm and location services. Initially I did it inside the application's module and everything went fine.
Now I need to create an Android Library to be used by more than one app, and I'm having a lot of problems:
The first one is that my lib doesn't have a google-services.json file, since it should use the app's module to configure itself. So google play services plugin is not working on the libs' build.gradle file.
The second one is that it seems that google play services plugin detects that I'm not calling apply plugin inside the lib's build.gradle and uses by default the version 9.0.0 of the library, even when I'm configuring it to use 10.0.1. So I'm also having a strange problem to run my app, Unable to execute dex: Multiple dex files define ...
What's the right way to create an Android library that uses google-play-services which can also coexist with an Android Application that also uses google-play-services?
First of all in your library, in the build.gradle you have to remove the line
//apply plugin: 'com.google.gms.google-services'
Since you can't have a google-services.json file, you can't use the plugin.
You have to add the dependencies needed, and it is enough to compile to library.
Instead in the projects which will use the library, you have to add the plugin and the google-services.json file.
I have faced a similar situation and concluded that:
1- Android Library should have it
google-services.json
file and should also declare dependencies and google services plugin.
2- App using the library can have their own
google-services.json
file and dependencies declared.
The point to be noted here is that we should use the same versions of dependencies and google services plugin.
Also while adding library dependency,
transitive = true
is added.
I found in the internet that this error of yours is usually caused by multiple copies of library(duplicate) that you are using in your project. Go into the Project Structure -> modules, then check in the target or the apk-libs folder if there are more than one copy. After this, do a clean and build the project.
For more solution about this issue, check this related SO question.
Now, for your question about creating an Android library that uses google-play-services, try to check this tutorial if it can help you. It provides screenshot that you can follow.
For more information, check these threads:
Set Up Google Play Services
Android Studio with Google Play Services
Import Google Play Services library in Android Studio
Adding Google Play Services Library to Your Android App
Even after invalidating caches and restarting Android Studio. The only thing that solved my problem was restarting the computer. Don't know how, but suddenly everything was correct again.

Android Studio Gradle Dependency Check

I am trying to develop a Google Play Services like structure which is split into its own separate components (libraries) that can be added to Android Studio as dependencies. For example what is displayed below;
Like the Play Services libraries I would like to force the user to use the same version for all the libraries when adding more than one, as seen below;
I am wondering how the build.gradle file determines this? Is it built into Android Studio, is it coming from the build tools plugin?
As I would like to do something like this, if anyone has any helpful suggestions/links it would much appreciated.
You can use Lint to define custom rules based on your needs.
There is a really good explanation on topic with an example on Android Studio Project Site.
An easy way to start defining your own Lint rules is by modifying the sample project provided at this link http://tools.android.com/tips/lint-custom-rules/customlint.zip?attredirects=0&d=1
This way you will have all the dependencies set up to use the Lint APIs.
Source http://tools.android.com/tips/lint-custom-rules

Categories

Resources