android.view.InflateException错误?

时间:2013-07-28 15:57:20

标签: android eclipse sdk

我正在努力制作这个游戏,我希望有人可以帮助我解决我遇到的这个错误问题,但我不确定它是什么

07-28 00:22:11.234: D/Androidsoft Sound Manager(11573): Init SoundManager
07-28 00:22:11.656: D/dalvikvm(11573): GC_FOR_ALLOC freed 68K, 3% free 8081K/8259K, paused 180ms, total 181ms
07-28 00:22:11.672: I/dalvikvm-heap(11573): Grow heap (frag case) to 10.283MB for 2457616-byte allocation
07-28 00:22:11.746: D/dalvikvm(11573): GC_CONCURRENT freed 1K, 3% free 10480K/10695K, paused 14ms+9ms, total 73ms
07-28 00:22:11.859: D/AndroidRuntime(11573): Shutting down VM
07-28 00:22:11.859: W/dalvikvm(11573): threadid=1: thread exiting with uncaught exception (group=0x40ec0300)
07-28 00:22:11.871: E/AndroidRuntime(11573): FATAL EXCEPTION: main
07-28 00:22:11.871: E/AndroidRuntime(11573): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vamp6x6x6x.memorykidsfree/com.vamp6x6x6x.memorykidsfree.ui.MainActivity}: android.view.InflateException: Binary XML file line #47: Error inflating class null
07-28 00:22:11.871: E/AndroidRuntime(11573):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at android.app.ActivityThread.access$600(ActivityThread.java:130)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at android.os.Handler.dispatchMessage(Handler.java:99)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at android.os.Looper.loop(Looper.java:137)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at android.app.ActivityThread.main(ActivityThread.java:4745)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at java.lang.reflect.Method.invokeNative(Native Method)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at java.lang.reflect.Method.invoke(Method.java:511)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at dalvik.system.NativeStart.main(Native Method)
07-28 00:22:11.871: E/AndroidRuntime(11573): Caused by: android.view.InflateException: Binary XML file line #47: Error inflating class null
07-28 00:22:11.871: E/AndroidRuntime(11573):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at android.app.Activity.setContentView(Activity.java:1867)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at com.vamp6x6x6x.memorykidsfree.ui.AbstractMainActivity.onCreate(AbstractMainActivity.java:64)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at com.vamp6x6x6x.memorykidsfree.ui.MainActivity.onCreate(MainActivity.java:75)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at android.app.Activity.performCreate(Activity.java:5008)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
07-28 00:22:11.871: E/AndroidRuntime(11573):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
07-28 00:22:11.871: E/AndroidRuntime(11573):    ... 11 more
07-28 00:22:11.871: E/AndroidRuntime(11573): Caused by: java.lang.NullPointerException
07-28 00:22:11.871: E/AndroidRuntime(11573):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:684)
07-28 00:22:11.871: E/AndroidRuntime(11573):    ... 23 more
07-28 00:22:15.472: I/Process(11573): Sending signal. PID: 11573 SIG: 9

不擅长阅读日志,但我认为此文件导致错误

package com.vamp6x6x6x.memorykidsfree.ui;

import com.vamp6x6x6x.memorykidsfree.PreferencesService;
import com.vamp6x6x6x.memorykidsfree.R;
import com.vamp6x6x6x.memorykidsfree.model.Memory;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import java.text.MessageFormat;

/**
 * MainActivity
 */
public class MainActivity extends AbstractMainActivity implements
        Memory.OnMemoryListener {

    private static final int[] tiles_fruits = { R.drawable.a1, R.drawable.a2,
            R.drawable.a3, R.drawable.a4, R.drawable.a5, R.drawable.a6,
            R.drawable.a7, R.drawable.a8, R.drawable.a9, R.drawable.a10,
            R.drawable.a11, R.drawable.a12, R.drawable.a13, R.drawable.a14,
            R.drawable.a15, R.drawable.a16, R.drawable.a17, R.drawable.a18,
            R.drawable.a19, R.drawable.a20, R.drawable.a21, R.drawable.a22 };

    private static final int[] tiles_halloween = { R.drawable.b1,
            R.drawable.b2, R.drawable.b3, R.drawable.b4, R.drawable.b5,
            R.drawable.b6, R.drawable.b7, R.drawable.b8, R.drawable.b9,
            R.drawable.b10, R.drawable.b11, R.drawable.b12 };

    private static final int[] tiles_sports = { R.drawable.c1, R.drawable.c2,
            R.drawable.c3, R.drawable.c4, R.drawable.c5, R.drawable.c6,
            R.drawable.c7, R.drawable.c8, R.drawable.c9, R.drawable.c10,
            R.drawable.c11, R.drawable.c12 };

    private static final int[] tiles_foods = { R.drawable.d1, R.drawable.d2,
            R.drawable.d3, R.drawable.d4, R.drawable.d5, R.drawable.d6,
            R.drawable.d7, R.drawable.d8, R.drawable.d9, R.drawable.d10,
            R.drawable.d11, R.drawable.d12 };

    private static final int[][] icons_set = { tiles_fruits, tiles_halloween,
            tiles_sports, tiles_foods };

    private static final int[] sounds = { R.raw.gupp, R.raw.winch,
            R.raw.chtoing, R.raw.kito, R.raw.kato, R.raw.ding, R.raw.ding2,
            R.raw.ding3, R.raw.ding4, R.raw.ding5, R.raw.ding6, R.raw.dong,
            R.raw.swirlup, R.raw.swipp };

    private static final int[] not_found_tile_set = {
            R.drawable.not_found_fruits, R.drawable.not_found_halloween,
            R.drawable.not_found_sports, R.drawable.not_found_foods };
    private Memory mMemory;
    // private int mNotFoundResId;
    private MemoryGridView mGridView;

    /**
     * {@inheritDoc }
     */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        PreferencesService.init(this);
        newGame();

    }

    /**
     * {@inheritDoc }
     */
    @Override
    protected View getGameView() {
        return mGridView;
    }

    /**
     * {@inheritDoc }
     */
    @Override
    protected void newGame() {
        int set = PreferencesService.instance().getIconsSet();
        mMemory = new Memory(icons_set[set], sounds, not_found_tile_set[set],
                this);
        mMemory.reset();
        mGridView = (MemoryGridView) findViewById(R.id.gridview);
        mGridView.setMemory(mMemory);
        drawGrid();
    }

    /**
     * {@inheritDoc }
     */
    @Override
    protected void preferences() {
        Intent intent = new Intent(this, PreferencesActivity.class);
        startActivity(intent);
    }

    /**
     * {@inheritDoc }
     */
    @Override
    protected void onResume() {
        super.onResume();

        mMemory.onResume(PreferencesService.instance().getPrefs());

        drawGrid();

    }

    /**
     * {@inheritDoc }
     */
    @Override
    protected void onPause() {
        super.onPause();

        mMemory.onPause(PreferencesService.instance().getPrefs(), mQuit);

    }

    /**
     * {@inheritDoc }
     */
    public void onComplete(int countMove) {
        int nHighScore = PreferencesService.instance().getHiScore();
        String title = getString(R.string.success_title);
        Object[] args = { countMove, nHighScore };
        String message = MessageFormat
                .format(getString(R.string.success), args);
        int icon = R.drawable.win;
        if (countMove < nHighScore) {
            title = getString(R.string.hiscore_title);
            message = MessageFormat.format(getString(R.string.hiscore), args);
            icon = R.drawable.hiscore;

            PreferencesService.instance().saveHiScore(countMove);
        }
        this.showEndDialog(title, message, icon);
    }

    /**
     * {@inheritDoc }
     */
    public void onUpdateView() {
        drawGrid();
    }

    /**
     * Draw or redraw the grid
     */
    private void drawGrid() {
        mGridView.update();
    }

}

