更新:
确保你的项目结构应该是这样的,你的库可以在某个目录中,比如库>AndroidBootStrapLibrary 没问题,在这种情况下你只需要更改 settings.gradle 和 build.gradle 中的路径
----YOUR_PROJECT
---AndroidBootStrapLibrary
--res
--src
-- .....
-- build.gradle(must contain apply plugin: 'android-library'
if not that menas not library project you have added something wrong)
---YOUR_MODULE
--res
--src
--build.gradle (no : A)
----settings.gradle
build.gradle(A号)文件
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:18.0.+'
compile project(':AndroidBootStrapLibrary')
}
settings.gradle:
include ':YOUR_MODULE'
include ':AndroidBootStrapLibrary'
毕竟要与 Gradle 同步项目
您忘记为库中的自定义视图添加命名空间。
用这个替换你的按钮代码
<com.beardedhen.androidbootstrap.BootstrapButton
xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="Success"
bootstrapbutton:bb_icon_right="fa-android"
bootstrapbutton:bb_type="success"
/>
如果您正在使用,也可以在其他视图中添加命名空间。您也可以将其添加到布局文件的根元素中,例如
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.app.MainActivity$PlaceholderFragment">
<TextView
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<com.beardedhen.androidbootstrap.BootstrapButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="Success"
bootstrapbutton:bb_icon_right="fa-android"
bootstrapbutton:bb_type="success"
/>
</RelativeLayout>
我在这里上传了一个工作测试项目(在 AS 中的 Checkout form github)
https://github.com/pyus-13/TesstApp.git