hi i have got a problem when i was making a navigation drawer. it show me two :
"Error parsing XML: duplicate attribute"
one of them is about my main layout and another is about my
E:\MyApplication\app\build\intermediates\res\merged\debug\layout\main.xml
and in the down of this two error that show me this:
"Error:Execution failed for task ':app:processDebugResources'. com.android.ide.common.process.ProcessException: Failed to execute aapt" error too.
and in the preview that say me i have two render error with these subjects
"compilation errors" and "Missing classes"
and this is my Main Activity:
package com.example.mehrad.myapplication; import android.content.Context; import android.content.SharedPreferences; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; public class MainActivity extends AppCompatActivity { private SharedPreferences sharedPreferences; private DrawerLayout drawerLayout; private NavigationView navigationView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); new MyShared(this); new Names("first one"); new Names("second one"); RecyclerView recyclerView=(RecyclerView)findViewById(R.id.rec); LinearLayoutManager linearLayoutManager=new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false); recyclerView.setLayoutManager(linearLayoutManager); MyAdapter myAdapter=new MyAdapter(this); recyclerView.setAdapter(myAdapter); drawerLayout =(DrawerLayout) findViewById(R.id.dl); navigationView=(NavigationView)findViewById(R.id.nv); } }
and this is my main layout:
<?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"
android:id="@+id/dl"
android:fitsSystemWindows="true"
android:layout_width="wrap_content"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<include layout="@layout/activity_main"/>
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_gravity="right"
android:id="@+id/nv"
app:headerLayout="@layout/header"
app:menu="@menu/menu"
android:layout_height="match_parent"/>
</android.support.v4.widget.DrawerLayout>
and this is my Activity main:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.mehrad.myapplication.MainActivity">
<android.support.v7.widget.RecyclerView
android:id="@+id/rec"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false" />
</LinearLayout>
and this is my app file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.mehrad.myapplication"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-
core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
}
this is my header:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:src="@drawable/header"
android:id="@+id/image"
android:layout_height="220dp" />
</LinearLayout>
and this is my menu:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/favorite" android:title="list"/>
<item android:id="@+id/about" android:title="about us"/>
<item android:id="@+id/exit" android:title="exit"/>
</menu>
help me please