I have following project structure in android studio
root project
- libA
- libB
- libCommon
- library (empty - just depends on libA, libB, libC)
where all are android library projects and both libA and libB are dependent on libCommon.
Now I am trying to push the entire project to maven central using Sonatype for which i am following this code https://github.com/chrisbanes/gradle-mvn-push
The problem is that only one project is getting uploaded to the Sonatype repo which is happens to be the last one - library blank with no dependencies added.
How can i upload entire project ?
Related
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
I am trying to figure out why maven is adding this dependency:
com.android.support:support-v4:jar:21.0.0:system
in my dependency tree. It is at the top level of the tree, not underneath any other dependencies which means that I should be able to locate it in the pom.xml?
Well it's not there, or anywhere else in my project. It also doesn't exist under any of my other dependencies as a transitive dependency.
Running
mvn dependency:tree
with debug enabled only gives me these 2 extra lines :
[DEBUG] testArtifact: artifact=com.android.support:support-v4:jar:21.0.0:system
[DEBUG] includeArtifact: artifact=com.android.support:support-v4:jar:21.0.0:system
Any ideas ?
Edit: Is there any chance that the android-maven-plugin adds anything in my dependency tree ?
It's not coming from android-maven-plugin (AMP) but from an aar dependency.
AMP is aware of how to process 'aar'.
One of your android library (aar) has the support-v4 library as an internal jar (In other words it is contained in the aar inside the libs folder)
Run mvn compile and the first couple of lines from mvn will show you a warning of which library include this jar.
You have 2 choices:
ask the producer of that library to not provide the support-v4 within the aar but instead put a dependency in the build.gradle/pom.xml
never include any internal jars from aar's by setting the includeLibsJarsFromAar flag to false, but then you will face problem when you include the support-v4 lib yourself as it contains internal jars
I'm working on my gradle build for an android product to get product flavors working.
I have following project structure:
at.mkw.inlocs.android - Library Project
at.mkw.inlocs.android.lib - Library Project - depends on at.mkw.inlocs.android
at.mkw.inlocs.android.login - App Project - depends on at.mkw.inlocs.android
at.mkw.inlocs.android.core - App Project - depends on at.mkw.inlocs.android.lib
at.mkw.inlocs.android.breeding - App Project - depends on at.mkw.inlocs.android.lib
at.mkw.inlocs.android.localization - App Project - depends on at.mkw.inlocs.android.lib
at.mkw.inlocs.android.health - App Project - depends on at.mkw.inlocs.android.lib
Since adding product flavors to all app and library projects, I am getting an exception when building.
I am using the newest gradle artifact (com.android.tools.build:gradle:0.9+) and android build tools 19.0.3
Another problem is, that Android Studio doesn't show the at.mkw.inlocs.android.lib module in project view.
After switching to packages view, the module is visible, but has no content.
I have pasted the build.gradle files:
root build script
at.mkw.inlocs.android
at.mkw.inlocs.android.lib
at.mkw.inlocs.android.login
at.mkw.inlocs.android.core
at.mkw.inlocs.android.localization
at.mkw.inlocs.android.health
at.mkw.inlocs.android.breeding
Looking at the build.gradle at.mkw.inlocs.android, you are using flavors in a library project.
While this is fine, current flavor support in library project is not final and by default the variants are not published (for consumption by other projects) due to some limitations.
To enable it you'll need to do
android {
publishNonDefault true
}
reference: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Library-Publication
I have created a new Maven project, using android-quickstart artifact Id. There is no error and apk runs on a mobile phone - okay.
When I download Holoeverywhere project from git and link it with my project as a library, it also works.
But I want to link Holoeverywhere to my project using Maven (pom.xml). It's better to import everything using pom.xml than Import->...Use Library...
Dependency in pom.xml itself shows no error, but pom.xml shows this error:
Same error shows up in all projects with apklib dependency in pom.xml. Some projects need these types of dependencies and I can't use them.
Does m2e-android 0.4.3 really support apklib?
We are standardizing our infrastructure for Android development and we are trying to incorporate dependency management to our Android library projects. My current track is using the maven android plugin with m2e-android. We have uploaded the Android artifacts to our Artifactory repository with the Android SDK Deployer. We also have an internal framework with a few libraries we can import into our projects and for most part it works fine.
The issue we are facing now is that apklib dependencies containing resource files are hard to set up. The maven plugin can correctly configure the classpath but if the apklib has resource files that needs to be referenced by the parent Android project, Eclipse is unable to find them unless you checkout the Library Project and link it to the parent project through ADT.
After reading m2e-android discussion on issue https://github.com/rgladwell/m2e-android/issues/8, https://stackoverflow.com/questions/6269816/creating-closed-source-android-libraries#answer-6270768 and APKLIB does not get installed in Maven Repo, I'm not convinced maven is the way to go until ADT properly support closed source apk libraries.
I'd like to know how are you handling these kind of dependencies on your Android projects. What strategies are there other than using Maven?
For reference, here's what we have tried so far.
No dependency management. All required jars are stored into the lib folder and pushed to the source control repo. Library projects are set up as subfolders and pushed to the source control repo for each project they are used in. Eclipse project settings are also pushed. Project built with standard ADT Ant script.
Jar dependencies into libs folder and library dependencies as git submodules. Project built with standard ADT Ant script.
Dependency management with maven, including library projects with apklib packaging. Issue with resource files in apklibs.
You can have an insight on how Facebook Android developers address their dependencies issues in this video: How Facebook Built Facebook for Android.
They use Buck for that. Buck is a build system for Android that encourages the creation of small, reusable modules consisting of code and resources. Buck is in github
This might not be the best solution for you but maybe for someone else.
With the advent of Android Studio and Gradle, we are no longer facing issues with project dependencies; Android or otherwise.
Gradle supports Maven dependencies in jar or apklib formats. Popular libraries have been exported to the apklib (aar) format and made available through Maven.