Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error:(38, 21) The method bind(LoginActivity) is undefined for the type ButterKnife #990

Closed
FantasyLand17 opened this issue Jun 25, 2017 · 4 comments

Comments

@FantasyLand17
Copy link

I am using Butterknife for the first time and I am not sure what I am doing wrong. I am getting the following error:

Error:(38, 21) The method bind(LoginActivity) is undefined for the type ButterKnife

Error:(36, 21) The method bind(SignupActivity) is undefined for the type ButterKnife

Error:Execution failed for task ':app:transformJackWithJackForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.core.JackToolchain$ToolchainException: Jack compilation exception

This is what my activities look like:

import com.myapp.R;

import butterknife.BindView;
import butterknife.ButterKnife;

public class LoginActivity extends Activity {
    private static final String TAG = "LoginActivity";
    private static final int REQUEST_SIGNUP = 0;

    @BindView(R.id.input_email) EditText _emailText;
    @BindView(R.id.input_password) EditText _passwordText;
    @BindView(R.id.btn_login) Button _loginButton;
    @BindView(R.id.link_signup) TextView _signupLink;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login_main);
        ButterKnife.bind(this);
...

And

import com.myapp.R;
import butterknife.ButterKnife;
import butterknife.BindView;

public class SignupActivity extends Activity {
    private static final String TAG = "SignupActivity";

    @BindView(R.id.input_name) EditText _nameText;
    @BindView(R.id.input_email) EditText _emailText;
    @BindView(R.id.input_password) EditText _passwordText;
    @BindView(R.id.btn_signup) Button _signupButton;
    @BindView(R.id.link_login) TextView _loginLink;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.signup_main);
        ButterKnife.bind(this);
...

I have this in my gradle.properties:

org.gradle.jvmargs=-Xmx1536m

These are my dependencies for butterknife:

compile 'com.jakewharton:butterknife:8.6.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'

Here's my gradle's main settings:

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.3'
    aaptOptions.cruncherEnabled = false
    aaptOptions.useNewCruncher = false

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        jackOptions {
            enabled true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
@JakeWharton
Copy link
Owner

JakeWharton commented Jun 25, 2017 via email

@FantasyLand17
Copy link
Author

Great suggestion! I just tried it and it did work. I am wondering if there's a workaround to keep jack on and still be able to use butterknife?

@JakeWharton
Copy link
Owner

JakeWharton commented Jun 25, 2017 via email

@FantasyLand17
Copy link
Author

Thanks for letting me know, Jack. I wasn't aware of that. I'll definitely try to migrate away from it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants