Android Bootstrap和Android Studio无法添加库
-
26-12-2019 - |
题
我想使用Android Studio(我遵循本教程)。
我在Project Explorer中看到了Android引导和我的项目,但如果我尝试添加Bootstrap按钮
<!-- basic button -->
<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"
/>
.
我收到以下错误消息:
android-apt-compiler:layout / activity_main.xml:56:错误:在包'com.carfinder'
中没有找到属性'bb_icon_right'的资源标识符
我做错了什么?
解决方案
更新:
确保您的项目结构应该如下所示,您的库可以在某些目录中,如库中> androidbootstraibrary没有问题,在这种情况下,只有您必须在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>
.
我在这里上传了一个工作测试项目(Checkout Form GitHub IS)
其他提示
以防某人在尝试添加这个库并遇到这个问题但有不同的问题,我认为值得一提的是为我工作的完整步骤(我改编了从另一个库
不隶属于 StackOverflow