清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.vamp6x6x6x.memorykidsfree"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:logo="@drawable/logo"
        android:hardwareAccelerated="true">
        <activity android:name="com.vamp6x6x6x.memorykidsfree.ui.MainActivity" 
                  android:screenOrientation="portrait"
                  android:label="@string/activity_title" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity android:name="com.vamp6x6x6x.memorykidsfree.ui.PreferencesActivity"
                  android:screenOrientation="portrait"  
                  android:label="@string/activity_title" >
        </activity>

    </application>

</manifest>

main.xml中

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/fullwrapper"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="#5a4872" >
<LinearLayout 
    android:id="@+id/container"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="vertical"
    android:background="#5a4872" >

         <LinearLayout
            android:id="@+id/splash"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="@drawable/splashscreen"
            android:gravity="center_horizontal|center_vertical"
            android:orientation="vertical" >

            <Button
                android:id="@+id/button_play"
                android:background="@drawable/btn_gameplay"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:gravity="center_horizontal|center_vertical"
                android:orientation="horizontal"
                android:text="@string/button_play"
                android:textColor="#ffffff"
                android:textStyle="bold"
                android:textSize="25.0sp" />

            <ImageView
                android:id="@+id/image_splash"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/appname"
                android:gravity="center_horizontal" />

         </LinearLayout>

    <view
        android:id="@+id/gridview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center"
        android:horizontalSpacing="8dp"
        android:layoutAnimation="@anim/layout_random_fade"
        android:numColumns="4"
        android:stretchMode="columnWidth"
        android:verticalSpacing="8dp"
        android:visibility="gone" />

</LinearLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:gravity="center" >


</LinearLayout>
</LinearLayout>

的settings.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#f0e2ff" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#f0e2ff"
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="8dp"
            android:text="@string/title_hiscore"
            android:textSize="24sp"
            android:textColor="#6a4098"
            android:textStyle="bold" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:gravity="center"
            android:orientation="horizontal"
            android:padding="10dp" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/label_hiscore"
                android:textColor="#8a62b7" />

            <TextView
                android:id="@+id/hiscore"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textStyle="bold"
                android:textColor="#8a62b7" />
        </LinearLayout>

        <Button
            android:id="@+id/button_reset_hiscore"
            android:layout_width="150dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:text="@string/button_reset_hiscore" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="8dp"
            android:text="@string/title_icons"
            android:textSize="24sp"
            android:textColor="#6a4098"
            android:textStyle="bold" />

        <RadioGroup
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:orientation="vertical"
            android:padding="10dp" >

            <RadioButton
                android:id="@+id/radio_mode_fruits"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/radio_mode_fruits"
                android:textColor="#8a62b7" />

            <RadioButton
                android:id="@+id/radio_mode_halloween"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/radio_mode_halloween"
                android:textColor="#8a62b7" />

            <RadioButton
                android:id="@+id/radio_mode_sports"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/radio_mode_sports"
                android:textColor="#8a62b7" />

            <RadioButton
                android:id="@+id/radio_mode_foods"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/radio_mode_foods"
                android:textColor="#8a62b7" />
        </RadioGroup>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#ffa891c2"
            android:padding="5dp"
            android:layout_gravity="center_horizontal"
            android:text="@string/message_effect_new_game"
            android:textSize="14sp"
            android:textColor="#e6daf3"
            android:textStyle="italic" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="8dp"
            android:text="@string/title_sound"
            android:textSize="24sp"
            android:textColor="#6a4098"
            android:textStyle="bold" />

        <ToggleButton
            android:id="@+id/checkbox_sound"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:text="@string/checkbox_sound" />


    </LinearLayout>

</ScrollView>

V14 / settings.xml中

