简体   繁体   English

与模拟器不同,Android 应用程序 UI 无法在物理设备上正确显示

[英]Android app UI isn't displaying properly on physical device, unlike emulator

I'm getting into Android development and making a calculator.我正在开发 Android 并制作计算器。

The application works properly on a Pixel 3a emulator, but when I try it on my physical Samsung with Android 8.1 the UI isn't what it's supposed to be.该应用程序在 Pixel 3a 模拟器上正常工作,但是当我在我的物理三星上使用 Android 8.1 尝试它时,UI 不是它应该的样子。 The text on the buttons isn't showing, the buttons do appear as if they are being pressed when I press them, and the TextView is updating.按钮上的文字没有显示,当我按下按钮时,它们看起来好像正在被按下,并且 TextView 正在更新。

Layout:布局:

 <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" tools:ignore="HardcodedText"> <LinearLayout android:id="@+id/linearLayout" android:layout_width="0dp" android:layout_height="0dp" android:orientation="vertical" app:layout_constraintBottom_toTopOf="@+id/guideline" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> <TextView android:id="@+id/formula" style="@style/Formula" android:layout_width="match_parent" android:layout_height="wrap_content" tools:text="1-1" /> <TextView android:id="@+id/result" style="@style/Result" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="0" /> </LinearLayout> <androidx.constraintlayout.widget.Guideline android:id="@+id/guideline" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" app:layout_constraintGuide_percent="0.25"/> <androidx.gridlayout.widget.GridLayout android:id="@+id/buttons_layout" android:layout_width="0dp" android:layout_height="0dp" app:columnCount="4" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="@+id/guideline" app:rowCount="5"> <Button android:id="@+id/clear" style="@style/MyButton.Additional" android:text="C" /> <Button android:id="@+id/parenthesis" style="@style/MyButton.Additional" android:text="()" /> <Button android:id="@+id/backspace" style="@style/MyButton.Additional" android:foreground="@drawable/backspace" android:foregroundGravity="center"/> <Button android:id="@+id/division" style="@style/MyButton.Arithmetic" android:text="/" /> <Button android:id="@+id/number_seven" style="@style/MyButton" android:text="7" /> <Button android:id="@+id/number_eight" style="@style/MyButton" android:text="8" /> <Button android:id="@+id/number_nine" style="@style/MyButton" android:text="9" /> <Button android:id="@+id/multiplication" style="@style/MyButton.Arithmetic" android:text="*" /> <Button android:id="@+id/number_four" style="@style/MyButton" android:text="4" /> <Button android:id="@+id/number_five" style="@style/MyButton" android:text="5" /> <Button android:id="@+id/number_six" style="@style/MyButton" android:text="6" /> <Button android:id="@+id/subtraction" style="@style/MyButton.Arithmetic" android:text="-" /> <Button android:id="@+id/number_one" style="@style/MyButton" android:text="1" /> <Button android:id="@+id/number_two" style="@style/MyButton" android:text="2" /> <Button android:id="@+id/number_three" style="@style/MyButton" android:text="3" /> <Button android:id="@+id/addition" style="@style/MyButton.Arithmetic" android:text="+" /> <Button android:id="@+id/positive_negative" style="@style/MyButton" android:text="00" /> <Button android:id="@+id/number_zero" style="@style/MyButton" android:text="0" /> <Button android:id="@+id/decimal" style="@style/MyButton" android:text="." /> <Button android:id="@+id/total" style="@style/MyButton.Result" android:text="=" /> </androidx.gridlayout.widget.GridLayout> </androidx.constraintlayout.widget.ConstraintLayout>

Logcat shows: Logcat 显示:

2021-01-20 07:23:55.156 16582-16582/? E/libpersona: scanKnoxPersonas
2021-01-20 07:23:55.156 16582-16582/? E/libpersona: Couldn't open the File - /data/system/users/0/personalist.xml - No such file or directory
2021-01-20 07:23:55.161 16582-16582/? W/SELinux: SELinux selinux_android_compute_policy_index : Policy Index[2],  Con:u:r:zygote:s0 RAM:SEPF_SAMSUNG-SM-J727A_8.1.0_0004, [-1 -1 -1 -1 0 1]
2021-01-20 07:23:55.162 16582-16582/? I/SELinux: SELinux: seapp_context_lookup: seinfo=untrusted, level=s0:c512,c768, pkgname=org.obebeokeke.calculator 
2021-01-20 07:23:55.166 16582-16582/? I/zygote: Late-enabling -Xcheck:jni
2021-01-20 07:23:55.229 16582-16582/? D/TimaKeyStoreProvider: TimaKeyStore is not enabled: cannot add TimaSignature Service and generateKeyPair Service
2021-01-20 07:23:55.229 16582-16582/? D/ActivityThread: Added TimaKeyStore provider
2021-01-20 07:23:55.492 16582-16582/org.obebeokeke.calculator I/zygote: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
2021-01-20 07:23:55.492 16582-16582/org.obebeokeke.calculator I/zygote:     at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2678)
2021-01-20 07:23:55.492 16582-16582/org.obebeokeke.calculator I/zygote:     at void androidx.appcompat.widget.ActionBarContainer.<init>(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:63)
2021-01-20 07:23:55.492 16582-16582/org.obebeokeke.calculator I/zygote:     at java.lang.Object java.lang.reflect.Constructor.newInstance0(java.lang.Object[]) (Constructor.java:-2)
2021-01-20 07:23:55.492 16582-16582/org.obebeokeke.calculator I/zygote:     at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:334)
2021-01-20 07:23:55.492 16582-16582/org.obebeokeke.calculator I/zygote:     at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:647)
2021-01-20 07:23:55.492 16582-16582/org.obebeokeke.calculator I/zygote:     at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:790)
2021-01-20 07:23:55.492 16582-16582/org.obebeokeke.calculator I/zygote:     at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:730)
2021-01-20 07:23:55.492 16582-16582/org.obebeokeke.calculator I/zygote:     at void android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:863)
2021-01-20 07:23:55.492 16582-16582/org.obebeokeke.calculator I/zygote:     at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:824)
2021-01-20 07:23:55.492 16582-16582/org.obebeokeke.calculator I/zygote:     at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:515)
2021-01-20 07:23:55.492 16582-16582/org.obebeokeke.calculator I/zygote:     at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:423)
2021-01-20 07:23:55.492 16582-16582/org.obebeokeke.calculator I/zygote:     at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:374)

This is what I'm supposed to see/what I am seeing in the emulator这是我应该看到的/我在模拟器中看到的

This is what I see on the physical device这是我在物理设备上看到的

EDIT 1:编辑1:

I have tried invalidating cache/restarting, I also restarted my PC and phone, no change.我试过无效缓存/重启,我也重启了我的电脑和手机,没有任何变化。

EDIT 2:编辑2:

My friend tried it in his phone and it worked, so somethings wrong with my phone.我的朋友在他的手机上尝试过它并且它有效,所以我的手机有问题。

Maybe just invalidate chaches and restart?也许只是使chaches无效并重新启动?

I did a factory reset on my phone and it worked, no idea why it wasn't.我在手机上恢复了出厂设置,它工作正常,不知道为什么它没有。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter 应用程序在 Android 模拟器上运行,但不在物理设备上(OnePlus 7T) - Flutter app is running on Android Emulator but not on Physical Device (OnePlus 7T) 仅在物理设备而非模拟器上运行 Android 应用 - Run Android app Only on Physical Device not Emulator Android 设备 ID 在物理设备和模拟器上不匹配 - Android device id doesn't match on Physical Device & Emulator 带有react-native的Android应用程序可以在模拟器上运行,但不能在物理设备上运行 - Android app with react-native works on emulator but doesn't on physical device Flutter 应用程序在 android 工作室模拟器上完美运行,但 go 无法通过物理设备上的加载屏幕 - Flutter app runs perfectly on android studio emulator but doesn't go past the loading screen on physical device Xamarin Forms / Android map app在模拟器上运行,但在物理设备上崩溃 - Xamarin Forms/Android map app runs on emulator, but crashes on physical device 无法在物理设备或模拟器上运行 flutter 应用程序 - can't run flutter app on physical device or emulator Android 模拟器不时显示“系统 UI 没有响应”对话框 - Android Emulator displaying "System UI isn't responding" dialog from time to time 如何使模拟器与物理设备具有相同的UI - how to have an emulator of same UI as of physical device Android模拟器无法正确显示TextView(在设备上正常运行) - Android emulator not displaying a TextView properly (works fine on device)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM