我正在为Android 2.3.3开发并试图使用支持GridLayout。 在我正在使用的类中的onCreate上运行SetContentView之后,我的应用程序崩溃了。
我在视图中有以下GridLayout:
<android.support.v7.widget.GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/chaptergrid"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:columnCount="4">
</android.support.v7.widget.GridLayout>
我在Log Cat中得到以下内容:
01-04 08:43:05.648: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed 55K, 53% free 2566K/5379K, external 716K/1038K, paused 56ms
01-04 08:43:05.708: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed 1K, 53% free 2565K/5379K, external 1382K/1894K, paused 26ms
01-04 08:43:05.768: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed <1K, 53% free 2565K/5379K, external 1902K/2568K, paused 27ms
01-04 08:43:05.848: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed <1K, 53% free 2565K/5379K, external 2944K/3677K, paused 36ms
01-04 08:43:05.937: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed <1K, 53% free 2566K/5379K, external 4160K/4795K, paused 25ms
01-04 08:43:05.987: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed <1K, 53% free 2566K/5379K, external 4883K/5590K, paused 25ms
01-04 08:43:06.107: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed 1K, 53% free 2567K/5379K, external 6330K/6493K, paused 33ms
01-04 08:43:06.207: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed 1K, 53% free 2568K/5379K, external 7776K/8299K, paused 32ms
01-04 08:43:36.217: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed 14K, 52% free 2595K/5379K, external 2163K/2886K, paused 24ms
01-04 08:43:36.277: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed 1K, 52% free 2594K/5379K, external 2481K/3205K, paused 24ms
01-04 08:43:36.347: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed <1K, 52% free 2595K/5379K, external 3697K/4332K, paused 23ms
01-04 08:43:36.777: D/dalvikvm(346): GC_CONCURRENT freed 189K, 48% free 3036K/5831K, external 4181K/5012K, paused 4ms+4ms
01-04 08:43:36.998: D/szipinf(346): Initializing inflate state
01-04 08:43:38.547: I/dalvikvm(346): Jit: resizing JitTable from 512 to 1024
01-04 08:43:38.598: W/dalvikvm(346): VFY: unable to resolve static field 1174 (default_gap) in Landroid/support/v7/gridlayout/R$dimen;
01-04 08:43:38.598: D/dalvikvm(346): VFY: replacing opcode 0x60 at 0x0024
01-04 08:43:38.598: D/dalvikvm(346): VFY: dead code 0x0026-007b in Landroid/support/v7/widget/GridLayout;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;I)V
01-04 08:43:38.618: I/dalvikvm(346): Could not find method android.support.v4.view.ViewCompat.resolveSizeAndState, referenced from method android.support.v7.widget.GridLayout.onMeasure
01-04 08:43:38.618: W/dalvikvm(346): VFY: unable to resolve static method 2483: Landroid/support/v4/view/ViewCompat;.resolveSizeAndState (III)I
01-04 08:43:38.618: D/dalvikvm(346): VFY: replacing opcode 0x71 at 0x0050
01-04 08:43:38.618: D/dalvikvm(346): VFY: dead code 0x0053-005b in Landroid/support/v7/widget/GridLayout;.onMeasure (II)V
01-04 08:43:38.618: D/AndroidRuntime(346): Shutting down VM
01-04 08:43:38.618: W/dalvikvm(346): threadid=1: thread exiting with uncaught exception (group=0x40015560)
01-04 08:43:38.627: E/AndroidRuntime(346): FATAL EXCEPTION: main
01-04 08:43:38.627: E/AndroidRuntime(346): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.turbo/com.example.turbo.Chapter}: android.view.InflateException: Binary XML file line #28: Error inflating class android.support.v7.widget.GridLayout
01-04 08:43:38.627: E/AndroidRuntime(346): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.os.Handler.dispatchMessage(Handler.java:99)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.os.Looper.loop(Looper.java:123)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.app.ActivityThread.main(ActivityThread.java:3683)
01-04 08:43:38.627: E/AndroidRuntime(346): at java.lang.reflect.Method.invokeNative(Native Method)
01-04 08:43:38.627: E/AndroidRuntime(346): at java.lang.reflect.Method.invoke(Method.java:507)
01-04 08:43:38.627: E/AndroidRuntime(346): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-04 08:43:38.627: E/AndroidRuntime(346): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-04 08:43:38.627: E/AndroidRuntime(346): at dalvik.system.NativeStart.main(Native Method)
01-04 08:43:38.627: E/AndroidRuntime(346): Caused by: android.view.InflateException: Binary XML file line #28: Error inflating class android.support.v7.widget.GridLayout
01-04 08:43:38.627: E/AndroidRuntime(346): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-04 08:43:38.627: E/AndroidRuntime(346): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.app.Activity.setContentView(Activity.java:1657)
01-04 08:43:38.627: E/AndroidRuntime(346): at com.example.turbo.Chapter.onCreate(Chapter.java:21)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
01-04 08:43:38.627: E/AndroidRuntime(346): ... 11 more
01-04 08:43:38.627: E/AndroidRuntime(346): Caused by: java.lang.reflect.InvocationTargetException
01-04 08:43:38.627: E/AndroidRuntime(346): at java.lang.reflect.Constructor.constructNative(Native Method)
01-04 08:43:38.627: E/AndroidRuntime(346): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
01-04 08:43:38.627: E/AndroidRuntime(346): ... 21 more
01-04 08:43:38.627: E/AndroidRuntime(346): Caused by: java.lang.NoClassDefFoundError: android.support.v7.gridlayout.R$dimen
01-04 08:43:38.627: E/AndroidRuntime(346): at android.support.v7.widget.GridLayout.<init>(GridLayout.java:270)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.support.v7.widget.GridLayout.<init>(GridLayout.java:289)
01-04 08:43:38.627: E/AndroidRuntime(346): ... 24 more