<?xml version="1.0" encoding="UTF-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="#f0e2ff" >


    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#f0e2ff"
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="8dp"
            android:text="@string/title_hiscore"
            android:textSize="24sp"
            android:textColor="#6a4098"
            android:textStyle="bold" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:gravity="center"
            android:orientation="horizontal"
            android:padding="10dp" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/label_hiscore"
                android:textColor="#8a62b7" />

            <TextView
                android:id="@+id/hiscore"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textStyle="bold"
                android:textColor="#8a62b7" />
        </LinearLayout>    

        <Button
            android:id="@+id/button_reset_hiscore"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:text="@string/button_reset_hiscore" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="8dp"
            android:text="@string/title_icons"
            android:textSize="24sp"
            android:textColor="#6a4098"
            android:textStyle="bold" />

        <RadioGroup
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:orientation="vertical"
            android:padding="10dp" >

            <RadioButton
                android:id="@+id/radio_mode_fruits"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/radio_mode_fruits"
                android:textColor="#8a62b7" />

            <RadioButton
                android:id="@+id/radio_mode_halloween"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/radio_mode_halloween"
                android:textColor="#8a62b7" />                                                

            <RadioButton
                android:id="@+id/radio_mode_sports"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/radio_mode_sports"
                android:textColor="#8a62b7" />

            <RadioButton
                android:id="@+id/radio_mode_foods"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/radio_mode_foods"
                android:textColor="#8a62b7" />                                 
        </RadioGroup>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#ffa891c2"
            android:padding="5dp"
            android:layout_gravity="center_horizontal"
            android:text="@string/message_effect_new_game"
            android:textSize="14sp"
            android:textColor="#e6daf3"
            android:textStyle="italic" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="8dp"
            android:text="@string/title_sound"
            android:textSize="24sp"
            android:textColor="#6a4098"
            android:textStyle="bold" />

        <ToggleButton
            android:id="@+id/checkbox_sound"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:text="@string/checkbox_sound" />

         </LinearLayout>

</ScrollView>

根据拉尔托的建议:

    07-28 13:06:50.894: D/dalvikvm(16745): Late-enabling CheckJNI
