Butterknife not finding views from Android Library module - android

I have 3 modules in my project: common, admin and client.
The first is an Android Library with an abstract LoginActivity that the other modules (apps) extends from.
LoginActivity has its own layout and all methods implemented but one: tryLogin(user, password) that navigates to the main activity, which is different for each app.
I have followed the official documentation but when I click on signIn button the OnClickListener is not called. Moreover, all bound views are null...
This are all related code from admin (both modules are almost identical)
Project level build.gradle
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath "io.realm:realm-gradle-plugin:1.1.1"
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.2.1'
classpath 'io.fabric.tools:gradle:1.21.7'
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Common library build.gradle
apply plugin: 'com.android.library'
apply plugin: 'realm-android'
apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'android-apt'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "0.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
// Local
compile fileTree(dir: 'libs', include: ['*.jar'])
...
compile 'com.jakewharton:butterknife:8.2.1'
}
Admin app build.gradle
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'io.fabric'
apply plugin: 'android-apt'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "..."
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "0.1"
}
buildTypes {
debug {
applicationIdSuffix '.debug'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
...
// Butterknife
compile 'com.jakewharton:butterknife:8.2.1'
apt 'com.jakewharton:butterknife-compiler:8.2.1'
}
LoginActivity (common)
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.Button;
import android.widget.EditText;
import xxx.common.R;
import xxx.common.R2;
import butterknife.BindView;
import butterknife.OnClick;
public abstract class LoginActivity extends BaseActivity {
#BindView(R2.id.login_user_form)
protected EditText user;
#BindView(R2.id.login_password_form)
protected EditText password;
#BindView(R2.id.login_sign_in)
protected Button signIn;
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ButterKnife.bind(this);
}
#OnClick(R2.id.login_sign_in)
protected void onSignInClick() {
String user = this.user.toString();
String password = this.password.getText().toString();
/* Fields validations ... */
tryLogin(user, password);
}
protected abstract void tryLogin(String user, String password);
}
activity_login.xml (common)
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:padding="#dimen/activity_horizontal_margin">
<ImageView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.4"
android:scaleType="fitCenter"
android:src="#drawable/brand" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.6"
android:gravity="center_horizontal"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="#+id/login_user_form"
style="#style/LoginEditText" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="#+id/login_password_form"
style="#style/LoginEditText" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/login_sign_in"
style="#style/LoginButton"
android:text="#string/login_sign_in" />
</LinearLayout>
</LinearLayout>
AdminLoginActivity (admin)
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import xxx.activity.LoginActivity;
import butterknife.ButterKnife;
public class AdminLoginActivity extends LoginActivity {
#Override
protected void tryLogin(String user, String password) {
// This is never called!!
Toast.makeText(this, "Login in...", Toast.LENGTH_SHORT).show();
}
}
Te application is not crashing or anything, it does just nothing.
What am I doing wrong??

My guess is that the code has the wrong R file being imported.
To verify this, you can look at the R file that is automagically built in the build/generated/source of the library module in issue and see if the id your looking for is included. There are several R files generated. Find the one that has the id your looking for and make sure it matches your R import namespace.

Related

Using webview AdblockWebView crashes

