APK Expansion Files: Specifying library path in Android Studio (Windows) - android

I am on Android Studio (Windows 10). I have been trying to follow the steps in https://developer.android.com/google/play/expansion-files.html but am stuck at the section "Preparing to use the Downloader Library". I have downloaded and installed Google Play License Library and Google Play Downloader Library. I have created the corresponding modules. But when I go to Module Settings and specify the path to the Library Repository, I get errors and when I open up Module Settings again, the Library Repository field remains blank. The error I get are :
10:23:57 PM IncorrectOperationException: Error while applying changes: cannot create file from text: C:\Users\n56\AppData\Local\Android\sdk\extras\google\market_apk_expansion\downloader_library\
10:36:23 PM IncorrectOperationException: Error while applying changes: cannot create file from text: C:\Users\n56\AppData\Local\Android\sdk\extras\google\market_licensing\library\
And the library repository paths I specified are :
C:\Users\n56\AppData\Local\Android\sdk\extras\google\market_apk_expansion\downloader_library
C:\Users\n56\AppData\Local\Android\sdk\extras\google\market_licensing\library\
I have tried various things like escaping the backslashes, importing the modules instead of clicking New Modules but to no available.
Would be grateful for any help. TIA.

The documentation of this tutorial miss the reference of the Android Manifes.xml file on the path for each android-library.
The correct path for each library are:
Google Play License Library
<sdk>/extras/google/play_licensing/library/AndroidManifest.xml
Google Play Downloader Library
<sdk>/extras/google/play_apk_expansion/downloader_library/AndroidManifest.xml
I noticed that on other tutorial from Google where use the same library for setting up the Licensing Verification Library
ANSWER UPDATED:
These previous method only reference one file of the whole library.
Actually I revert all this steps to use a library from gradle whit all we need to use Google Play License Library and Google Play Downloader Library there is the link for the repository

I tried and made it work with below Tags in individual Module's build.gradle . flatDir is the key to solution. and for Windows based Android Studio, the '\' needs to be escaped using double '\' backslashes.
repositories {
flatDir {
dirs "C:\\Users\\<username>\\AppData\\Local\\Android\\sdk\\extras\\google\\market_licensing"
}
}
I am still learning, but I think it has something to do with flatDirs container which should be child of repositories container.
it is now showing up a bit different but the Gradle Sync just works.

Related

JCenter hosts java applications that follow maven convention

