- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试制作一个简单的内存游戏,目前我只完成了 XML 代码。但由于某些原因我无法理解,在 logcat 中我收到错误由以下原因引起:java.lang.reflect.InitationTargetException
在这个java行:setContentView(R.layout.activity_main);
。
这行是应用程序在我自动创建它时编写的。
这是我的 XML 代码:
<?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"
android:padding="20dp"
android:orientation="vertical"
tools:context=".MainActivity"
android:background="@drawable/background">
<TextView
android:layout_width="wrap_content"
android:layout_gravity="center"
android:textSize="40sp"
android:fontFamily="@font/hearthstonefont"
android:layout_height="wrap_content"
android:text="@string/title" />
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="@string/hint"
android:fontFamily="@font/hearthstonefont" />
<TextView
android:id="@+id/tvGame"
android:textSize="20sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/pCounter"
android:fontFamily="@font/hearthstonefont" />
<TextView
android:id="@+id/tvPoints"
android:textSize="20sp"
android:layout_marginBottom="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/gCounter"
android:fontFamily="@font/hearthstonefont" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:id="@+id/imageButton"
android:layout_width="150dp"
android:layout_height="180dp"
android:layout_weight="1"
android:contentDescription="@string/title"
android:scaleType="fitEnd"
android:background="@android:color/transparent"
android:src="@drawable/cardback"/>
<ImageButton
android:id="@+id/ibum"
android:layout_width="150dp"
android:layout_height="180dp"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="fitEnd"
android:contentDescription="@string/title"
android:src="@drawable/cardback" />
<ImageButton
android:id="@+id/ibur"
android:layout_width="150dp"
android:layout_height="180dp"
android:layout_weight="1"
android:contentDescription="@string/title"
android:background="@android:color/transparent"
android:scaleType="fitEnd"
android:src="@drawable/cardback" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<ImageButton
android:id="@+id/ibdl"
android:layout_width="150dp"
android:layout_height="180dp"
android:layout_weight="1"
android:contentDescription="@string/title"
android:background="@android:color/transparent"
android:scaleType="fitEnd"
android:src="@drawable/cardback" />
<ImageButton
android:id="@+id/ibdm"
android:layout_width="150dp"
android:contentDescription="@string/title"
android:layout_height="180dp"
android:layout_weight="1"
android:scaleType="fitEnd"
android:background="@android:color/transparent"
android:src="@drawable/cardback" />
<ImageButton
android:id="@+id/ibdr"
android:contentDescription="@string/title"
android:layout_width="150dp"
android:layout_height="180dp"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="fitEnd"
android:src="@drawable/cardback" />
</LinearLayout>
<Space
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="bottom" >
<Button
android:id="@+id/btnNewGame"
android:layout_width="150dp"
android:layout_height="100dp"
android:layout_weight="1"
style="@style/Widget.AppCompat.Button.Borderless"
android:background="@drawable/btngood"
android:fontFamily="@font/hearthstonefont"
android:text="@string/btnNewGame"
android:textSize="17sp"/>
<Button
android:id="@+id/btNewPlayer"
android:background="@drawable/btngood"
android:layout_width="150dp"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_height="100dp"
android:layout_weight="1"
android:fontFamily="@font/hearthstonefont"
android:text="@string/btnNewPlayer"
android:textSize="17sp"/>
</LinearLayout>
</LinearLayout>
这是我的java代码:
package com.example.maor_memorygame;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
日志猫:
2020-01-19 15:20:05.672 1139-1139/? I/art: Not late-enabling -Xcheck:jni (already on)
2020-01-19 15:20:05.673 1139-1139/? W/art: Unexpected CPU variant for X86 using defaults: x86
2020-01-19 15:20:05.791 1139-1139/com.example.maor_memorygame W/System: ClassLoader referenced unknown path: /data/app/com.example.maor_memorygame-2/lib/x86
2020-01-19 15:20:05.849 1139-1139/com.example.maor_memorygame W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
2020-01-19 15:20:05.876 1139-1139/com.example.maor_memorygame I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at void androidx.appcompat.widget.ActionBarContainer.<init>(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at java.lang.Object java.lang.reflect.Constructor.newInstance0!(java.lang.Object[]) (Constructor.java:-2)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:430)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:645)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:787)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:727)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at void android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:858)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:821)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:518)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:426)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:377)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at void com.example.maor_memorygame.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:12)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6679)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1118)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2618)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2726)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1477)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at void android.os.Looper.loop() (Looper.java:154)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6119)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:886)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:776)
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.example.maor_memorygame-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.maor_memorygame-2/lib/x86, /system/lib, /vendor/lib]]
2020-01-19 15:20:05.877 1139-1139/com.example.maor_memorygame I/art: at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at void androidx.appcompat.widget.ActionBarContainer.<init>(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at java.lang.Object java.lang.reflect.Constructor.newInstance0!(java.lang.Object[]) (Constructor.java:-2)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:430)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:645)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:787)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:727)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at void android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:858)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:821)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:518)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:426)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:377)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at void com.example.maor_memorygame.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:12)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6679)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1118)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2618)
2020-01-19 15:20:05.878 1139-1139/com.example.maor_memorygame I/art: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2726)
2020-01-19 15:20:05.879 1139-1139/com.example.maor_memorygame I/art: at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2020-01-19 15:20:05.879 1139-1139/com.example.maor_memorygame I/art: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1477)
2020-01-19 15:20:05.879 1139-1139/com.example.maor_memorygame I/art: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
2020-01-19 15:20:05.880 1139-1139/com.example.maor_memorygame I/art: at void android.os.Looper.loop() (Looper.java:154)
2020-01-19 15:20:05.880 1139-1139/com.example.maor_memorygame I/art: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6119)
2020-01-19 15:20:05.880 1139-1139/com.example.maor_memorygame I/art: at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2020-01-19 15:20:05.880 1139-1139/com.example.maor_memorygame I/art: at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:886)
2020-01-19 15:20:05.880 1139-1139/com.example.maor_memorygame I/art: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:776)
2020-01-19 15:20:06.348 1139-1139/com.example.maor_memorygame I/art: Starting a blocking GC Alloc
2020-01-19 15:20:06.348 1139-1139/com.example.maor_memorygame I/art: Starting a blocking GC Alloc
2020-01-19 15:20:06.368 1139-1139/com.example.maor_memorygame I/art: Alloc partial concurrent mark sweep GC freed 9304(551KB) AllocSpace objects, 0(0B) LOS objects, 37% free, 6MB/10MB, paused 1.534ms total 18.933ms
2020-01-19 15:20:06.368 1139-1139/com.example.maor_memorygame I/art: Starting a blocking GC Alloc
2020-01-19 15:20:06.379 1139-1139/com.example.maor_memorygame I/art: Alloc sticky concurrent mark sweep GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 37% free, 6MB/10MB, paused 1.315ms total 10.152ms
2020-01-19 15:20:06.379 1139-1139/com.example.maor_memorygame I/art: Starting a blocking GC Alloc
2020-01-19 15:20:06.398 1139-1139/com.example.maor_memorygame I/art: Alloc concurrent mark sweep GC freed 126(5KB) AllocSpace objects, 0(0B) LOS objects, 37% free, 6MB/10MB, paused 1.371ms total 18.414ms
2020-01-19 15:20:06.398 1139-1139/com.example.maor_memorygame I/art: Forcing collection of SoftReferences for 387MB allocation
2020-01-19 15:20:06.398 1139-1139/com.example.maor_memorygame I/art: Starting a blocking GC Alloc
2020-01-19 15:20:06.415 1139-1139/com.example.maor_memorygame I/art: Alloc concurrent mark sweep GC freed 3(72B) AllocSpace objects, 0(0B) LOS objects, 37% free, 6MB/10MB, paused 1.547ms total 16.002ms
2020-01-19 15:20:06.415 1139-1139/com.example.maor_memorygame W/art: Throwing OutOfMemoryError "Failed to allocate a 406425612 byte allocation with 4194304 free bytes and 377MB until OOM"
2020-01-19 15:20:06.415 1139-1139/com.example.maor_memorygame I/art: Starting a blocking GC Alloc
2020-01-19 15:20:06.415 1139-1139/com.example.maor_memorygame I/art: Starting a blocking GC Alloc
2020-01-19 15:20:06.425 1139-1139/com.example.maor_memorygame I/art: Alloc sticky concurrent mark sweep GC freed 4(752B) AllocSpace objects, 0(0B) LOS objects, 37% free, 6MB/10MB, paused 975us total 9.026ms
2020-01-19 15:20:06.425 1139-1139/com.example.maor_memorygame I/art: Starting a blocking GC Alloc
2020-01-19 15:20:06.440 1139-1139/com.example.maor_memorygame I/art: Alloc partial concurrent mark sweep GC freed 6(144B) AllocSpace objects, 0(0B) LOS objects, 37% free, 6MB/10MB, paused 1.719ms total 14.523ms
2020-01-19 15:20:06.440 1139-1139/com.example.maor_memorygame I/art: Starting a blocking GC Alloc
2020-01-19 15:20:06.458 1139-1139/com.example.maor_memorygame I/art: Alloc concurrent mark sweep GC freed 3(72B) AllocSpace objects, 0(0B) LOS objects, 37% free, 6MB/10MB, paused 1.054ms total 17.991ms
2020-01-19 15:20:06.458 1139-1139/com.example.maor_memorygame I/art: Forcing collection of SoftReferences for 387MB allocation
2020-01-19 15:20:06.458 1139-1139/com.example.maor_memorygame I/art: Starting a blocking GC Alloc
2020-01-19 15:20:06.476 1139-1139/com.example.maor_memorygame I/art: Alloc concurrent mark sweep GC freed 3(72B) AllocSpace objects, 0(0B) LOS objects, 37% free, 6MB/10MB, paused 2.155ms total 17.667ms
2020-01-19 15:20:06.476 1139-1139/com.example.maor_memorygame W/art: Throwing OutOfMemoryError "Failed to allocate a 406425612 byte allocation with 4194304 free bytes and 377MB until OOM"
2020-01-19 15:20:06.477 1139-1139/com.example.maor_memorygame D/skia: --- allocation failed for scaled bitmap
2020-01-19 15:20:06.480 1139-1139/com.example.maor_memorygame D/AndroidRuntime: Shutting down VM
2020-01-19 15:20:06.482 1139-1139/com.example.maor_memorygame E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.maor_memorygame, PID: 1139
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.maor_memorygame/com.example.maor_memorygame.MainActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:717)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.maor_memorygame.MainActivity.onCreate(MainActivity.java:12)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.OutOfMemoryError: Failed to allocate a 406425612 byte allocation with 4194304 free bytes and 377MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:620)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:455)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1155)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:720)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:571)
at android.content.res.Resources.loadDrawable(Resources.java:858)
at android.content.res.TypedArray.getDrawable(TypedArray.java:928)
at android.view.View.<init>(View.java:4202)
at android.view.ViewGroup.<init>(ViewGroup.java:579)
at android.widget.LinearLayout.<init>(LinearLayout.java:211)
2020-01-19 15:20:06.482 1139-1139/com.example.maor_memorygame E/AndroidRuntime: at android.widget.LinearLayout.<init>(LinearLayout.java:207)
at android.widget.LinearLayout.<init>(LinearLayout.java:203)
... 25 more
应用程序gradle.build:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.maor_memorygame"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
最佳答案
您的实际异常是 ClassNotFoundException。
java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener"
检查this出来,也许有帮助。
关于java - : java. lang.reflect.InitationTargetException 引起的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59810277/
我已经使用 vue-cli 两个星期了,直到今天一切正常。我在本地建立这个项目。 https://drive.google.com/open?id=0BwGw1zyyKjW7S3RYWXRaX24tQ
您好,我正在尝试使用 python 库 pytesseract 从图像中提取文本。请找到代码: from PIL import Image from pytesseract import image_
我的错误 /usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference
我已经训练了一个模型,我正在尝试使用 predict函数但它返回以下错误。 Error in contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]])
根据Microsoft DataConnectors的信息我想通过 this ODBC driver 创建一个从 PowerBi 到 PostgreSQL 的连接器使用直接查询。我重用了 Micros
我已经为 SoundManagement 创建了一个包,其中有一个扩展 MediaPlayer 的类。我希望全局控制这个变量。这是我的代码: package soundmanagement; impo
我在Heroku上部署了一个应用程序。我正在使用免费服务。 我经常收到以下错误消息。 PG::Error: ERROR: out of memory 如果刷新浏览器,就可以了。但是随后,它又随机发生
我正在运行 LAMP 服务器,这个 .htaccess 给我一个 500 错误。其作用是过滤关键字并重定向到相应的域名。 Options +FollowSymLinks RewriteEngine
我有两个驱动器 A 和 B。使用 python 脚本,我在“A”驱动器中创建一些文件,并运行 powerscript,该脚本以 1 秒的间隔将驱动器 A 中的所有文件复制到驱动器 B。 我在 powe
下面的函数一直返回这个错误信息。我认为可能是 double_precision 字段类型导致了这种情况,我尝试使用 CAST,但要么不是这样,要么我没有做对...帮助? 这是错误: ERROR: i
这个问题已经有答案了: Syntax error due to using a reserved word as a table or column name in MySQL (1 个回答) 已关闭
我的数据库有这个小问题。 我创建了一个表“articoli”,其中包含商品的品牌、型号和价格。 每篇文章都由一个 id (ID_ARTICOLO)` 定义,它是一个自动递增字段。 好吧,现在当我尝试插
我是新来的。我目前正在 DeVry 在线学习中级 C++ 编程。我们正在使用 C++ Primer Plus 这本书,到目前为止我一直做得很好。我的老师最近向我们扔了一个曲线球。我目前的任务是这样的:
这个问题在这里已经有了答案: What is an undefined reference/unresolved external symbol error and how do I fix it?
我的网站中有一段代码有问题;此错误仅发生在 Internet Explorer 7 中。 我没有在这里发布我所有的 HTML/CSS 标记,而是发布了网站的一个版本 here . 如您所见,我在列中有
如果尝试在 USB 设备上构建 node.js 应用程序时在我的树莓派上使用 npm 时遇到一些问题。 package.json 看起来像这样: { "name" : "node-todo",
在 Python 中,您有 None单例,在某些情况下表现得很奇怪: >>> a = None >>> type(a) >>> isinstance(a,None) Traceback (most
这是我的 build.gradle (Module:app) 文件: apply plugin: 'com.android.application' android { compileSdkV
我是 android 的新手,我的项目刚才编译和运行正常,但在我尝试实现抽屉导航后,它给了我这个错误 FAILURE: Build failed with an exception. What wen
谁能解释一下?我想我正在做一些非常愚蠢的事情,并且急切地等待着启蒙。 我得到这个输出: phpversion() == 7.2.25-1+0~20191128.32+debian8~1.gbp108
我是一名优秀的程序员,十分优秀!