title: How to integrate Butterknife in android library?
body: <p>I am working on existing project in android and I want to convert Android project to Android Library.
  In that project butterknife library is used for binding UI components. When I tried to convert project to library using <a href="https://developer.android.com/studio/projects/android-library#Convert" rel="nofollow noreferrer">reference</a> the project synced successfully but all file where butterknife is used, I am getting below error &quot;<strong>Attribute value must be constant</strong>&quot; for all @BindView components.</p>
  <p>Below is the changes I made on gradle file.</p>
  <ol>
  <li>App level gradle :</li>
  </ol>
  <pre><code>    apply plugin: 'com.android.library'
      apply plugin: 'com.jakewharton.butterknife'
      apply plugin: 'com.google.gms.google-services'
      apply plugin: 'kotlin-android'
      apply plugin: 'kotlin-android-extensions'
      
      def verionMajor = 2
      def versionMinor = 1
      def versionPatch = 1
      
      android {
          compileSdkVersion 28
          flavorDimensions &quot;general&quot;
      
          defaultConfig {
              minSdkVersion 21
              targetSdkVersion 28
              versionCode 6
              versionName &quot;$verionMajor.$versionMinor.$versionPatch&quot;
              testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
              multiDexEnabled true
          }
      
          buildTypes {
              release {
                  minifyEnabled false
                  proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
              }
          }
      
          packagingOptions {
              exclude 'META-INF/proguard/androidx-annotations.pro'
          }
      
          productFlavors {
              general {
                  buildConfigField 'String', 'appName', '&quot;Finetra&quot;'
                  buildConfigField 'String', 'applicationType', '&quot;General&quot;'
                  resValue &quot;string&quot;, &quot;app_name&quot;, &quot;Finetra&quot;
              }
      
              flavor1 {
                  buildConfigField 'String', 'appName', '&quot;Finetra&quot;'
                  buildConfigField 'String', 'applicationType', '&quot;Flavor&quot;'
                  resValue &quot;string&quot;, &quot;app_name&quot;, &quot;Finetra&quot;
              }
          }
      
          dexOptions {
              javaMaxHeapSize &quot;4g&quot; //specify the heap size for the dex process
          }
      
          packagingOptions {
              exclude 'META-INF/atomicfu.kotlin_module'
          }
      
      }
      
      android {
          compileOptions {
              sourceCompatibility JavaVersion.VERSION_1_8
              targetCompatibility JavaVersion.VERSION_1_8
          }
      }
      
      repositories {
          maven { url 'http://dl.bintray.com/dev-fingerlinks/maven' }
          maven { url &quot;https://jitpack.io&quot; }
      
          dependencies {
              configurations {
                  all*.exclude group: 'com.android.support', module: 'support-v13'
              }
              implementation fileTree(dir: 'libs', include: ['*.jar'])
              implementation 'androidx.appcompat:appcompat:1.1.0'
              implementation 'androidx.multidex:multidex:2.0.1'
              implementation 'com.android.support:design:28.0.0'
              implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
              implementation &quot;androidx.cardview:cardview:1.0.0&quot;
      
              testImplementation 'junit:junit:4.12'
              androidTestImplementation 'com.android.support.test:runner:1.0.2'
              androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
      
              implementation 'com.google.firebase:firebase-messaging:17.6.0'
              implementation 'com.google.firebase:firebase-core:16.0.5'
      
              implementation 'com.jakewharton:butterknife:10.2.3'
              annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
      
              implementation 'com.github.lzyzsd:circleprogress:1.2.1'
      
              implementation 'org.fingerlinks.mobile.android:Navigator:0.1.5'
      
              implementation 'com.loopj.android:android-async-http:1.4.9'
              implementation 'com.google.code.gson:gson:2.8.5'
      
              implementation 'com.squareup.retrofit2:retrofit:2.1.0'
              implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
              implementation 'com.squareup.okhttp3:logging-interceptor:3.12.0'
      
              implementation 'com.wdullaer:materialdatetimepicker:3.0.0'
      
              implementation 'com.pixplicity.easyprefs:library:1.9.0'
      
              
              implementation 'com.facebook.fresco:fresco:2.0.0'
              implementation 'com.facebook.fresco:animated-gif:1.9.0'
      
              implementation 'com.github.crosswall:Android-Coverflow:release-v1.0.5'
      
              implementation 'io.github.inflationx:calligraphy3:3.1.1'
              implementation 'io.github.inflationx:viewpump:2.0.3'
      
              implementation 'com.kaopiz:kprogresshud:1.2.0'
      
              implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
      
              implementation 'com.mikhaellopez:circularimageview:3.2.0'
      
              implementation 'com.google.android.gms:play-services-auth:17.0.0'
      
              implementation &quot;com.priyankvasa.android:cameraview-ex:3.5.5-alpha&quot;
      
              implementation(name: 'highcharts-release', ext: 'aar')
      
              implementation 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1'
      
              implementation 'com.github.warkiz.widget:indicatorseekbar:2.1.2'
      
             
              implementation 'com.google.firebase:firebase-analytics:17.2.2'
          }
      }
      
      ext {
          versions = [
                  'javacv': '1.4.2',
                  'ffmpeg': '4.0.1'
          ]
      }
      
      dependencies {
          implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
          implementation &quot;org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version&quot;
          implementation &quot;org.jetbrains.kotlin:kotlin-reflect:1.3.41&quot;
      
          implementation(group: 'org.bytedeco', name: 'javacv-platform', version: versions.javacv) {
              exclude group: 'org.bytedeco.javacpp-presets'
          }
          implementation group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: &quot;${versions.ffmpeg}-${versions.javacv}&quot;
          implementation group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: &quot;${versions.ffmpeg}-${versions.javacv}&quot;, classifier: 'android-arm'
          implementation group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: &quot;${versions.ffmpeg}-${versions.javacv}&quot;, classifier: 'android-arm64'
          implementation 'androidx.appcompat:appcompat:1.1.0'
          implementation 'com.google.android.material:material:1.0.0'
          implementation 'androidx.navigation:navigation-fragment-ktx:2.0.0'
          implementation 'androidx.navigation:navigation-ui-ktx:2.0.0'
          implementation project(path: ':mylibrary')
      }
      
      android {
         
          compileOptions {
              sourceCompatibility JavaVersion.VERSION_1_8
              targetCompatibility JavaVersion.VERSION_1_8
          }
          kotlinOptions {
              jvmTarget = &quot;1.8&quot;
          }
      }
  
  </code></pre>
  <ol start="2">
  <li><p>Project level gradle :</p>
  <p>// Top-level build file where you can add configuration options common to all sub-projects/modules.</p>
  </li>
  </ol>
  <pre><code>    buildscript {
          ext.kotlin_version = '1.3.50'
      
      
          repositories {
              mavenCentral()
              google()
              jcenter()
          }
          dependencies {
              classpath 'com.android.tools.build:gradle:3.5.3'
              classpath 'com.google.gms:google-services:4.3.3'
      
              // NOTE: Do not place your application dependencies here; they belong
              // in the individual module build.gradle files
              classpath &quot;org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version&quot;
      
              // Add the Crashlytics Gradle plugin.
      //        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta02'
      
              classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.3'
      
          }
      }
      
      allprojects {
          repositories {
              google()
              jcenter()
              flatDir {
                  dirs 'libs'
              }
          }
      }
      
      ext {
          rxJava = '2.2.0'
          rxAndroid = '2.1.0'
      }
      
      task clean(type: Delete) {
          delete rootProject.buildDir
      }
  </code></pre>
  <p>I also refer <a href="https://github.com/JakeWharton/butterknife" rel="nofollow noreferrer">butterknife doc</a> and made changes accordingly.
  But I am not able to resolve the error for R2.</p>
  <pre><code>@BindView(R2.id.user) EditText userName;
  </code></pre>
  <p>How can I achieve this?</p>
  <p>Any help will be appreciated.</p>