After publishing library on bintray i received one mail from support. Below
Bintray (bintray) has sent you a direct message from Bintray:
Hi,
JCenter hosts java applications that follow maven convention.
In addition to the .pom file, your version should include a binary jar file, a sources jar, and optionally a javadoc jar.
Your files should be under a maven path layout.
(see https://bintray.com/docs/usermanual/uploads/uploads_includingyourpackagesinjcenter.html)
Once those files are added, we'll be glad to include your package in JCenter
Last activity on bitray account showing library released. What's the step need to follow now. Any help will be appreciated. Thanks
I got same Email once . I was trying only to upload library with out sample. Later I changed the format , Create a new android project and attach library to sample and pushed it and it got accepted .
Here is a sample library of mine which I created for learning purpose
https://github.com/Redman1037/MenuDrawer
In bintray account the structure should be like
it should contain all the below files

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.

How to post an Android Studio .AAR file to a local Artifactory repository

I'm using Android Studio 1.5.1 to build a self-contained library (no external dependencies). Let's call it "myLib.aar".
I've been asked to modify my Gradle build to push the .AAR file into the company's private, local Artifactory repository. I am an experienced developer but know very little about Java repositories.
There are a lot of search hits on this topic, but none of them have so far resulted in a solution for my particular situation. Even more troubling, I can't find any two posts that implement a solution the same way.
I'm further confused why one can't just use an/the Artifactory plugin. Apparently one must ALSO use a Maven plugin -- but why? Some use third-party Maven plugins, some use something which appears to be built into Android Studio.
So my question is simply what lines to add to which Gradle files in order to push my .AAR file into Artifactory?
You should use Artifactory plugin.
Re Maven plugin. The role of Maven plugin is to generate metadata about your package (the pom.xml file). Other option is using Ivy plugin to generate the metadata in an alternative format (the ivy.xml file). One way or another your package needs metadata. Select one of them (by applying maven, maven-publish, ivy, or ivy-publish plugin).
The instructions about Artifactory plugin show configuration examples for all the possible options.
JFrog GitHub repo contains project examples for all the possible options.
Hope that helps.
I am with JFrog, the company behind Bintray and [artifactory], see my profile for details and links.

How to use an AAR file with Android Studio 1.2

EDIT:
When I use the response of How to manually include external aar package using new Gradle Android Build System I have an error.
BASE:
I never use AAR file, with the release of Android Studio we can use it.
But I don't find any explanation to use it.
Do you know how to use it?
It's necessary to make some things like ask for the permissions or create the dependencies?
Thanks
AAR format is a jar file containing a compiled Android Library project. Here's some info on what is inside an AAR file
What this means for app developers is that instead of (the old way):
Downloading the source code of a library project
Building it in eclipse
Setting your application project to depend on the local library project
You can instead add the dependency specification to your project/app/build.gradle's dependencies block: compile 'fr.baloomba:viewpagerindicator:2.4.2'
Then gradle (on the next build) searches for the aar file in a central binary repository, downloads the library and allows you to use it's functionality in your project. ( ex: http://search.maven.org/remotecontent?filepath=fr/baloomba/viewpagerindicator/2.4.2/viewpagerindicator-2.4.2.aar )
You can also search the central repository's web interface for libraries to depend on. Once you've clicked on a library to add to the project, click "Gradle/Grails" under "Dependency Information" to copy the line to add to build.gradle.
In my opinion this is a huge improvement.
You don't need to add any permissions to the app, either way, adding a Library project dependency is a compile time thing, not runtime or user-facing.

Duplicate file when deploying apk

This problem seems to come up for a few people, but I haven't been able to apply the solution suggested in other threads for one reason or another so...
I am trying to build a simple android app with an embedded webserver. The server of choice if jetty. I am using maven to manage dependencies with the maven-android-plugin. I have added jetty-server v8.x as a dependency with the default scope. When I try and deploy my apk to the sandbox I get an error
Found duplicate file for APK: about.html
So the file in question is from the jetty package, or rather it is found in two jetty packages, one being a dependency of jetty-server. Other threads out there seem to be suggest I delete the file from one jar or the other but this is not really a scalable solution as I am not the owner of the jars.
Is there a more general solution to this problem? Something that manages the conflict and build or deploy time?
I should note, I am a bit of a Java noob, and have gone the NetBeans and maven route because this is the toolkit I'm familiar with.
OK, found it. The solution is to build using the following command
mvn android:deploy -Dandroid.extractDuplicates=true
There are a couple of issues:
First, to integrate Jetty, your project is going to need a pom.xml file. The Android APK (as-is) does not know how to resolve a pom with Maven dependencies without some sort of bridge. So, you'll need to install a few plugins for Pom management onto Eclipse. Follow the instructions here: http://rgladwell.github.com/m2e-android/
(I found it easier to create a new project using the method described here rather than converting my existing Android app to a Maven project, but I'm sure it'll work either way.)
Second, once you've installed this, you're going to have to make sure your pom.xml contains the necessary dependencies, build goals, and variables. So, open up your pom.xml, and make sure you have the following:
In the "build" node:
sourceDirectory -> src
defaultGoal -> install (I suppose...)
In the "dependencies" node:
... all the jetty/cometd dependencies (org.cometd.java, org.eclipse.jetty, etc.)
Third, you should know that you can't just click the green run button and launch the app via ADB. You have to install it the maven way (Run As -> Maven build/install/test/whatever)
You should open up your war file and check if you actually have two about.html files in there. Some time ago I had two web.xmls in my war files. If you actually have duplicates then you should try to exclude those files.
Maybe you have one file in your project and the duplicate is generated by the maven plugin.
I also just realized that you're probably already properly using the android-maven plugin. One other important tip: change the scope to runtime on the jetty dependencies. This builds successfully for me, whereas using the default scope (compile) always threw the duplicate file in APK error.

Categories

Resources