How to add correctly google_play-services - android

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

Related

Integrating github projects in my app using Android Studio

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!

AdMob without Firebase, not resolving

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!

Error: File google-services.json is missing. The Google Services Plugin cannot function without it.

i have already include google-services.json file in my app but it still give me error.
Error:Execution failed for task ':app:processDebugGoogleServices'.
File google-services.json is missing. The Google Services Plugin cannot function without it.
Searched Location:
C:\Users\vikas\AndroidStudioProjects\FireBaseFunctionality\app\src\debug\google-services.json
C:\Users\vikas\AndroidStudioProjects\FireBaseFunctionality\app\google-services.json
Had the same problem - builded before next step of tutorial. You have to generate and download the file from firebase website. See Error "File google-services.json is missing from module root folder. The Google Services Plugin cannot function without it"
- late, but someone may need this nowdays.
go into SDK manager --> SDK tool---->install play service and USB tool and repository
I have solved same problem with above method
or u can change the name of google service
google-services.json instead of
google-services(any number).json
just change in the build.gradle the line
compile fileTree (dir: 'libs', include: ['* .jar'])
to
implementation fileTree(dir: 'libs', include: ['*.jar'])
Go to your flutter sdk folder used to build the app. Delete all the contents in the folder .pub-cache
Now pub-get and run.
Sometime we copy the downloaded file and put in app directory. But it changes the name. For example googleservices(1).json instead of googleservices.json. so make sure the name of file is correct.
What worked for me was:
Download google-services.json from https://console.firebase.google.com/
Place it on App Level Directory (myapp/app/)
And then follow the https://console.firebase.google.com steps to do in android studio:
Project-level build.gradle (/build.gradle):
buildscript {
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
...
// Add this line
classpath 'com.google.gms:google-services:4.3.8'
}
}
allprojects {
...
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
...
}
}
App-level build.gradle (//build.gradle):
apply plugin: 'com.android.application'
// Add this line
apply plugin: 'com.google.gms.google-services'
dependencies {
// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:28.3.0')
// Add the dependency for the Firebase SDK for Google Analytics
// When using the BoM, don't specify versions in Firebase dependencies
implementation 'com.google.firebase:firebase-analytics'
// Add the dependencies for any other desired Firebase products
// https://firebase.google.com/docs/android/setup#available-libraries
}
Finally, press "Sync now" in the bar that appears in the IDE:
change your googleservices(number).json to googleservices.json no number it worked for me I just encountered the same problem.

How to integrate MoPub inside a shared library in Android Studio

I need to integrate MoPub inside an android library shared by 3 different games.
I tried to use the fabric plugin with no success... after some attempts I get this error:
Error:Failed to resolve: com.mopub.volley:mopub-volley:1.1.0
Then I also tried to follow this guide that you can find here (https://github.com/mopub/mopub-android-sdk/wiki/Getting-Started) but I always get some errors (I can't execute the gradle command via terminal or I get the same error as mentioned above).
Can someone help me?
Thank you,
Mirko
UPDATE
Thanks to #Edward I was able to import correctly mopub-sdk in my project.
In order to fix the mopub-volley error, first clean the solution, read which files are missing in the console, look at the path, recreate the indicated path and add mopub-volley-1.1.0.jar, mopub-volley-1.1.0.pom in that folder.
Rebuild and you are ready to go!
In my case, mopub-sdk was looking for the mopub-volley lib inside an
inexistent folder in the same path of the android sdk.
If you get another error related to the millenial sdk, add this line in the dependencies section of the build.gradle file inside the mopub-sdk library:
compile fileTree(dir: 'libs', include: ['*.jar'])
you should get something like this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:22.0.0'
compile 'com.android.support:support-annotations:22.0.0'
compile 'com.mopub.volley:mopub-volley:1.1.0'
}
Hope this can help you!
Go download the MoPub SDK.
Unzip and you will get a mopub-sdk folder
Navigate to your ‘Project location’, go into your project folder, and drop the unzipped mopub-sdk into the folder.
Navigate back to Android Studio and open your project's settings.gradle file and include the MoPub SDK as a module as shown below. You may need to sync Gradle again in Android Studio to have the ‘mopub-sdk’ show up in the left Project window.
include ':app', ':mopub-sdk'
Open your project's build.gradle file and add jcenter as a repository and the MoPub SDK as a dependency:
repositories {
jcenter()
}
...
dependencies {
compile project(':mopub-sdk')
...
}
For those late to the party:
repositories {
jcenter()
}
dependencies {
compile('com.mopub:mopub-sdk:4.8.0#aar') {
transitive = true
}
}
just make sure you've added jcenter() in the your repositories. fabric does not do this automatically for some reason
It looks like there is no mopub-volley lib into mavencentral or jcenter
So tou can try to use
compile 'com.mcxiaoke.volley:library:1.0.18'
instead of
compile 'com.mopub.volley:mopub-volley:1.1.0'
It helps for me.

Best way to add dependency for Wire using Gradle in Android Studio

I'm using Square's Wire library for my Android app, using Android Studio with Gradle.
I originally added the wire-runtime-1.2.0.jar into a libs folder in my module, and added the dependency to Gradle like this in my build.gradle file:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
That worked fine.
I'm new to Gradle and Android Studio, but based on the way I'm depending on the Google Support and Play Services libraries, I thought I might be able to remove the wire-runtime-1.2.0.jar library from my repository and just declare a dependency like this (the line is from the Maven repository):
dependencies {
compile 'com.squareup.wire:wire:1.0.0'
}
But if I do that then I hit this error:
Gradle: package com.squareup.wire does not exist
Is there a way to set up this dependency without importing the JAR file directly? Or does that only work for libraries that you can install through the SDK Manager?
Some packages, like com.squareup.wire, have multiple artifacts in Maven Central. You need to choose the right one for your needs. In this case, the equivalent of wire-runtime-1.2.0.jar is the wire-runtime artifact, not the wire artifact.
Here's what your dependencies section should look like:
dependencies {
compile 'com.squareup.wire:wire-runtime:1.2.0'
}

Categories

Resources