Copy Gradle dependency res to another Gradle dependency


(Raymond de la Croix) #1

I’m currently developing a few plugin for Android, in Android studio, and have encountered an issue with resources not being found in the end project which implements all the plugins. To deploy a plugin I use gradlew install which generates a .aar, this .aar contains the .jar and a res folder containing the resource files form that project.

Overview of the problem:

Plugin A uses the google com.android.support:cardview-v7:23.2.0 dependency.

Plugin A now has an external library added to the project and can access the cardview res folder.

While compiling Plugin B it uses a resource from Plugin A, which is an instance of the cardview.

This cardview uses a resource file from the res folder in Plugin A.

Plugin B now adds Plugin A as dependency.

Plugin B now has the res folder from Plugin A but still misses resource items from the res folder from the cardview dependency.

The error thrown at this point is:

Error:(8) No resource identifier found for attribute 'cardCornerRadius' in package...

This is because Plugin B uses the cardview as so:

   <android.support.v7.widget.CardView
        android:id="@+id/card_view"
        android:layout_gravity="center"
        android:layout_width="200dp"
        android:layout_height="200dp"
        card_view:cardCornerRadius="4dp">

        <TextView
            android:id="@+id/info_text"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    </android.support.v7.widget.CardView>

The missing card_view:cardCornerRadius isn’t found in my project, because it is never copied over from Plugin A to Plugin B.

My question is as follows:

Is there a way to have my Plugin B understand what card_view:cardCornerRadius is without adding the com.android.support:cardview-v7:23.2.0 dependency to Plugin B, but instead copy it over from Plugin A?