I am creating an android library (.aar) that is using the Google android vision Gradle dependencies for OCRing. But I am unable to figure out how should I can add the Gradle dependency to the .aar File.
I don't want to add Google dependency separately while using my .aar because my library project already contains the same.
I have tried one solution by pushing the .aar file to local maven then using the same in the application but in that case I was still unable to find the Google Vision classes to use.
Thanks.
#user3572586, same issue faced, when you build aar file only project source added in aar not dependency lib. so you need to add externally.
Or
You need to publish your aar in maven repository (local or remote) and including it using compile (...#aar) transitive dependencies are turned off.
For more info see link below's,
Link1
Link2
Related
I want to use android library aar on my common java application, not android.
That android library is on maven central repository.
When I set the dependency in my build.gradle for that, aar file just imported.
How to use that?
How should i change build.gradle and other files in android projects to add dependencies offline?
I downloaded Google Maven Dependency from developer.android.com but i don't know how should i use it?
The official documentation covers very useful topics, including the one you're asking about.
dependencies {
// Dependency on a local library module
implementation(project(":mylibrary"))
// Dependency on local binaries
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
}
https://developer.android.com/studio/build/dependencies
I am an Android developer and my use case is very basic. I have a java library. I want to share the jar with my teammates as a re-usable piece of functionality.
So far I have tried,
Building a .jar from ./gradlew jar by following this guide. But when I include the same jar in Android Studio the jar's dependencies are not resolved.
I can't publish it on bintray or maven central. So I used maven-publish gradle plugin to publishToLocal by following these steps. This didn't help either. In fact, this didn't publish anything at all.
I used gradle shadow jar plugin. It made the jar "fat" i.e. increase the size from 25KB to 3MB.
All I want is to share a jar within my team. And also the transitive dependencies to be resolved.
Can anyone help?
To have the dependencies resolved you need a POM file, which needs to be hosted on a maven repository.
On this blog post it's explained how to do it using bitbucket as your private maven: https://jeroenmols.com/blog/2016/02/05/wagongit/
The TL;DR from the post is:
Add this script to the module gradle:
apply from: 'https://raw.githubusercontent.com/JeroenMols/GitAsMaven/master/publish-bitbucket.gradle'
Add these data to project gradle.properties
ARTIFACT_VERSION=<version_here>
ARTIFACT_NAME=<libraryname_here>
ARTIFACT_PACKAGE=<packagename_here>
ARTIFACT_PACKAGING=jar //You could also use aar
COMPANY=<bitbucket_team_company_here> //Username if not part of team
REPOSITORY_NAME=<bitbucket_reponame_here>
Add these data to your computer global gradle.properties (on linux it's on ~/.gradle/gradle.properties (on mac/windows you'll have to figure out yourself)
USERNAME=<username_here>
PASSWORD=<password_here>
Execute ./gradlew uploadArchives to send it to the private maven.
Add the new repo on your other project:
maven {
credentials {
username USERNAME
password PASSWORD
}
url "https://api.bitbucket.org/1.0/repositories/<your user name>/<the repo name>/raw/releases/"
You can use Jitpack or create a new module .aar
After adding Google Play Services to integrate Google ads into my libGDX project in Eclipse, I can no longer use Gradle to build my Android project.
I know that's because I need to tell Gradle about the new Google Play project dependency so I added compile com.google.android.gms:play-services:5.0.89 to the dependencies section of the :android project however it complains that it could not find com.android.support:support-v4:19.1.0.
I guess that means I need to somehow tell Gradle this new dependency depends on another dependency?
Everything works fine in Eclipse so the dependency of my Google Play project in Eclipse is for sure golden, I just need to make Gradle the same way. Do I need to declare the Google play project as another Gradle project and make a build.gradle file for it? I don't think I should be touching the Google Play project contents at all.
If you have downloaded the tools and google reprositories using the Android SDK Manager (1st thing to check), check if your build.gradle files do not need to be updated (what libGDX version are you currently using?).
I had the same problem and solved it by replacing my Android's module build.gradle file by a brand new.
To do so, use the last ligdx setup ui (https://github.com/libgdx/libgdx/wiki/Project-Setup-Gradle) to create a fresh project then compare/replace gradle files.
Under your android module there's a build.gradle file. Add the following:
dependencies {
compile 'com.google.android.gms:play-services:6.1.11'
}
Check for the latest version of Google Play Services and update your version number accordingly.
For example: there is a project on GitHub https://github.com/chrisbanes/ActionBar-PullToRefresh, it uses Gradle, so you can add to a project using:
compile 'com.github.chrisbanes.actionbarpulltorefresh: library: +'
And there is a project https://github.com/ahorn/android-rss, where Gradle is not used.
What are the ways to connect using Gradle this library to my project?
This need not to store external libraries in my git repository.
If you have a project that is not a simple Java project and is not made for gradle Im afraid you have to download the source convert an eclipse adt project manually/automatically to gradle:
You cann import it as a module through Android Studio (New-> Module -> Import Existing Project) see http://developer.android.com/sdk/installing/migrate.html
You could also just write the build files yourself teaching you a little gradle on the way, just look at the examples and docs how to do it
This project doesn't use gradle but uses maven so dependency to this project can also be handled. You just need to find repository with public access where this project is deployed and add appropriate address in repositories section in build.gradle file. If there's no such repository You can download the project and install it in the local repository - the downside is that no other developer that works with your project can download this dependency until You make Your repo public.
Furthermore the fact that some project doesn't use gradle or maven doesn't mean that dependency to this project can't be handled with gradle. If this project has fixed versioning scheme and is accessible over the net gradle can be configured to use such dependency. Gradle can deal with multiple types of repositories (e.g. flat files).