Question

I would like to add the Android Bootstrap library to my project using Android Studio (I followed this tutorial).

I see Android Bootstrap and my project in project explorer, but if I try to add a bootstrap button

 <!-- 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"
        />

I get the following error message:

android-apt-compiler: layout/activity_main.xml:56: error: No resource identifier found for attribute 'bb_icon_right' in package 'com.carfinder'

What am I doing wrong?

Was it helpful?

Solution

UPDATED:

Make sure your project structure should look like this, your library can be inside some directory, like libraries>AndroidBootStrapLibrary no problem, in that case only you have to change path in settings.gradle and 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 (No. A) file

  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'

Do sync Project with Gradle after all

sync project with gradle

You forgot to add namespace for the custom view in library.

Replave your code for button with this

     <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"
    />

add namespace in other views too if you are using. You can also add it in to the root element of your layout file too like

  <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>

I have uploaded one working test project here (Checkout form github in AS)

https://github.com/pyus-13/TesstApp.git

OTHER TIPS

Just in case somebody is trying to add this library and comes across this question but has different issues, I think it would be worth mentioning the full steps that worked for me (I adapted the wiki from another library here):

  1. Open your project in Android Studio
  2. Download the library (using Git, or a zip archive to unzip)
  3. Go to the folder where you unzipped the library > AndroidBootstrap > build.gradle
  4. Remove 'apply from: 'push.gradle'
  5. Replace Integer.parseInt(TARGET_SDK_INT), Integer.parseInt(MIN_SDK_INT), Integer.parseInt(VERSION_CODE), VERSION_NAME, "25.0.1" with the versions from your project. You can find those in Gradle Scripts > build.gradle
  6. Go to File > Import Module and import the library (you only need the AndroidBootstrap folder, not the whole code from the branch)
  7. Go to File > Project Structure
  8. Locate your main project module, click on it. (you should also see AndroidBootstrap below it)
  9. Click on it and go to Dependencies.
  10. Click on the left green "+" button > Module dependency
  11. Select "AndroidBoostrap"

And now everything should work.

You might still get an error in your .xml files when you try to add an element from the AndroidBoostrap library "Namespace 'app' is not bound.". You can solve this by clicking ALT + ENTER on the error in Android Studio, or add this line

xmlns:app="http://schemas.android.com/apk/res-auto"

after the declaration or your Layout and xmlns:tools e.g

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"

I don't know if this is the most accurate solution on how to include a library as I am an Android beginner but it worked for me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top