当前,我在项目的导航视图中遇到错误,当应用程序尝试显示时,它只是停止了,并且找不到任何可以帮助我的答案。
这是错误。
09-11 18:54:23.160 16755-16755/co.cloudtechnologys.www.contol_academic_student E/AndroidRuntime: FATAL EXCEPTION: main
Process: co.cloudtechnologys.www.contol_academic_student, PID: 16755
java.lang.RuntimeException: Unable to start activity ComponentInfo{co.cloudtechnologys.www.contol_academic_student/co.cloudtechnologys.www.contol_academic_student.Views.MainActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class android.support.design.widget.NavigationView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3319)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class android.support.design.widget.NavigationView
at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at co.cloudtechnologys.www.contol_academic_student.Views.MainActivity.onCreate(MainActivity.java:138)
at android.app.Activity.performCreate(Activity.java:6904)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class android.support.design.widget.NavigationView
at android.view.LayoutInflater.createView(LayoutInflater.java:657)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at co.cloudtechnologys.www.contol_academic_student.Views.MainActivity.onCreate(MainActivity.java:138)
at android.app.Activity.performCreate(Activity.java:6904)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:631)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at co.cloudtechnologys.www.contol_academic_student.Views.MainActivity.onCreate(MainActivity.java:138)
at android.app.Activity.performCreate(Activity.java:6904)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.NoSuchFieldError: No static field MenuItem_iconTintMode of type I in class Landroid/support/v7/appcompat/R$styleable; or its superclasses (declaration of 'android.support.v7.appcompat.R$styleable' appears in /data/app/co.cloudtechnologys.www.contol_academic_student-1/base.apk)
at android.support.v7.view.SupportMenuInflater$MenuState.readItem(SupportMenuInflater.java:435)
at android.support.v7.view.SupportMenuInflater.parseMenu(SupportMenuInflater.java:177)
at android.support.v7.view.SupportMenuInflater.inflate(SupportMenuInflater.java:127)
at android.support.design.widget.NavigationView.inflateMenu(NavigationView.java:248)
at android.support.design.widget.NavigationView.<init>(NavigationView.java:172)
at android.support.design.widget.NavigationView.<init>(NavigationView.java:98)
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:631)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at co.cloudtechnologys.www.contol_academic_student.Views.MainActivity.onCreate(MainActivity.java:138)
at android.app.Activity.performCreate(Activity.java:6904)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
在添加领域库之前,一切工作都很好,但是我需要制作该应用程序的新部分,我尝试重新创建整个项目,但不起作用,最终出现相同的错误。
这是我的应用模块。
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 27
defaultConfig {
applicationId "co.cloudtechnologys.www.contol_academic_student"
minSdkVersion 16
targetSdkVersion 27
versionCode 39
versionName "1.0.35"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy {
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.android.gms:play-services-gcm:12.0.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.mcxiaoke.volley:library:1.0.19'
implementation 'com.j256.ormlite:ormlite-android:4.48'
implementation 'it.sephiroth.android.library.picasso:picasso:2.5.2.4b'
implementation 'de.hdodenhof:circleimageview:2.0.0'
implementation 'com.akexorcist:RoundCornerProgressBar:2.0.3'
implementation 'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'
implementation 'com.github.chrisbanes:PhotoView:2.1.3'
implementation 'uk.co.samuelwall:material-tap-target-prompt:1.7.0'
implementation 'com.github.sundeepk:compact-calendar-view:1.9.9'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services-maps:12.0.1'
implementation 'com.github.thomper:sweet-alert-dialog:v1.4.0'
implementation 'com.facebook.shimmer:shimmer:0.2.0'
implementation files('libs/YouTubeAndroidPlayerApi.jar')
}
这是具有导航视图的 activity_main 。
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#ffff">
<TextView
android:id="@+id/colegioTextDrawable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/md_grey_500" />
<TextView
android:id="@+id/version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/colegioTextDrawable"
android:layout_marginBottom="15dp"
android:gravity="center"
android:textColor="@color/md_grey_400"
android:textSize="10dp" />
</RelativeLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
主要活动类,该类中有很多代码,因此我将在其中使用这些部分。
public class MainActivity extends AppCompatActivity {
private RealmConfiguration realmConfiguration;
private DrawerLayout drawer;
private NavigationView navigationView;
private ActualizarVersionController mActualizarVersionController;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
navigationView = (NavigationView) findViewById(R.id.nav_view);
mContext = this;
}
private void setupNavigationDrawerContent(NavigationView navigationView) {
View headerView = navigationView.getHeaderView(0);
TextView emailText = (TextView) headerView.findViewById(R.id.IDnombreDraw);
tipoU = (TextView) headerView.findViewById(R.id.TipoUsuarioNH);
navigationView.setNavigationItemSelectedListener(
menuItem -> {
switch (menuItem.getItemId()) {
case R.id.inasistencia:
menuItem.setChecked(true);
drawer.closeDrawer(GravityCompat.START);
Intent intent = new Intent(MainActivity.this, Inasistencias.class);
overridePendingTransition(R.anim.left_int, R.anim.left_out);
startActivity(intent);
finish();
return true;
case R.id.tesoreria:
menuItem.setChecked(true);
drawer.closeDrawer(GravityCompat.START);
Intent intentT = new Intent(MainActivity.this, ExpandibleTesoreria.class);
startActivity(intentT);
finish();
break;
case R.id.perfil:
//menuItem.setChecked(true);
//drawerLayout.closeDrawer(GravityCompat.START);
return true;
case R.id.ajuste:
menuItem.setChecked(true);
Intent inte = new Intent(MainActivity.this, Ajustes.class);
inte.putExtra("Menu", "menu");
overridePendingTransition(R.anim.left_int, R.anim.left_out);
startActivity(inte);
finish();
drawer.closeDrawer(GravityCompat.START);
return true;
case R.id.CerrarS:
menuItem.setChecked(true);
startActivity(new Intent(MainActivity.this, Login.class));
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
Principal.cerrarSessionToken(MainActivity.this, getString(R.string.url), Volley.newRequestQueue(MainActivity.this));
MainActivity.this.finish();
DataBaseHelper dataBaseHelper = new DataBaseHelper(MainActivity.this);
dataBaseHelper.onResetUsuarios();
dataBaseHelper.onResetEstudiantes();
dataBaseHelper.onResetSincronizacion();
dataBaseHelper.onResetToken();
dataBaseHelper.onResetModelos();
dataBaseHelper.onResetCalendario();
dataBaseHelper.onResetPromedioEstudiante();
dataBaseHelper.onResetPeriodo();
dataBaseHelper.onResetProcesos();
dataBaseHelper.onResetSubProcesos();
dataBaseHelper.onResetMinMaxEstadoAcademico();
dataBaseHelper.onResetProcesosDim();
dataBaseHelper.onResetSubProcesosDim();
dataBaseHelper.onResetAsignaturas();
dataBaseHelper.onResetConfiguracion();
dataBaseHelper.onResetHorarioEstudiante();
dataBaseHelper.onResetCantidadEventos();
dataBaseHelper.onResetMensajeria();
dataBaseHelper.onResetEstudianteBD();
dataBaseHelper.onResetItemTiendaVirtual();
dataBaseHelper.onResetDetalleItemTiendaVirtual();
dataBaseHelper.onResetBalanceTienda();
dataBaseHelper.onResetEscalaValorativa();
MainActivity.clearBadge(MainActivity.this);
Realm.deleteRealm(realmConfiguration);
drawer.closeDrawer(GravityCompat.START);
return true;
//Excusas por el movil
// case R.id.excusas:
// Intent i = new Intent(Inasistencias.this, ResponderExcusas.class);
// startActivity(i);
// finish();
// return true;
case R.id.cambioHijo:
if (tipo.equals("6")) {
menuItem.setChecked(true);
Intent intentCH = new Intent(MainActivity.this, Principal.class);
startActivity(intentCH);
DataBaseHelper dataBaseHelper2 = new DataBaseHelper(MainActivity.this);
dataBaseHelper2.onResetSincronizacion();
dataBaseHelper2.onResetEstudiantes();
dataBaseHelper2.onResetPromedioEstudiante();
dataBaseHelper2.onResetPeriodo();
dataBaseHelper2.onResetProcesos();
dataBaseHelper2.onResetSubProcesos();
dataBaseHelper2.onResetMinMaxEstadoAcademico();
dataBaseHelper2.onResetProcesosDim();
dataBaseHelper2.onResetSubProcesosDim();
dataBaseHelper2.onResetAsignaturas();
dataBaseHelper2.onResetConfiguracion();
dataBaseHelper2.onResetHorarioEstudiante();
dataBaseHelper2.onResetItemTiendaVirtual();
dataBaseHelper2.onResetDetalleItemTiendaVirtual();
dataBaseHelper2.onResetBalanceTienda();
overridePendingTransition(R.anim.left_int, R.anim.left_out);
finish();
drawer.closeDrawer(GravityCompat.START);
} else {
//menuItem.setVisibility(View.GONE);
menuItem.setVisible(false);
}
break;
case R.id.agenda:
Intent intentA = new Intent(MainActivity.this, Agenda.class);
startActivity(intentA);
finish();
menuItem.setChecked(true);
drawer.closeDrawer(GravityCompat.START);
break;
case R.id.mensajeria:
Intent intentM = new Intent(MainActivity.this, Mensajeria.class);
intentM.putExtra("Menu", "Menu");
overridePendingTransition(R.anim.left_int, R.anim.left_out);
startActivity(intentM);
finish();
menuItem.setChecked(true);
drawer.closeDrawer(GravityCompat.START);
break;
case R.id.estadoacademicom:
menuItem.setChecked(true);
drawer.closeDrawer(GravityCompat.START);
Intent intentE;
if (coddimenval != null && !coddimenval.equals("") && !coddimenval.equals("null")) {
if (Integer.parseInt(coddimenval) > 0) {
intentE = new Intent(MainActivity.this, Activity_Dimension_Valorativa.class);
overridePendingTransition(R.anim.left_int, R.anim.left_out);
} else {
intentE = new Intent(MainActivity.this, Estado_Academico_Estudiantes.class);
overridePendingTransition(R.anim.left_int, R.anim.left_out);
}
overridePendingTransition(R.anim.left_int, R.anim.left_out);
startActivity(intentE);
finish();
} else {
Funciones f = new Funciones();
f.Alerta("Necesitas descargar la información del estudiante", MainActivity.this);
}
break;
case R.id.horario:
Intent i;
i = new Intent(MainActivity.this, horarioEstudianteVista.class);
startActivity(i);
finish();
menuItem.setChecked(true);
drawer.closeDrawer(GravityCompat.START);
break;
case R.id.excusas:
Intent i2;
i2 = new Intent(MainActivity.this, ResponderExcusas.class);
startActivity(i2);
finish();
menuItem.setChecked(true);
drawer.closeDrawer(GravityCompat.START);
break;
case R.id.incidente:
startActivity(new Intent(MainActivity.this, Incidencias.class));
finish();
menuItem.setChecked(true);
drawer.closeDrawer(GravityCompat.START);
break;
case R.id.tienda:
startActivity(new Intent(MainActivity.this, Alimentacion.class));
finish();
menuItem.setChecked(true);
drawer.closeDrawer(GravityCompat.START);
break;
case R.id.transporte:
menuItem.setChecked(true);
drawer.closeDrawer(GravityCompat.START);
Intent t = new Intent(MainActivity.this, TransporteActivity.class);
startActivity(t);
finish();
return true;
case R.id.enfermeria:
Intent enfermeria1 = new Intent(MainActivity.this, EnfermeriaActivity.class);
startActivity(enfermeria1);
finish();
menuItem.setChecked(true);
drawer.closeDrawer(GravityCompat.START);
break;
case R.id.aula:
Intent aula = new Intent(MainActivity.this, aulaVirtual.class);
startActivity(aula);
finish();
menuItem.setChecked(true);
drawer.closeDrawer(GravityCompat.START);
break;
}
return true;
});
}
感谢您的帮助,谢谢。