- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在为我的一门大学编码类(class)开发一个游戏项目(用 Java 编写),我使用的是 Android Studio。我了解 Java 基础知识,但我是 Android Studio 的新手。我的主要问题与在旧版 API/SDK 上运行/测试我的项目有关,特别是在旧手机上。
我一直在基于 API 26 的 Android 8.0 (Oreo) 上进行开发,尽管我也安装了 Pie (API 28)。目前我的targetSDKVersion是26,compileSDKVersion是26,minSDKVersion是19。
我正在尝试在 Samsung Galaxy S4 (API 19) 上运行我的应用程序(称为 AMaze),这就是我的 minSDKVersion 为 19 的原因。它在支持 Android 8.0 及更高版本的手机上运行完全正常,据我所知'意识到。但是当我在我的 Galaxy S4 上运行该应用程序时,它会打开并立即崩溃并显示“不幸的是,您的应用程序已停止”。我不知道如何解决这个问题。
我已在 StackOverflow 和 Android 开发者网站上搜索答案,但运气极差。我试过使用 gradle 清理和重建项目,我试过禁用 Instant Run,我试过将 compileSDKVersion 设置为 19 而不是 26(但这会导致编译器生气,说 Google Play 需要它26 岁或以上)。我假设我的手机是 android 兼容的(见 https://developer.android.com/guide/practices/compatibility ),我按照说明将手机连接到我的电脑( https://developer.android.com/training/basics/firstapp/running-app )。根据 Developers 网站,看起来我应该做的就是将 minSDKVersion 设置为正确的级别,并针对代码中的任何 API 弃用和更新进行调整(我认为我已经完成了)。但它仍然不起作用。
我确实发现我的代码在我的主要 Activity (称为 AMazeActivity)的 onCreate() 方法中产生了膨胀异常。似乎有多种原因会导致此错误,但我无法找出根本原因。这个人有类似的情况: android.view.InflateException: Binary XML file: Error inflating class fragment
这是我在手机上运行该应用程序后收到的完整错误消息。错误消息说我的膨胀异常是由于试图膨胀 Spinner 造成的:
12/27 22:08:17: Launching app
No apk changes detected since last installation, skipping installation of C:\Users\jandj\AndroidStudioProjects\AMaze\app\build\outputs\apk\debug\app-debug.apk
$ adb shell am force-stop cs.cs301.amaze
$ adb shell am start -n "cs.cs301.amaze/cs.cs301.amaze.gui.AMazeActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 28224 on device samsung-sgh_m919-47dccee4
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/dalvikvm: Could not find method android.view.Window$Callback.onPointerCaptureChanged, referenced from method android.support.v7.view.WindowCallbackWrapper.onPointerCaptureChanged
W/dalvikvm: VFY: unable to resolve interface method 16265: Landroid/view/Window$Callback;.onPointerCaptureChanged (Z)V
D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
I/dalvikvm: Could not find method android.view.Window$Callback.onProvideKeyboardShortcuts, referenced from method android.support.v7.view.WindowCallbackWrapper.onProvideKeyboardShortcuts
W/dalvikvm: VFY: unable to resolve interface method 16267: Landroid/view/Window$Callback;.onProvideKeyboardShortcuts (Ljava/util/List;Landroid/view/Menu;I)V
D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
W/dalvikvm: VFY: unable to resolve interface method 16269: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
W/dalvikvm: VFY: unable to resolve interface method 16273: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
W/dalvikvm: VFY: unable to resolve virtual method 708: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
W/dalvikvm: VFY: unable to resolve virtual method 730: Landroid/content/res/TypedArray;.getType (I)I
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0008
I/dalvikvm: Could not find method android.content.Context.createDeviceProtectedStorageContext, referenced from method android.support.v4.content.ContextCompat.createDeviceProtectedStorageContext
W/dalvikvm: VFY: unable to resolve virtual method 485: Landroid/content/Context;.createDeviceProtectedStorageContext ()Landroid/content/Context;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
I/dalvikvm: Could not find method android.content.Context.getCodeCacheDir, referenced from method android.support.v4.content.ContextCompat.getCodeCacheDir
W/dalvikvm: VFY: unable to resolve virtual method 491: Landroid/content/Context;.getCodeCacheDir ()Ljava/io/File;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
I/dalvikvm: Could not find method android.content.Context.getColor, referenced from method android.support.v4.content.ContextCompat.getColor
W/dalvikvm: VFY: unable to resolve virtual method 492: Landroid/content/Context;.getColor (I)I
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
I/dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method android.support.v4.content.ContextCompat.getColorStateList
W/dalvikvm: VFY: unable to resolve virtual method 493: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
I/dalvikvm: Could not find method android.content.Context.getDataDir, referenced from method android.support.v4.content.ContextCompat.getDataDir
W/dalvikvm: VFY: unable to resolve virtual method 495: Landroid/content/Context;.getDataDir ()Ljava/io/File;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
I/dalvikvm: Could not find method android.content.Context.getDrawable, referenced from method android.support.v4.content.ContextCompat.getDrawable
W/dalvikvm: VFY: unable to resolve virtual method 496: Landroid/content/Context;.getDrawable (I)Landroid/graphics/drawable/Drawable;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
I/dalvikvm: Could not find method android.content.Context.getNoBackupFilesDir, referenced from method android.support.v4.content.ContextCompat.getNoBackupFilesDir
W/dalvikvm: VFY: unable to resolve virtual method 503: Landroid/content/Context;.getNoBackupFilesDir ()Ljava/io/File;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
I/dalvikvm: Could not find method android.content.Context.isDeviceProtectedStorage, referenced from method android.support.v4.content.ContextCompat.isDeviceProtectedStorage
W/dalvikvm: VFY: unable to resolve virtual method 516: Landroid/content/Context;.isDeviceProtectedStorage ()Z
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
I/dalvikvm: Could not find method android.content.Context.startForegroundService, referenced from method android.support.v4.content.ContextCompat.startForegroundService
W/dalvikvm: VFY: unable to resolve virtual method 531: Landroid/content/Context;.startForegroundService (Landroid/content/Intent;)Landroid/content/ComponentName;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
I/dalvikvm: Could not find method android.widget.FrameLayout.startActionModeForChild, referenced from method android.support.v7.widget.ActionBarContainer.startActionModeForChild
W/dalvikvm: VFY: unable to resolve virtual method 16736: Landroid/widget/FrameLayout;.startActionModeForChild (Landroid/view/View;Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0002
I/dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method android.support.v7.content.res.AppCompatResources.getColorStateList
W/dalvikvm: VFY: unable to resolve virtual method 493: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/graphics/drawable/Icon;)
I/dalvikvm: Could not find method android.widget.ImageButton.setImageIcon, referenced from method android.support.v7.widget.AppCompatImageButton.setImageIcon
W/dalvikvm: VFY: unable to resolve virtual method 16759: Landroid/widget/ImageButton;.setImageIcon (Landroid/graphics/drawable/Icon;)V
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0000
I/dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawable
W/dalvikvm: VFY: unable to resolve virtual method 671: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
I/dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawableForDensity
W/dalvikvm: VFY: unable to resolve virtual method 673: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
W/dalvikvm: VFY: unable to resolve instanceof 194 (Landroid/graphics/drawable/RippleDrawable;) in Landroid/support/v7/widget/AppCompatImageHelper;
D/dalvikvm: VFY: replacing opcode 0x20 at 0x000c
I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeMaxTextSize, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeMaxTextSize
W/dalvikvm: VFY: unable to resolve virtual method 17062: Landroid/widget/TextView;.getAutoSizeMaxTextSize ()I
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006
I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeMinTextSize, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeMinTextSize
W/dalvikvm: VFY: unable to resolve virtual method 17063: Landroid/widget/TextView;.getAutoSizeMinTextSize ()I
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006
I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeStepGranularity, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeStepGranularity
W/dalvikvm: VFY: unable to resolve virtual method 17064: Landroid/widget/TextView;.getAutoSizeStepGranularity ()I
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006
I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeTextAvailableSizes, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeTextAvailableSizes
W/dalvikvm: VFY: unable to resolve virtual method 17065: Landroid/widget/TextView;.getAutoSizeTextAvailableSizes ()[I
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006
I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeTextType, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeTextType
W/dalvikvm: VFY: unable to resolve virtual method 17066: Landroid/widget/TextView;.getAutoSizeTextType ()I
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0007
I/dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeUniformWithConfiguration, referenced from method android.support.v7.widget.AppCompatTextView.setAutoSizeTextTypeUniformWithConfiguration
W/dalvikvm: VFY: unable to resolve virtual method 17109: Landroid/widget/TextView;.setAutoSizeTextTypeUniformWithConfiguration (IIII)V
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006
I/dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeUniformWithPresetSizes, referenced from method android.support.v7.widget.AppCompatTextView.setAutoSizeTextTypeUniformWithPresetSizes
W/dalvikvm: VFY: unable to resolve virtual method 17110: Landroid/widget/TextView;.setAutoSizeTextTypeUniformWithPresetSizes ([II)V
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006
I/dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeWithDefaults, referenced from method android.support.v7.widget.AppCompatTextView.setAutoSizeTextTypeWithDefaults
W/dalvikvm: VFY: unable to resolve virtual method 17111: Landroid/widget/TextView;.setAutoSizeTextTypeWithDefaults (I)V
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006
I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeStepGranularity, referenced from method android.support.v7.widget.AppCompatTextHelper.loadFromAttributes
W/dalvikvm: VFY: unable to resolve virtual method 17064: Landroid/widget/TextView;.getAutoSizeStepGranularity ()I
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0163
I/dalvikvm: Could not find method android.text.StaticLayout$Builder.obtain, referenced from method android.support.v7.widget.AppCompatTextViewAutoSizeHelper.createStaticLayoutForMeasuring
W/dalvikvm: VFY: unable to resolve static method 15540: Landroid/text/StaticLayout$Builder;.obtain (Ljava/lang/CharSequence;IILandroid/text/TextPaint;I)Landroid/text/StaticLayout$Builder;
D/dalvikvm: VFY: replacing opcode 0x71 at 0x0014
D/ProgressBar: setProgressDrawable drawableHeight = 36
D/AbsSeekBar: AbsSeekBar Constructor: mAllowedSeeBarAnimation = true
D/ProgressBar: setProgressDrawable drawableHeight = 36
setProgressDrawable getHeight() = 0
updateDrawableBounds: left = 0
updateDrawableBounds: top = 0
updateDrawableBounds: right = -96
updateDrawableBounds: bottom = 0
updateDrawableBounds: mProgressDrawable.setBounds()
I/dalvikvm: Could not find method android.widget.Spinner.getPopupContext, referenced from method android.support.v7.widget.AppCompatSpinner.getPopupContext
W/dalvikvm: VFY: unable to resolve virtual method 17017: Landroid/widget/Spinner;.getPopupContext ()Landroid/content/Context;
D/dalvikvm: VFY: replacing opcode 0x6f at 0x000d
W/ResourceType: Skipping entry 0x7f050026 in package table 0 because it is not complex!
E/AMazeActivity: onCreate
android.view.InflateException: Binary XML file line #46: Error inflating class Spinner
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at cs.cs301.amaze.gui.AMazeActivity.onCreate(AMazeActivity.java:39)
at android.app.Activity.performCreate(Activity.java:5585)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2400)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495)
at android.app.ActivityThread.access$900(ActivityThread.java:170)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1304)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5635)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.content.res.AssetManager.getResourceTextArray(AssetManager.java:215)
at android.content.res.Resources.getTextArray(Resources.java:1626)
at android.content.res.TypedArray.getTextArray(TypedArray.java:629)
at android.widget.AbsSpinner.<init>(AbsSpinner.java:74)
at android.widget.Spinner.<init>(Spinner.java:174)
at android.widget.Spinner.<init>(Spinner.java:153)
at android.support.v7.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:195)
at android.support.v7.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:166)
at android.support.v7.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:147)
at android.support.v7.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:132)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:115)
at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1024)
at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1081)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:690)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at cs.cs301.amaze.gui.AMazeActivity.onCreate(AMazeActivity.java:39)
at android.app.Activity.performCreate(Activity.java:5585)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2400)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495)
at android.app.ActivityThread.access$900(ActivityThread.java:170)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1304)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5635)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
D/AndroidRuntime: Shutting down VM
W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x417eeda0)
E/AndroidRuntime: FATAL EXCEPTION: main
Process: cs.cs301.amaze, PID: 28224
java.lang.RuntimeException: Unable to start activity ComponentInfo{cs.cs301.amaze/cs.cs301.amaze.gui.AMazeActivity}: android.view.InflateException: Binary XML file line #46: Error inflating class Spinner
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2436)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495)
at android.app.ActivityThread.access$900(ActivityThread.java:170)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1304)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5635)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #46: Error inflating class Spinner
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at cs.cs301.amaze.gui.AMazeActivity.onCreate(AMazeActivity.java:39)
at android.app.Activity.performCreate(Activity.java:5585)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2400)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495)
at android.app.ActivityThread.access$900(ActivityThread.java:170)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1304)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5635)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.content.res.AssetManager.getResourceTextArray(AssetManager.java:215)
at android.content.res.Resources.getTextArray(Resources.java:1626)
at android.content.res.TypedArray.getTextArray(TypedArray.java:629)
at android.widget.AbsSpinner.<init>(AbsSpinner.java:74)
at android.widget.Spinner.<init>(Spinner.java:174)
at android.widget.Spinner.<init>(Spinner.java:153)
at android.support.v7.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:195)
at android.support.v7.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:166)
at android.support.v7.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:147)
at android.support.v7.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:132)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:115)
at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1024)
at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1081)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:690)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at cs.cs301.amaze.gui.AMazeActivity.onCreate(AMazeActivity.java:39)
at android.app.Activity.performCreate(Activity.java:5585)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2400)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495)
at android.app.ActivityThread.access$900(ActivityThread.java:170)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1304)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5635)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
I/Process: Sending signal. PID: 28224 SIG: 9
Application terminated.
这是我的主要 Activity 中发生崩溃的地方。我尝试将代码包围在 try/catch block 中以捕获异常并将其更清晰地打印出来,如上图所示:
@Override
protected void onCreate(Bundle savedInstanceState) {
try {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_amaze);
}
catch (Exception e) {
e.getCause();
Log.e("AMazeActivity", "onCreate", e);
throw e;
}
. . .
. . .
注意事项:我为我的 Activity 使用约束布局,我只在程序中使用一个自定义 View ,并且我没有使用自定义主题。这是异常提示 Spinner 的 XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="cs.cs301.amaze.gui.AMazeActivity">
. . .
<TextView
android:id="@+id/diff_JFrame"
android:layout_width="248dp"
android:layout_height="60dp"
android:layout_marginStart="16dp"
android:layout_marginTop="256dp"
android:text="Difficulty/Size"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
. . .
<Spinner
android:id="@+id/mazeGen"
android:layout_width="248dp"
android:layout_height="35dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="120dp"
android:layout_marginBottom="130dp"
android:entries="@color/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
/>
. . .
我认为这可能只是更改设置中的几行(可能在 gradle、 list 文件、R 类、XML 文件等)中的问题,但我不知道要更改什么或在哪里更改。任何帮助将不胜感激!
最佳答案
改变这一行
android:entries="@color/colorAccent"
到
android:entries="@array/yourarrayname"
关于java - 我似乎无法在旧的 android 手机上运行我的 android studio 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53966291/
几周前,我安装了一个新的 ssl 证书来替换一个过期的证书。 .crt 和 .key 的文件名保持不变。只是内容变了。 现在,当我访问我的网站时,它说证书已过期,我看到它正在使用旧的证书链。我可以确认
这个问题在这里已经有了答案: Make namespaces backwards compatible in PHP (4 个回答) 8 年前关闭。 我真的很想在我的工作流程中采用命名空间。据我了解,
我从 CN1 开始,然后以 Todo App 为例。当我在 Netbeans 中运行 de app 时,只出现一个空白表单,我更改了主题,添加了一个 jpg 图像并使用旧的 GUI Builder 在
我想知道是否有一些 Laravel 人员可以帮忙。 我有一个表单,其中有 2 个单选按钮,当表单提交时,它会通过验证器,如果验证器失败,它会返回表单,使用输入填充字段并显示错误消息。 我似乎无法对单选
我正在使用 Java 中没有泛型的旧代码。 hashMap 是在该代码中定义的,没有泛型,例如: Map A = new HashMap(); 在这段代码中,我想如何确定要在键和值中放入什么内容,以及
我想问一个关于项目兼容性的问题。我的论文项目是在Windows Vista和XP上在JRE 1.6和JDK 1.6下开发的。该项目使用Java新套接字。今天我尝试在 Windows 8(64 位)机器
有谁知道一个脚本可以将旧的 Products 命名空间样式 Plone 附加组件包装到 Egg 中吗? 生成setup.py 创建目录结构 还需要采取其他措施吗? 鸡蛋化过程中有什么陷阱吗? 最佳答案
我已经运行 MySQL 5.6.12 一段时间了。我决定将我的 WAMP 服务器更新到最新的 PHP 版本。 在此过程中,它还将 MySQL 更新到 5.6.17,保留 .12 数据,但无法访问。 如
最近,我一直在尝试根据互联网上的各种旧教程编写论坛代码,但是我最近遇到了一个问题 - 尽管我完全按照教程所述进行操作,但我收到了空格错误。我认为这可能是因为某些 MySQL 命令可能已更改。如果有人可
我正在创建对 Count 表的查询。 $Month = $_POST['Month']; $query = "SELECT ANY_VALUE(AD) AS ad, COU
如果我使用 mysqldump 工具备份旧版本的 MySql 数据库,是否存在任何已知风险?例如,如果我在生产机器上使用 mysqldump 5.6 来备份 MySql 5.X 数据库。 最佳答案 有
当将 columnsData 值分配给 columns 时,我有两个 JSON 对象 columnsData 和 columns,这两个值都会更改。 var columnsData = [
我有一个需要在 gcc 4.4 上编译的多线程应用程序,我不允许使用 c++0x 标志。 我希望一个变量以原子方式运行,但不幸的是没有 C++0x 标志我无法使用 atomic在 C++ 中。 我试过
我可以借助广播事件(ACTION_TIME_CHANGED 和 ACTION_DATE_CHANGED)获取时间更改事件。 我需要在时间更改后获取之前的时间。例如,当前时间是 10:00。我要把时间改
我正在尝试在我的 Android 应用程序中创建一个 DatePickerDialog,但是当我创建一个 DatePickerDialog 时,我收到以下消息:Call requires API le
{!! Form::open(array('route' => 'posts.store', 'data-parsley-validate' => '')) !!} {{ Form::labe
我的问题与 iOS 周围的蓝牙技术有关。我看过关于蓝牙低功耗 101、新功能、基础知识等的 WWDC,以及关于使用 iOS 5 及更高版本中可用的 CoreBluetooth 框架的内容。我浏览了不同
我有一个有五个屏幕的应用。 在每个屏幕上,我在 viewDidLoad 中从服务器访问数据。 在每个屏幕上我都有下一个按钮。 当我从屏幕一转到屏幕五(通过单击下一步 4 次)时,在 NSLog 中,我
我最近在一家网络报纸找到了一份工作。在网站上,我们有一个非常古老且重要的 Symfony 应用程序,它是为一位年长的开发人员编写的,已经消失很久了。该应用程序是神圣的:是报纸收入的血液。问题是我们没有
我相信我已经找到了一种方法来实现类似可移植 C89 中众所周知的“struct hack”的方法。我很好奇这是否真的严格符合 C89。 主要思想是:我分配足够大的内存来容纳初始结构和数组元素。确切的大
我是一名优秀的程序员,十分优秀!