Compile, Provided, APK – Android dependency scope –

Development issue/problem:

When you add new dependencies to an Android project, especially in Android Studio under Dependencies, there are three options for the Compile/Supply/APK section.

What are the implications if we use each of the options? Contrary to what the title says.


Treat the supplied and packaged parts well so they do what they are supposed to do.
supplied and packaged cannot be used with Android libraries and generate an error…. this with

How can I solve this problem?

Solution 1:

  • provided – only depends on the compilation time
  • Package – only package dependencies
  • Compilation – dependence on compilation time and packing time

provided it is normally used for libraries based on annotation processing. Usually these libraries are divided into two artifacts – the annotation and the compiler. The compiler is a dependency because it does not need to be used in the application, only for compilation, and the annotation is a compilation dependency – it is used in the application code and thus compiled. Or the generated code requires additional dependencies and your application does not need them. For example, the configuration of the dagger dependency :

Compile ‘com.squareup.dolk:dolk:1.2.2’
provided by ‘com.squareup.dolk:dolk-compiler:1.2.2’.

Solution 2:

These features stem from the view of paradise.

They simply indicate how certain dependencies should be managed at each stage of the design process.

  1. compile is the default approach, it just means that all dependencies must be available at compile time. Compilation dependencies are available in all project class paths. Moreover, these dependencies extend to dependent projects. Compilation time dependency is normally required at runtime.
  2. Package – declares an additional configuration for building the application. You can create a list of plugins that add extra functionality to the build process.
  3. This means that the runtime environment contains these dependencies. For example, if you look in the android.jar library, you’ll see a java.lang.RuntimeException : Stump! in every body in the method.

This has certain consequences:

    • You can develop Android applications locally without having a full Android environment.
    • You will need to run your APK on your Android device or emulator, as they offer an implementation of these methods.
    • Your applications that reference the classes in the SDK are built correctly because the jar provides class metadata.
    • If you are not using a library that provides artifacts (e.g., Robolectric), you should run the tests on an emulator/device.

and the package cannot be used with Android libraries and generates an error.

Here’s what a set of sources looks like:

Enter a description of the image here

For more information about the mounting system:

Great article on the crib:

Solution 3:

Xavier is talking about the AIC sighting.

in the Android plugin is called the equivalent (kind of) runtime apk. You can make
apk files (‘libs/foo.jar’)
dependencies and it will only bundle on the compiled classpath, but not on these.

Good luck!

Related Tags:

 android dependencies listgradle add dependencygradle dependencies ( implementation)android studio add module dependencygradle dependencies ( classpath)how to add google maven repository in android studioandroid flavor dependenciesandroid studio conditional compilationgradle install dependencieshow to install gradle in android studioandroid aar include dependencieswhere is build.gradle file in android studioadd dependency to gradle intellijgradle dependencies compile vs implementationcompile gradle project with another project as a dependency

Leave a Reply

Your email address will not be published. Required fields are marked *