该应用程序在启动后立即崩溃,并出现错误:
11-08 21:13:08.704 15973-15973/com.t99sdevelopment.centralized E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.t99sdevelopment.centralized/com.t99sdevelopment.centralized.HomeScreen}: android.view.InflateException: Binary XML file line #81: Error inflating class android.support.design.widget.NavigationViewjava文件:
package com.t99sdevelopment.centralized;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.widget.Toolbar;
public class HomeScreen extends AppCompatActivity {
Intent intentHome = new Intent(this, HomeScreen.class);
Intent intentAnnouncements = new Intent(this, AnnouncementsScreen.class);
/*
Intent intentSchedule = new Intent(this, ScheduleScreen.class);
Intent intentCalendar = new Intent(this, CalendarScreen.class);
Intent intentContactBook = new Intent(this, ContactBookScreen.class);
Intent intentSportsSchedule = new Intent(this, SportsScheduleScreen.class);
Intent intentFrontAndCentral = new Intent(this, FrontAndCentralScreen.class);
Intent intentMap = new Intent(this, MapScreen.class);
Intent intentAccount = new Intent(this, AccountScreen.class);
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_homescreen);
setTheme(R.style.AppTheme);
}
private void goToHome(){
}
private void goToAnnouncements(){
startActivity(intentAnnouncements);
}
private void goToSchedule(){
}
private void goToCalendar(){
}
private void goToContactBook(){
}
private void goToSportsSchedule(){
}
private void goToFrontAndCentral(){
}
private void goToMap(){
}
private void goToAccount(){
}
}这个错误表示导航抽屉无法创建,但是从上次导航抽屉工作到现在,我没有改变任何看起来会影响它的东西。
我查看了代码,更改了一些内容,错误保持不变,但是代码不同,所以我提交了一个不同的新页面这里,解决了这个问题。
发布于 2015-11-09 06:39:21
如果你真的什么都没做,试着清除和构建项目,或者把代码复制到新的项目中。
发布于 2015-11-09 06:41:48
设计库和Proguard的23.1.0版本有一个问题。作为解决办法,您应该添加
-keep class android.support.v7.widget.LinearLayoutManager { *; } 敬你的卫兵规则。
看一下这个问题:NavigationView InflateException
https://stackoverflow.com/questions/33601566
复制相似问题