我创建了一个使用 Android CardView 的库。
该库以 aar 文件的形式提供。
当我将 aar 文件添加到项目中时,它会在同步时出现以下错误。我还没有在项目中使用它
attribute for 'cardElevation' not found in com.sampleapp
如何解决此命名空间问题?因此,使用该库的任何人都不必将 cardview 添加到他们的 gradle 中。
使用cardview的库xml文件
<?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 & 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>
示例app/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')
}
谢谢