Erreur de gonflage de la classe android.de soutien.de la conception.widget de.La fenêtre des éléments
J'ai suivi un tutoriel sur la mise en œuvre de la la fenêtre des éléments de la conception de la bibliothèque de prise en charge et je ne peux pas sortir de cette erreur ci-dessous. J'ai lu les autres solutions postées sur ce site, mais aucun d'entre eux travaillaient pour moi, s'il vous plaît aider.
Caused by: android.view.InflateException: Binary XML file line #28: Error inflating class android.support.design.widget.NavigationView
activity_main.xml
<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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/tool_bar"
layout="@layout/tool_bar" />
<FrameLayout
android:id="@+id/frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/header"
app:menu="@menu/drawer" />
</android.support.v4.widget.DrawerLayout>
MainActiviy.java
import android.support.design.widget.NavigationView;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
//Defining Variables
private Toolbar toolbar;
private NavigationView navigationView;
private DrawerLayout drawerLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Initializing Toolbar and setting it as the actionbar
toolbar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(toolbar);
//Initializing NavigationView
navigationView = (NavigationView) findViewById(R.id.navigation_view);
//Setting Navigation View Item Selected Listener to handle the item click of the navigation menu
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
//This method will trigger on item Click of navigation menu
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
//Checking if the item is in checked state or not, if not make it in checked state
if (menuItem.isChecked()) menuItem.setChecked(false);
else menuItem.setChecked(true);
//Closing drawer on item click
drawerLayout.closeDrawers();
//Check to see which item was being clicked and perform appropriate action
switch (menuItem.getItemId()) {
//Replacing the main content with ContentFragment Which is our Inbox View;
case R.id.inbox:
Toast.makeText(getApplicationContext(), "Inbox Selected", Toast.LENGTH_SHORT).show();
ContentFragment fragment = new ContentFragment();
android.support.v4.app.FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.frame, fragment);
fragmentTransaction.commit();
return true;
//For rest of the options we just show a toast on click
case R.id.starred:
Toast.makeText(getApplicationContext(), "Stared Selected", Toast.LENGTH_SHORT).show();
return true;
case R.id.sent_mail:
Toast.makeText(getApplicationContext(), "Send Selected", Toast.LENGTH_SHORT).show();
return true;
case R.id.drafts:
Toast.makeText(getApplicationContext(), "Drafts Selected", Toast.LENGTH_SHORT).show();
return true;
case R.id.allmail:
Toast.makeText(getApplicationContext(), "All Mail Selected", Toast.LENGTH_SHORT).show();
return true;
case R.id.trash:
Toast.makeText(getApplicationContext(), "Trash Selected", Toast.LENGTH_SHORT).show();
return true;
case R.id.spam:
Toast.makeText(getApplicationContext(), "Spam Selected", Toast.LENGTH_SHORT).show();
return true;
default:
Toast.makeText(getApplicationContext(), "Somethings Wrong", Toast.LENGTH_SHORT).show();
return true;
}
}
});
//Initializing Drawer Layout and ActionBarToggle
drawerLayout = (DrawerLayout) findViewById(R.id.drawer);
ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.openDrawer, R.string.closeDrawer) {
@Override
public void onDrawerClosed(View drawerView) {
//Code here will be triggered once the drawer closes as we dont want anything to happen so we leave this blank
super.onDrawerClosed(drawerView);
}
@Override
public void onDrawerOpened(View drawerView) {
//Code here will be triggered once the drawer open as we dont want anything to happen so we leave this blank
super.onDrawerOpened(drawerView);
}
};
//Setting the actionbarToggle to drawer layout
drawerLayout.setDrawerListener(actionBarDrawerToggle);
//calling sync state is necessay or else your hamburger icon wont show up
actionBarDrawerToggle.syncState();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
//Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
//Handle action bar item clicks here. The action bar will
//automatically handle clicks on the Home/Up button, so long
//as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
construire.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.0'
defaultConfig {
applicationId "com.example.mobinamanzai.projectalpha"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.0.0'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
}
EDIT:
Trace De La Pile
Causés par: android.vue.InflateException: Binaire dans le fichier XML de la ligne n ° 28: Erreur de gonflage de la classe android.de soutien.de la conception.widget de.La fenêtre des éléments
Causés par: java.lang.de réfléchir.InvocationTargetException
Causés par: android.vue.InflateException: Binaire dans le fichier XML de la ligne #2: Erreur de gonflage de la classe android.widget de.RelativeLayout
Causés par: java.lang.de réfléchir.InvocationTargetException
Causés par: java.lang.OutOfMemoryError: Impossible d'allouer un 276203532 allocation d'octets avec 12108696 octets libres et 174MB jusqu'OOM
EDIT 2: Le problème semble être dans le header.xml
juste édité
OriginalL'auteur Mobin Amanzai | 2015-09-01
Vous devez vous connecter pour publier un commentaire.
Tout a commencé à partir d'ici,
Parce qu'une image que vous utilisez pour l'en-tête ou en tant qu'éléments dans votre navigationdrawer a une résolution supérieure à celle de l'application de la mémoire allouée peut gérer. Réduire les dimensions des images et de les vérifier. Qui va résoudre le problème. Si vous ajoutez un peu plus de trace de la pile ci-dessous, vous pouvez trouver ce que l'élément exactement l'origine de ce problème.
OriginalL'auteur diyoda_
J'ai eu le inflater erreur pour le mode de Navigation lors du passage à Android support library version 23.1.0, compiler version du SDK 23 et construire les outils de la version 23.0.2.
Pour moi, il s'est avéré être un proguard question.
Ajoutez la ligne suivante à votre proguard configuration:
Voir Android Open Source Project Issue Tracker
Pour moi, la Force de fermeture, a déclaré Causés par: java.lang.ClassNotFoundException: android.de soutien.v7.widget de.LinearLayoutManager et donc le droit de fixer pour moi
Cela résout un problème différent, mais toujours agréable d'avoir ici
OriginalL'auteur Emanuel Seidinger
Oui, moi aussi suis même erreur.
Si vous regardez dans l'erreur soigneusement u trouverez ligne suivante
Causés par: java.lang.OutOfMemoryError: Impossible d'allouer un 276203532 allocation d'octets avec 12108696 octets libres et 174MB jusqu'OOM
Cela est résolu en réduisant la résolution des images qui sont utilisées pour le menu.
OriginalL'auteur onkar saravade