I am trying to use AdblockWebView library to block ads on Android webview. I tried to connect with my phone but the developed app crashes. I am using the following code. Is there anything I should change.
MainActivit.java
import org.adblockplus.libadblockplus.android.webview.AdblockWebView;
public class MainActivity extends AppCompatActivity {
AdblockWebView superWebView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
superWebView = findViewById(R.id.main_webview);
superWebView.getSettings().setJavaScriptEnabled(true);
superWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
superWebView.getSettings().setDomStorageEnabled(true);
superWebView.setWebViewClient(new WebViewClient());
superWebView.clearCache(true);
superWebView.loadUrl("https://m.youtube.com/");
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<org.adblockplus.libadblockplus.android.webview.AdblockWebView
android:id="#+id/main_webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
build.gradle (project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (Module)
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.webview"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'org.adblockplus:adblock-android-webview:3.14'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Your issue is most likely coming from superWebView.clearCache(true);
Remove this line and the app should run.

Ripple Pulse /Pulse animation Lib Not Working

I want to use pulseLayout In my Project but it's not working I made Demo Project for Find out Reason for it not able to conclude anything. I tried 2 pulse lib but none of them are working.
lib are : https://github.com/gaurav414u/android-ripple-pulse-animation
https://github.com/booncol/Pulsator4Droid
Layout File :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:ripple="http://schemas.android.com/tools"
tools:context=".MainActivity">
<com.gauravbhola.ripplepulsebackground.RipplePulseLayout
android:layout_width="200dp"
android:layout_height="200dp"
android:clipChildren="false"
ripple:rippleColor="#3D66C7"
ripple:rippleType="stroke"
ripple:strokeWidth="2dp"
ripple:startRadius="42dp"
android:layout_centerInParent="true"
ripple:endRadius="100dp"
ripple:duration="2000"
android:id="#+id/layout_ripplepulse">
</com.gauravbhola.ripplepulsebackground.RipplePulseLayout>
<pl.bclogic.pulsator4droid.library.PulsatorLayout
android:id="#+id/pulsator"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:pulse_count="4"
app:pulse_duration="7000"
app:pulse_repeat="0"
android:layout_below="#+id/layout_ripplepulse"
app:pulse_color="#color/colorAccent"
app:pulse_startFromScratch="false"
app:pulse_interpolator="Linear">
</pl.bclogic.pulsator4droid.library.PulsatorLayout>
</RelativeLayout>
Activity :
public class MainActivity extends AppCompatActivity {
RipplePulseLayout layout_ripplepulse;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
layout_ripplepulse =findViewById(R.id.layout_ripplepulse);
layout_ripplepulse.startRippleAnimation();
}
}
App level Gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.trueapps.wordsearchnewproject"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
implementation 'pl.bclogic:pulsator4droid:1.0.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.gauravbhola.ripplepulsebackground:library:1.0.0'
}
Project level Gradle :
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
In the Xml file header you are using
xmlns:ripple="http://schemas.android.com/tools"
Just replace it with
xmlns:ripple="http://schemas.android.com/apk/res-auto"

Databingding V2 and kotlin,I can not find my BR?

Yesterday, I updated my Android Studio to 3.1. So I can only use Databinding V2.I can build successfully in Java.But fail in Kotlin.It told me Unresolved reference: BR
layout
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="mainViewModel"
type="com.example.shao.myapplication.ViewModel" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#{mainViewModel.title}"/>
</LinearLayout>
</layout>
in Java
public class MainActivity2 extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
binding.setVariable(BR.mainViewModel, new ViewModel());
}
public static int getMainBr() {
return BR.mainViewModel;
}
}
in kotlin
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val mBinding = DataBindingUtil.setContentView<ActivityMainBinding>(this, R.layout.activity_main)
mBinding.setVariable(BR.mainViewModel, ViewModel())
}
}
Android’s Data Binding with Kotlin
First of all, after having a created Android project in Android Studio, we need to add the Data Binding dependency and the ones of Kotlin to the build.gradle file of our app.
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
....
dataBinding {
enabled = true
}
}
dependencies {
...
// notice that the compiler version must be the same than our gradle version
kapt 'com.android.databinding:compiler:2.3.1'
}
First we need to create a model. In this case a basic one like User.kt
data class User(val name: String, val age: Int)
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<variable
name="user"
type="com.kuma.sample.User"
/>
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.kuma.sample.MainActivity"
>
<TextView
android:id="#+id/user_name_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="#{user.name}"
tools:text="Name"
/>
<TextView
android:id="#+id/user_age_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="#{Integer.toString(user.age)}"
tools:text="XX"
/>
</LinearLayout>
</layout>
Kotlin Class
package com.kuma.sample
import android.databinding.DataBindingUtil
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.kuma.kotlinsteps.databinding.ActivityMainBinding
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val binding: ActivityMainBinding = DataBindingUtil.setContentView(this, R.layout.activity_main)
val user = User("Kuma", 23)
binding.setVariable(BR.user, user)
binding.executePendingBindings()
}
}
Solve Error Br
enter code hereapply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.example.icarusud.recyclerviewtest"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled true
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
//recyclerview
compile "com.android.support:recyclerview-v7:24.1.1"
//lastadapter
compile 'com.github.nitrico.lastadapter:lastadapter:1.1.1'
kapt "com.android.databinding:compiler:2.1.2"
}
repositories {
mavenCentral()
}
kapt { generateStubs = true }
Change your gradle setting according to below code try this code it helps you.
change
mBinding.setVariable(BR.mainViewModel, ViewModel())
to
mBinding.mainViewModel=ViewModel()
I worked around this issue by adding a BRUtils.java, then in the Kotlin files, accessing BR values in BRUtils.java
BRUtils.java:
/**
* since {#link BR} cannot be resolved in kotlin files during compile time
* for some reason, created this file to hold getters for {#link BR} fields
* that can then be accessed from said kotlin files.
*/
public class BRUtils {
private BRUtils() {}
public static int getMainViewModel() {
return BR.mainViewModel;
}
}
something.kt:
binding.setVariable(BRUtils.getMainViewModel(), ViewModel())

