Does 'compile ...' in gradle requieres internet in the installation device? - android

I'm working on a project and using the Google GSM Vision library to read a QR Code by adding
compile 'com.google.android.gms:play-services-vision:8.4.0'
in my app gradle.
After doing it, the project syncs and now I'm able to use the lib and I can launch the app in my own device.
The problem is. What happens if the target does not have access to internet and it does not have a Google account? Will it run or the lib needs to be downloaded after or during the installation?
Thank you.

Creation of APK, mobile vision api bundled with APK. So, internet is not required and google account is not necessary.
From Doc :
Note: ProGuard directives are included in the Play services client
libraries to preserve the required classes. The Android Plugin for
Gradle automatically appends ProGuard configuration files in an AAR
(Android ARchive) package and appends that package to your ProGuard
configuration. During project creation, Android Studio automatically
creates the ProGuard configuration files and build.gradle properties
for ProGuard use. To use ProGuard with Android Studio, you must enable
the ProGuard setting in your build.gradle buildTypes. For more
information, see the ProGuard guide.

Generally, Gradle can try to connect to the web. If you have your dependency downloaded in cache you can build the app in --offline mode.

Related

Different module file by flavor

I'm trying to implement play services and huawei services in the same app, but want to be able to configure which one to use by flavor. Each flavor uses it's own applicationIdSuffix. So for each different flavor, huawei plugin fails and I cannot compile.
I have app module that contains agconnect-services.json file in it's root.
How could I specify different versions of this file for each build flavor?
If it's not possible, then in my root build.gradle file I have this line:
classpath 'com.huawei.agconnect:agcp:1.1.1.300'
Is it possible to use this line only on specific flavor?
The possible cause is that your AppGallery Connect plug-in version is not the latest one. Please upgrade it by referring to HUAWEI AppGallery Connect Guide.
To support multiple channels, you need to add the agconnect-services.json file to the folder of only the Huawei channel and ensure that the AppGallery Connect plug-in version in the project is 1.2.1.301 or later (classpath'com.huawei.agconnect:agcp:1.2.1.301'). If the plug-in version is earlier than 1.2.1.301, upgrade it to 1.2.1.301 or later. To obtain the latest AppGallery Connect plug-in version, please refer to Configuring Address Information for the AppGallery Connect SDK.
The configuration procedure is as follows:
If your app needs to support multiple build types or flavors, configure the agconnect-services.json configuration file downloaded from AppGallery Connect for your app to implement the function. The agconnect-services.json file provides configuration information required by various services in your AppGalleryConnect project. Therefore, if you need to use multiple flavors to release different app versions, copy the agconnect-services.json file to the folder of each flavor and configure it.
To support multiple build types, such as release, debug, rest, and mirror for your app, set buildTypes in the build.gradle file in the app directory. You also need to copy the agconnect-services.json file to the folder of each build type.
If your project needs to support different app packages for different channels, the package name needs to vary depending on the channel. Change the package name in productFlavor in the build.gradle file under the app directory.

Could not locate google-play-services_lib

I'm trying to integrate Google Analytics in my Unity game. I've downloaded and installed the latest unitypackage.
In Unity after clicking on Google Analytics > Setup > Install google-play-services_lib I get this error:
I've installed Google Play Services in Android SDK manager but it does not install the lib. Even the description of the package says it only installs JavaDoc and Sample code, no library:
So the problem is that in the /extras/google/google_play_services/ folder there is no libproject subfolder at all. Only JavaDoc and Samples folders.
I've read the documentation (tab OTHER because I'm not using neither Android Studio nor Eclipse), followed the instructions step by step and it just doesn't work. And my googling turned in vain. How can I install google play services lib?
Have you tried checking the Setting Up Google Play Services Document by Google?
For Android Studio:
Open the build.gradle file inside your application module directory.
Add a new build rule under dependencies for the latest version of play-services. For example:
apply plugin: 'com.android.application'
...
dependencies {
compile 'com.google.android.gms:play-services:fp9.0.0'
}
Save the changes and click Sync Project with Gradle Files in the toolbar.
Note: If the number of method references in your app exceeds the 65K limit, your app may fail to compile. You may be able to mitigate this problem when compiling your app by specifying only the specific Google Play services APIs your app uses, instead of all of them. For information on how to do this, see Selectively compiling APIs into your executable.
For Eclipse with ADT:
Copy the library project at <android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/ to the location where you maintain your Android app projects.
Import the library project into your Eclipse workspace. Click File > Import, select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it.
In your app project, reference Google Play services library project. See Referencing a Library Project for Eclipse for more information on how to do this.
After you've added the Google Play services library as a dependency for your app project, open your app's manifest file and add the following tag as a child of the <application> element:

How to add a specific Google play Services api to Eclipse android project

i simply need an OAuth 2.0 token to authorize requests with Google for REST APIs. so I need to import the google play service sdk.
specifically the:
Google Account Login com.google.android.gms:play-services-identity:8.1.0
I am using eclipse I only want to import the Google account login api, but there is no instructions on how to do so.
if there is no solution, how can I grab the Jar referenced in the dependencies for android studio projects https://developers.google.com/android/guides/setup
There is a solution I guess. Try this:
Go to "android_sdk\extras\google\m2repository\com\google\android\gms\play-services-identity\8.1.0\"
Copy "play-services-identity-8.1.0.aar" to your eclipse project's /libs directory.
Open "project.properties" file and add this line: android.libraries.reference.1=libs/play-services-identity-8.1.0/ and Run Application.
And if it didn't work, try setting up your project with com.google.android.gms:play-services-identity:8.1.0 in android studio and import/export gradle project in/for eclipse. It will most probably resolves the included dependencies automatically to work with eclipse.
Hope it helps.

android build server with crashlytics

I have a android build server which uses APKTool to decompile and then assemble apps again. So the same code base is used and some settings and name, package page, icon and other things are changed for each app and are assembled again. This is something that is already implemented.
I wanted to integrate crashlytics into this. But the problem is crashlytics is available as a gradle plugin and they submit to their API when you build it from source. I decompiled the class files and figured out the API call and called it manually. This works fine. But just wanted to see if we can install gradle and whatever tools required on the build server and directly execute the plugin task alone?
For iOS they have provided a tool so that solves it elegantly:
http://support.crashlytics.com/knowledgebase/articles/370383-beta-distribution-with-ios-build-servers

should I check in the Google Play services library project to source version control for GCM support?

I already added the support for GCM at our android app, however one thing bothers me is about the Google Play services library project. Based on this link Set Up Google Play Services SDK, I should do the following at step 4:
Make a copy of the Google Play services library project.
If you are using Eclipse, import the library project into your workspace. Click File > Import, select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it.
We are using eclipse. So to allow other developer to build our app project without doing any manual work, I checked in the Google Play services library project into our version control (SVN) and add that project as part of our app project.
However I am not sure whether I should check that project into our source version control or not. One thing I also found out that google-play-services_lib.jar file is modified today, however I didn't do anything to that jar and I don't have any idea how it got updated. Should I check in the new version of the jar file? Again this still goes back to whether I should check in the Google Play services library project in the first place.
Could someone with GCM experience shed some lights what's the best approach here?
Update 1 at Jan 16:
Per the answer below, we could add a Google play services jar file to our app project, however based on this link, Implementing GCM Client, it has the following:
Caution: When you add the Play Services library to your project, be sure to add it with resources, as described in Setup Google Play Services SDK. The key point is that you must reference the library—simply adding a .jar file to your Eclipse project will not work. You must follow the directions for referencing a library, or your app won't be able to access the library's resources, and it won't run properly
So that would means that we could not just simple add the jar file.
Your library compiles first whenever you compile your application, as library projects create jar your Google Play Services jar will be updated on every run.
As the library incluse resources you cant create the jar and add them in to your java build path there two possible ways to get rid of this :
Move to Android Studio which uses .aar files which contains all your andorid resources in archive. Read more from refrence.
Prevent libray project to compile each and every time you run the app in eclipse. Click Here to know how to do that.

Categories

Resources