无法打开导航抽屉:没有发现重力右抽屉视图
Unable to open navigation drawer: No drawer view found with gravity RIGHT
昨天一切正常,但今天我又开始在我的应用程序中工作,在 activity 的 xml 文件中,但 Android Studio 在 phone 接口(通常位于右侧的那个接口,就在 XML 代码旁边。)它说这是一个渲染问题。
Here you can see that the layou is displayed normally but i can't see my edits until I run the app
java.lang.IllegalArgumentException: No drawer view found with gravity RIGHT
at androidx.drawerlayout.widget.DrawerLayout.openDrawer(DrawerLayout.java:1736)
at androidx.drawerlayout.widget.DrawerLayout.openDrawer(DrawerLayout.java:1722)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.android.layoutlib.bridge.util.ReflectionUtils.invoke(ReflectionUtils.java:56)
at com.android.layoutlib.bridge.android.support.DrawerLayoutUtil.openDrawer(DrawerLayoutUtil.java:59)
at com.android.layoutlib.bridge.android.support.DrawerLayoutUtil.openDrawer(DrawerLayoutUtil.java:53)
at android.view.BridgeInflater.postInflateProcess(BridgeInflater.java:577)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.postInflateProcess(RenderSessionImpl.java:702)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.postInflateProcess(RenderSessionImpl.java:707)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:338)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:373)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:141)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:713)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate(RenderTask.java:844)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
请注意,此错误不会显示在 logcat 中,因为除可视化工具外,所有内容都是 运行。
它说的是没有重力正确的抽屉视图,当然没有。但是IDK为什么现在正在搜索它。
这是我的代码。我已经使用过此配置,所以我认为这不是问题所在。
<androidx.drawerlayout.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_dar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="end"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar_dar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/itemBlueDark"
app:title="Sube tu objeto"/>
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:id="@+id/title_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Categoría"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
>
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/spinner_Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:inputType="none"
/>
</com.google.android.material.textfield.TextInputLayout>
<Spinner
android:id="@+id/spinner"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/transparent"
android:spinnerMode="dialog"
tools:listitem="@layout/spinner_layout"
/>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/nombre_objeto"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginTop="10dp"
android:layout_marginRight="12dp"
android:background="@color/white"
android:hint="@string/nombre_objeto">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/nombre_objeto_editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/desc_objeto"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginTop="10dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="12dp"
android:background="@color/white"
android:hint="@string/descripcion_objeto">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/desc_objeto_editText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="@+id/img_objeto"
android:layout_width="274dp"
android:layout_height="240dp"
android:layout_gravity="center"
android:layout_marginTop="24dp"
android:src="@drawable/sin_foto" />
<Button
android:id="@+id/btn_enviar_imagen"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_gravity="center"
android:layout_marginTop="60dp"
android:layout_marginBottom="40dp"
android:background="@drawable/forma_btn"
app:backgroundTint="@color/itemBlueDark"
android:text="Subir" />
<Button
android:id="@+id/btn_listaUsuarios"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/cabecera_menu"
app:menu="@menu/menu_drawer" />
</androidx.drawerlayout.widget.DrawerLayout>
here you can see that there is a problem w/ the Layout Rendering Engine. I've tried to enable/disable it but it seems it does not work
Here you can see other errors related to the rendering
Althouhg other XML files have the same render issues, AndroidStudio display the desing visualizator properly
编辑:这是我的依赖项,也许其中有些是错误的,但我对此表示怀疑。
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.Trueque"
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
//para las cajas de texto
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
//Para dependencias de firebase
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//Para las tabs deslizantes
implementation "androidx.viewpager2:viewpager2:1.0.0"
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:28.2.0')
// Declare the dependency for the Realtime Database library
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-database'
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:28.2.0')
// Declare the dependency for the Firebase Authentication library
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-storage:20.0.0'
implementation 'com.google.firebase:firebase-auth:21.0.1'
}
我已通过删除 XML 文件中的以下行来修复它。
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/title_spinner"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:hint="Categoría">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/spinner_Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:inputType="none" />
</com.google.android.material.textfield.TextInputLayout>
<Spinner
android:id="@+id/spinner"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/transparent"
android:spinnerMode="dialog"
tools:listitem="@layout/spinner_layout" />
昨天一切正常,但今天我又开始在我的应用程序中工作,在 activity 的 xml 文件中,但 Android Studio 在 phone 接口(通常位于右侧的那个接口,就在 XML 代码旁边。)它说这是一个渲染问题。 Here you can see that the layou is displayed normally but i can't see my edits until I run the app
java.lang.IllegalArgumentException: No drawer view found with gravity RIGHT
at androidx.drawerlayout.widget.DrawerLayout.openDrawer(DrawerLayout.java:1736)
at androidx.drawerlayout.widget.DrawerLayout.openDrawer(DrawerLayout.java:1722)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.android.layoutlib.bridge.util.ReflectionUtils.invoke(ReflectionUtils.java:56)
at com.android.layoutlib.bridge.android.support.DrawerLayoutUtil.openDrawer(DrawerLayoutUtil.java:59)
at com.android.layoutlib.bridge.android.support.DrawerLayoutUtil.openDrawer(DrawerLayoutUtil.java:53)
at android.view.BridgeInflater.postInflateProcess(BridgeInflater.java:577)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.postInflateProcess(RenderSessionImpl.java:702)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.postInflateProcess(RenderSessionImpl.java:707)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:338)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:373)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:141)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:713)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate(RenderTask.java:844)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
请注意,此错误不会显示在 logcat 中,因为除可视化工具外,所有内容都是 运行。 它说的是没有重力正确的抽屉视图,当然没有。但是IDK为什么现在正在搜索它。
这是我的代码。我已经使用过此配置,所以我认为这不是问题所在。
<androidx.drawerlayout.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_dar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="end"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar_dar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/itemBlueDark"
app:title="Sube tu objeto"/>
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:id="@+id/title_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Categoría"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
>
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/spinner_Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:inputType="none"
/>
</com.google.android.material.textfield.TextInputLayout>
<Spinner
android:id="@+id/spinner"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/transparent"
android:spinnerMode="dialog"
tools:listitem="@layout/spinner_layout"
/>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/nombre_objeto"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginTop="10dp"
android:layout_marginRight="12dp"
android:background="@color/white"
android:hint="@string/nombre_objeto">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/nombre_objeto_editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/desc_objeto"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginTop="10dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="12dp"
android:background="@color/white"
android:hint="@string/descripcion_objeto">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/desc_objeto_editText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="@+id/img_objeto"
android:layout_width="274dp"
android:layout_height="240dp"
android:layout_gravity="center"
android:layout_marginTop="24dp"
android:src="@drawable/sin_foto" />
<Button
android:id="@+id/btn_enviar_imagen"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_gravity="center"
android:layout_marginTop="60dp"
android:layout_marginBottom="40dp"
android:background="@drawable/forma_btn"
app:backgroundTint="@color/itemBlueDark"
android:text="Subir" />
<Button
android:id="@+id/btn_listaUsuarios"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/cabecera_menu"
app:menu="@menu/menu_drawer" />
</androidx.drawerlayout.widget.DrawerLayout>
here you can see that there is a problem w/ the Layout Rendering Engine. I've tried to enable/disable it but it seems it does not work
Here you can see other errors related to the rendering
Althouhg other XML files have the same render issues, AndroidStudio display the desing visualizator properly
编辑:这是我的依赖项,也许其中有些是错误的,但我对此表示怀疑。
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.Trueque"
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
//para las cajas de texto
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
//Para dependencias de firebase
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//Para las tabs deslizantes
implementation "androidx.viewpager2:viewpager2:1.0.0"
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:28.2.0')
// Declare the dependency for the Realtime Database library
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-database'
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:28.2.0')
// Declare the dependency for the Firebase Authentication library
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-storage:20.0.0'
implementation 'com.google.firebase:firebase-auth:21.0.1'
}
我已通过删除 XML 文件中的以下行来修复它。
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/title_spinner"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:hint="Categoría">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/spinner_Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:inputType="none" />
</com.google.android.material.textfield.TextInputLayout>
<Spinner
android:id="@+id/spinner"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/transparent"
android:spinnerMode="dialog"
tools:listitem="@layout/spinner_layout" />