search

Home  >  Q&A  >  body text

android - 使用butterknife,不能编译通过

package com.aa.safe.safehei.activities;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import com.aa.safe.safe.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class DogActivity extends AppCompatActivity {


    @BindView(R.id.tv_islocked_notselect)
    TextView mTvIslockedNotselect;
    @BindView(R.id.tv_islocked_select)
    TextView mTvIslockedSelect;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dog);
        ButterKnife.bind(this);
    }

}

使用butterknife后
在app/build/generated/source/apt/debug/包名/DogActivity$$ViewBinder
下提示报错

import butterknife.internal.Finder;
import butterknife.internal.ViewBinder;

提示这二个类找不到,我看了下的确是没有的

messages 窗口也提示找不到符号........

ringa_leeringa_lee2773 days ago500

reply all(3)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 17:58:35

        @Bind(R.id.drawer_layout)
        DrawerLayout drawerLayout;
        @Bind(R.id.nav_view)
        NavigationView navigationView;
        @Bind(R.id.toolbar)
        Toolbar toolbar;
        @Bind(R.id.main_container)
        FrameLayout mainContainer;
        ActionBarDrawerToggle mActionBarDrawerToggle;
        FragmentManager fragmentManager;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            ButterKnife.bind(this);
            ···
            }

    What version are you using? This is 7.0.1

    compile 'com.jakewharton:butterknife:7.0.1'

    reply
    0
  • 黄舟

    黄舟2017-04-17 17:58:35

    butterknife cannot be used in the library project, I don’t know if this is the case for you,

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 17:58:35

    The 8.1.0 version I use needs to add apt 'com.jakewharton:butterknife-compiler:8.1.0'
    in gradle. It is used for pre-compilation. I don’t know if it is required for 7.0

    reply
    0
  • Cancelreply