我的ButterKnife
库存在问题。同步gradle后我的视图停止了绑定 - 在它没有任何问题之前工作。
我附上了一些代码。
build.gradle(app)
compile 'com.jakewharton:butterknife:8.6.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
MainActivity
public class MainActivity extends AppCompatActivity {
@BindView(R.id.navigation)
BottomNavigationView navigation;
private Fragment fragment;
private FragmentManager fragmentManager;
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.navigation_home:
fragment = new HomeFragment();
break;
case R.id.navigation_dashboard:
fragment = new GraphFragment();
break;
case R.id.navigation_notifications:
fragment = new ProfileFragment();
break;
}
final FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.replace(R.id.content, fragment).commit();
return true;
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.setDebug(true);
ButterKnife.bind(this);
fragmentManager = getSupportFragmentManager();
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
}}
ButterKnife记录
D / ButterKnife:查找绑定 com.example.azkb.instproject.refactor.MainActivity D / ButterKnife:Not 找到。尝试超类android.support.v7.app.AppCompatActivity D / ButterKnife:MISS:达到了框架类。放弃搜索。
答案 0 :(得分:3)
当我将Kotlin添加到我的项目中时出现问题。
解决方案:
kapt'com.jakewharton:butterknife-compiler:8.7.0'
感谢downvoting:)