Local Dependencies

720 0 0
                                        

Sometimes some SDKs are behind with the times and don't provide maven dependencies. In this case, they may provide a jar, aar or Android Library project which you import into your project to build with.

Depending on a local jar

As an example of including a local jar, and to demonstrate the common use of the useLibrary property with Gradle, I'll show how to include the Apache HTTP library.

If your project, or one of your dependencies requires use of the legacy Apache HTTP library and you target API level 23+, you need to include the jar manually. It is located at SDK_DIR/platforms/android-API_LEVEL/optional/org.apache.http.legacy.jar.

Copy the jar to somewhere in your project where Gradle won't see it (if you're using useLibrary).

Now all that is needed is to modify your BUILD file to the following:

The path specified in jars is a relative path from the directory the BUILD file is in

¡Ay! Esta imagen no sigue nuestras pautas de contenido. Para continuar la publicación, intente quitarla o subir otra.

The path specified in jars is a relative path from the directory the BUILD file is in.

Note that this is a workaround needed only for Bazel 0.2.0. Future versions of Bazel should allow including this dependency in a similar way to including the support libraries.

Depending on a local aar

As with a remote aar, a workaround is needed to build with a local aar. The difference this time is that you have to extract the aar yourself before using it.

For this example, I'll show how to build using a local aar of RxAndroid. The steps are similar to using a remote aar. You can first extract the aar to a directory in the root of your project. Then make the following changes to WORKSPACE and your BUILD file, and also add an rxandroid.BUILD to the root of your project.

BUILD to the root of your project

¡Ay! Esta imagen no sigue nuestras pautas de contenido. Para continuar la publicación, intente quitarla o subir otra.

¡Ay! Esta imagen no sigue nuestras pautas de contenido. Para continuar la publicación, intente quitarla o subir otra.

¡Ay! Esta imagen no sigue nuestras pautas de contenido. Para continuar la publicación, intente quitarla o subir otra.
Has llegado al final de las partes publicadas.

⏰ Última actualización: Feb 26, 2016 ⏰

¡Añade esta historia a tu biblioteca para recibir notificaciones sobre nuevas partes!

Building Android Apps: Moving from Gradle to BazelDonde viven las historias. Descúbrelo ahora