07-28 13:06:53.113: D/Androidsoft Sound Manager(16745): Init SoundManager
07-28 13:06:53.945: D/dalvikvm(16745): GC_FOR_ALLOC freed 80K, 2% free 8096K/8259K, paused 32ms, total 33ms
07-28 13:06:53.957: I/dalvikvm-heap(16745): Grow heap (frag case) to 10.297MB for 2457616-byte allocation
07-28 13:06:54.062: D/dalvikvm(16745): GC_CONCURRENT freed 1K, 2% free 10495K/10695K, paused 13ms+9ms, total 106ms
07-28 13:06:58.109: I/Ads(16745): To get test ads on this device, call adRequest.addTestDevice("8AC985F3B60E434E427E81FA5A73D9AB");
07-28 13:06:59.742: D/dalvikvm(16745): GC_CONCURRENT freed 340K, 4% free 10889K/11335K, paused 23ms+156ms, total 322ms
07-28 13:07:00.285: D/dalvikvm(16745): DexOpt: --- BEGIN 'ads-938894140.jar' (bootstrap=0) ---
07-28 13:07:00.390: D/AndroidRuntime(16745): Shutting down VM
07-28 13:07:00.390: W/dalvikvm(16745): threadid=1: thread exiting with uncaught exception (group=0x40ec0300)
07-28 13:07:00.402: E/AndroidRuntime(16745): FATAL EXCEPTION: main
07-28 13:07:00.402: E/AndroidRuntime(16745): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vamp6x6x6x.memorykidsfree/com.vamp6x6x6x.memorykidsfree.ui.MainActivity}: java.lang.ClassCastException: android.widget.GridView cannot be cast to com.vamp6x6x6x.memorykidsfree.ui.MemoryGridView
07-28 13:07:00.402: E/AndroidRuntime(16745):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
07-28 13:07:00.402: E/AndroidRuntime(16745):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
07-28 13:07:00.402: E/AndroidRuntime(16745):    at android.app.ActivityThread.access$600(ActivityThread.java:130)
07-28 13:07:00.402: E/AndroidRuntime(16745):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
07-28 13:07:00.402: E/AndroidRuntime(16745):    at android.os.Handler.dispatchMessage(Handler.java:99)
07-28 13:07:00.402: E/AndroidRuntime(16745):    at android.os.Looper.loop(Looper.java:137)
07-28 13:07:00.402: E/AndroidRuntime(16745):    at android.app.ActivityThread.main(ActivityThread.java:4745)
07-28 13:07:00.402: E/AndroidRuntime(16745):    at java.lang.reflect.Method.invokeNative(Native Method)
07-28 13:07:00.402: E/AndroidRuntime(16745):    at java.lang.reflect.Method.invoke(Method.java:511)
07-28 13:07:00.402: E/AndroidRuntime(16745):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-28 13:07:00.402: E/AndroidRuntime(16745):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-28 13:07:00.402: E/AndroidRuntime(16745):    at dalvik.system.NativeStart.main(Native Method)
07-28 13:07:00.402: E/AndroidRuntime(16745): Caused by: java.lang.ClassCastException: android.widget.GridView cannot be cast to com.vamp6x6x6x.memorykidsfree.ui.MemoryGridView
07-28 13:07:00.402: E/AndroidRuntime(16745):    at com.vamp6x6x6x.memorykidsfree.ui.MainActivity.newGame(MainActivity.java:84)
07-28 13:07:00.402: E/AndroidRuntime(16745):    at com.vamp6x6x6x.memorykidsfree.ui.MainActivity.onCreate(MainActivity.java:63)
07-28 13:07:00.402: E/AndroidRuntime(16745):    at android.app.Activity.performCreate(Activity.java:5008)
07-28 13:07:00.402: E/AndroidRuntime(16745):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
07-28 13:07:00.402: E/AndroidRuntime(16745):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
07-28 13:07:00.402: E/AndroidRuntime(16745):    ... 11 more
07-28 13:07:01.070: D/dalvikvm(16745): DexOpt: --- END 'ads-938894140.jar' (success) ---
07-28 13:07:01.070: D/dalvikvm(16745): DEX prep '/data/data/com.vamp6x6x6x.memorykidsfree/cache/ads-938894140.jar': unzip in 0ms, rewrite 784ms
07-28 13:07:01.472: I/Ads(16745): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"preqs":0,"session_id":"5076525192160201353","seq_num":"1","slotname":"MY_AD_UNIT_ID","u_w":320,"msid":"com.vamp6x6x6x.memorykidsfree","js":"afma-sdk-a-v6.4.1","bas_off":0,"net":"wi","app_name":"1.android.com.vamp6x6x6x.memorykidsfree","hl":"en","gnt":3,"carrier":"310260","u_audio":1,"kw":[],"u_sd":1.5,"ms":"XfmY0GOLdWYeRxBmGDWzcLWM2YZ73LBNEiMsr8bPOj3auaZ7P2CSgTcmbnW4JOjQwTK107lvILQ230DxA78eMADkGFWZRS6UkMuLwx6itQSH2Z49LenFzqsVBN_yrXE3GBraLa0BZpe57N6bjNn9scgflWXAvvCDpjUd4Z-RI7G5FrtYEdL0wcJqLMT52lzybHhbyg7FQsgQ5I0s0KId9dSzXVd7SXNvt5zFpSchs90D-V31paUsS_2UvPPjQJrYiv57twerFPeslttkPiBBphSNJRdWVPtEzsvnWg6q6lLbu0ysBTOW5i8f-kVeZr-6DtADNmbqfVSobHdYSj6-rA","mv":"80210010.com.android.vending","isu":"8AC985F3B60E434E427E81FA5A73D9AB","format":"320x50_mb","oar":0,"ad_pos":{"height":0,"visible":0,"y":0,"x":0,"width":0},"u_h":533,"pt":1,"bas_on":0,"ptime":0});</script></head><body></body></html>

2 个答案:

答案 0 :(得分:0)

 <view
    android:id="@+id/gridview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:horizontalSpacing="8dp"
    android:layoutAnimation="@anim/layout_random_fade"
    android:numColumns="4"
    android:stretchMode="columnWidth"
    android:verticalSpacing="8dp"
    android:visibility="gone" />

view无法在此处解析为有效的View类。元素名称可能应为GridView

答案 1 :(得分:0)

我弄清楚了。我忘了将类添加到main.xml