Android Studio: where did "Install Client Libraries" go for Cloud Endpoints? - android

Back when I was using Android Studio 0.8.2, whenever I would make a change to an Google Cloud Endpoint in my App Engine backend for an Android project, I would then go to
Tools->GoogleCloudTools->InstallClientLibraries
which generated and installed (wrote them to a local maven repository) the client libraries.
That feature is no longer there in 0.8.9. How do I generate/install endpoint client libraries now? Where did that tool go?
Thanks.

There's two options here :
. You can call the gradle task directly "appengineEndpointsInstallClientLibraries"
. You can try using the new flow by including a configuration in your android build file
dependencies {
compile project(path: '<appengine-module>', configuration: 'android-endpoints')
}
which will automatically depend on client libraries defined in your app engine module and include any necessary dependencies.

Related

Can I convert an app configured in AOSP to an app using gradle in Android Studio?

I have my legacy version System App which consists of mk files from AOSP.
However, debugging or modifying this app is time-consuming and tedious because you have to port it after building the entire platform.
I just want to modify this app and add features within android studio like the apps I've developed in the past.
Most of the dependencies written in the existing mk file could be configured using gradle script, but androidstudio fails to build because of the part that uses system api or the part where the framework itself is customized.
is there a way for me?
I would split it into two major parts:
For dependencies on Android Application component based Java code:
Try to make a list of all the dependencies you have there and add
them via imports if they're a part of the public Android SDK, and /
or add them to your app via the dependencies block in the module's
build.gradle as an implementation. Make sure to add google() and
mavenCentral() in the repositories. (Plenty of guides on how to add
a dependency of a third party library). And then gradle sync.
For customized framework dependency:
I think the best way to add any custom framework dependency is to add it as a compileOnly file / or implementation / api in the build.gradle of whatever module you have in the app source code on your project as an AAR or a JAR file. To generate this custom framework AAR / JAR (like a CustomServiceManager.java), build that specific module in AOSP environment if it can be built independently or via make framework / make services.
Ref: https://medium.com/#chauyan/import-aosp-framework-jar-file-f0c2ac979a8a

volley error when importing module

I've been trying to add the volley library to my android project by downloading this repository https://android.googlesource.com/platform/frameworks/volley and then importing the module to my project by following this guide:
First get latest volley with git (git clone >https://android.googlesource.com/platform/frameworks/volley).
In your current project (android studio) click [File] --> [New] -->[Import >Module].
Now select the directory where you downloaded Volley to.
Now Android studio might guide you to do the rest but continue guide to verify >that everything works correct
Open settings.gradle (find in root) and add (or verify this is included):
include ':app', ':volley'
Now go to your build.gradle in your project and add the dependency:
compile project(":volley").
When gradle tries to sync the project after I've imported the module i get the following error message : Error:Could not download layoutlib-api.jar (com.android.tools.layoutlib:layoutlib-api:24.3.1): No cached version available for offline mode.
I believe you want to use Volley and not contribute to the volley library. if that is the case there are better ways to get volley in your project. let Gradle handle it. Gradle is Build Management tool just like Maven but better, As it gives you more freedom and flexibility.
How to add libraries to gradle in android studio. this link shows a how to add libraries to your android project.
As Android Studio uses Gradle things are pretty neat as it uses the middle ground of ANT and Maven for Build and Management tool.
for volley you can add
compile 'com.mcxiaoke.volley:library:1.0.19'
to the app module of your project. this library can be looked up on Github
or you can do that using android studio's GUI, click on File -> Project Structure
example

Why does the generated Cloud Endpoints library change its version now and then?

An App Engine project in Android Studio is (by default) configured to generate a client library, which can be consumed by an Android and/or iOS app.
Gradle is configured to auto-generate the library:
apply plugin: 'appengine'
appengine {
downloadSdk = true
appcfg {
oauth2 = true
}
endpoints {
getClientLibsOnBuild = true
getDiscoveryDocsOnBuild = true
}
}
Note there is no version specified anywhere here.
As specified in https://cloud.google.com/appengine/docs/java/endpoints/gen_clients, the library name is generated as
/target/<yourProjectVersion>.<versionString>-rc-SNAPSHOT.jar
This documentation is probably still from the rc candidate of Android Studio, as my library looks like this:
com.mydomain:api:v2-1.20.0-SNAPSHOT
I am using that library in a separate project:
compile 'com.mydomain:api:v2-1.20.0-SNAPSHOT'
This works fine, until Android Studio or gradle or Google or whoever changes the version number, here 1.20.0. Then my app compile breaks until I adjust the version in gradle.
Why is that? Can anybody tell me why the version stays stable for months and then suddenly changes from one day to another without any update or changes performed from my side. What is that version, who generates it, and can I control it when I generate it from my App Engine project?
NB: Given that the App Engine module and the Android app module are in the same project, Android Studio changes both versions and everything is fine. But when projects are separate, automated builds break.
The 1.20.0 version matches the version of the appengine endpoint client libs generation package for Maven, used to create your client libraries. Behind the scenes it is running the Maven goal appengine:endpoints_get_client_lib in order to build the JAR/AAR your Android app needs. Check your compile dependencies to see what version is being specified for appengine. If it is using a version with a + at the end then Gradle and Maven could be downloading newer versions of the plugins/SDKs which are used to build your endpoints as well as the libraries needed for client apps.
There's no documented way to override this version information using the Maven targets or Gradle. However, you could manually build the library using the endpoints.sh script in the AppEngine SDK which should allow you to set the version the way you want.

Gradle - How my own library can be used in the dependencies section

I'm developing my own library for android. I want to allow other developers to use my library via the dependencies section in the gradle file.
What should I do in order to enable this?
Thanks.
You need to deploy your library to Bintray and link your package to JCenter (that's the default repository configured when you create a new project with Android Studio).
Here are some instructions on how to get started.
Please note that Bintray does not support SNAPSHOTs, but you can get a free account in oss.jfrog.org if you have a Bintray package linked to JCenter.
Here a project example that has all the pieces in place (look for gradle scripts in /gradle directory)

Where does the version string in generated Google Endpoint libs come from?

When I run the installClientLibs from Android Studio (with gradle command as well) for an Endpoint, the jar is generated with this name:
libEndpoint-v1-1.18.0-rc-SNAPSHOT
But since some days ago, it's being generated as:
libEndpoint-v1-1.19.0-SNAPSHOT
Where do the "18.0-rc" and the "19.0" come from? Why did it change? Is it due to a SDK update maybe?
This is the version of the Google libraries:
google-api-client-1.18.0-rc
google-api-client-android-1.18.0-rc
google-http-client-1.18.0-rc
google-http-client-android-1.18.0-rc
google-oauth-client-1.18.0-rc
These libraries are used to generate android client library for your Android module.
You can see them if you expand External Libraries section in Android Studio.
You can also check what is the latest version in Maven Repository. Just go to http://search.maven.org/ and type one of them. You will notice that 1.19.0 is the newest one as you posted.
If you would like avoid update Android module gradle file every time version changes, you can set your dependency like this:
compile project(path: ':backend', configuration: 'android-endpoints')
where backend is the name of the module. By the way, this is how Google Cloud Endpoint template generates configuration for a while. If you find any difficulties applying this way, try creating new project and generate backend module.

Categories

Resources