1

I have created a library that uses Android CardView.

The library is available as aar file.

When I add the aar file to the project, it gives the following error, on syncing. I still have not used it in the project

attribute for 'cardElevation' not found in com.sampleapp

How do I resolve this namespace issue? So anyone using the library does not have to add cardview to their gradle.

library xml file using cardview

 <?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/networkCard"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:cardUseCompatPadding="true"
    app:cardCornerRadius="@dimen/cardCornerRadius"
    app:cardElevation="6dp"
    app:cardPreventCornerOverlap="true"
    >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/card_background"
        android:clipToPadding="false">
        <ImageView
            android:id="@+id/source_type_icon"
            style="@style/ServiceConnectUIComponentsTheme"
            android:layout_alignParentTop="true"
            android:src="@drawable/ic_linkedin3x"
            android:tint="@android:color/white"

            />
        <android.support.v7.widget.AppCompatTextView
            android:id="@+id/connect_to_source_rational"
            style="@style/ServiceConnectUIComponentsTheme"
            android:layout_centerInParent="true"
            android:text="Your LinkedIn account allows us to check your professional info, employment &amp; education history"
            />
        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_marginLeft="@dimen/connect_buttons_extra_margin"
            android:layout_marginStart="@dimen/connect_buttons_extra_margin"
            android:layout_marginEnd="@dimen/connect_buttons_extra_margin"
            android:layout_marginRight="@dimen/connect_buttons_extra_margin"
            android:layout_marginTop="@dimen/connect_button_margin"
            android:layout_marginBottom="@dimen/circle_indicator_connect_button_margin"
            >
            <Button
                android:id="@+id/access_source"
                android:text="Connect LinkedIn"
                style="@style/Widget.AppCompat.Button.Colored"
                android:background="@drawable/connect_data_button_drawable"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"

                android:elevation="10dp"
                android:textAllCaps="false"

                />
            <com.UIUtils.HorizontalDottedProgress
                android:id="@+id/connectDataProgress"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:visibility="gone"
                ></com.UIUtils.HorizontalDottedProgress>

        </FrameLayout>
    </RelativeLayout>

    </android.support.v7.widget.CardView>

The sampleapp/build.gradle

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.sampleapp"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}
   repositories {
      jcenter()
      flatDir {
        dirs 'libs'
      }
   }
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
      compile 'com.android.support:appcompat-v7:25.3.0'
      compile 'com.android.support.constraint:constraint-layout:1.0.0-beta1'
       testCompile 'junit:junit:4.12'

    compile project(':UI-release')
    }

Thanks

user2536851
  • 314
  • 3
  • 11
  • gradle file and xml file please – Jaydeep Devda Apr 12 '17 at 09:25
  • Your cardview dependency is missing in gradle. Add compile 'com.android.support:cardview-v7:21.0.+' Make sure you use appropriate version of lib. – Hardik Trivedi Apr 12 '17 at 09:45
  • that solution I already had in mind, as you can see in my question. But because the cardview is part of my library project, in whose gradle it is included, I assume there should be no need to add it to the sampleapp, if I can resolve the namespace issue. – user2536851 Apr 12 '17 at 09:49
  • @user2536851 Have you got any solution for this? I am also stuck with the same issue. – Surender Kumar Oct 01 '19 at 04:59

1 Answers1

0

sorry, this answer is late am just putting it others might find it useful in their project. Any library you used building your library or aar you have to add that library in any project you use the library you build. let me put it like this.

for instance, I compiled a library that uses card view, I have to add the card view library to any project I want to use my library.

Yo Daniel
  • 114
  • 11