android package *.databinding does not exist

I read more links about this problem, but i dont know whats exactly problem of my project. i set dataBinding as true on build.gradle, below code is my application build.gradle file content
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.text.myapp"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://clojars.org/repo/" }
}
def support_library = "25.2.0"
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:appcompat-v7:${support_library}"
compile "com.android.support:support-v13:${support_library}"
compile "com.android.support:cardview-v7:${support_library}"
compile "com.android.support:recyclerview-v7:${support_library}"
}
My activity:
public class ActivityRegister extends AppCompatActivity {
private ActivityRegisterBinding binding;
#Override
public void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_register);
}
}
and then, activity layout
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="presenter"
type="ir.pishguy.cafealachiqpro.Ui.Register.ActivityMain.Model.ActivityRegisterViewModel"/>
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="-5dp"
android:orientation="vertical">
<TextView
android:id="#+id/default_port"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="#dimen/default_textview_height"/>
</LinearLayout>
</layout>
Error on Logcat:
/Users/mahdi/Desktop/Home/Projects/Android/CafeAlachiqPro/app/src/main/java/com/text/myapp/Ui/Register/ActivityMain/Presenter/ActivityRegister.java
Error:(11, 45) error: package com.text.myapp.databinding does not exist
Error:(19, 13) error: cannot find symbol class ActivityRegisterBinding
Warning:The following options were not recognized by any processor:
'[android.databinding.artifactType, android.databinding.printEncodedErrors, android.databinding.minApi, android.databinding.isTestVariant, android.databinding.enableDebugLogs, android.databinding.sdkDir, android.databinding.bindingBuildFolder, android.databinding.enableForTests, android.databinding.modulePackage, android.databinding.generationalFileOutDir, android.databinding.xmlOutDir]'
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
My viewModel:
public class ActivityRegisterViewModel extends BaseObservable {
private String readContactPermission;
private String getMessages;
public ActivityRegisterViewModel() {
}
#Bindable
public String getReadContactPermission() {
return readContactPermission;
}
public void setReadContactPermission(String readContactPermission) {
this.readContactPermission = readContactPermission;
notifyChange();
}
public String getGetMessages() {
return getMessages;
}
public void setGetMessages(String getMessages) {
this.getMessages = getMessages;
}
}
Remove
apply plugin: 'com.neenbedankt.android-apt'
and
apt "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}"
from gradle. This helps me to get rid of this error.
Although I could run your project cause ir.pishguy.cafealachiqpro.Ui.Register.Robot.Model.RobotViewModel can not be resolved from robot_user_action.xml
<data class="UserMessagesDataBinding">
<variable
name="viewModel"
type="ir.pishguy.cafealachiqpro.Ui.Register.Robot.Model.RobotViewModel">
</variable>
</data>
Please mention the variable tag which defines your viewmodel as follows :
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="<variablename>"
type="<packagename.YourViewModel>" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="-5dp"
android:orientation="vertical">
<TextView
android:id="#+id/default_port"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="#dimen/default_textview_height"/>
</LinearLayout>
</layout>

OnClick linstener using Butterknife not working

OnClick linstener using Butterknife is not working when i click button it's not happening any thing,someone please check the code below and suggest me any modifications if any.
MainActivity.java
package com.example.niranjan.sample;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class MainActivity extends AppCompatActivity {
#BindView(R.id.button)
Button button;
#BindView(R.id.edit)
EditText edit;
#BindView(R.id.text)
TextView text;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
}
#OnClick(R.id.button)
public void onClick(View view)
{
String text1 = edit.getText().toString();
text.setText(text1);
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.niranjan.sample.MainActivity">
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/edit"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="addtext" />
</LinearLayout>
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.niranjan.sample"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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:24.2.1'
compile 'com.jakewharton:butterknife:8.4.0'
testCompile 'junit:junit:4.12'
}
I done below steps and successfully implemented butter knife
In build.gradle(project)
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apply the 'android-apt' and dependency in build.gradle(app)
apply plugin: 'android-apt'
android {
...
}
dependencies {
compile 'com.jakewharton:butterknife:8.4.0'
apt 'com.jakewharton:butterknife-compiler:8.4.0'
}
I had the same problem, try this in your build.gradle(Module.app)
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
and then
apt 'com.jakewharton:butterknife-compiler:8.4.0'
also do not forget
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' in build.gradle(Project)
You neeed to add apt 'com.jakewharton:butterknife-compiler:8.4.0' under apply plugin in build.gradle
Also add
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
In your project build.gradle inside buildScript->dependencies

Categories

Resources