致命异常:主要 - Android

时间:2014-12-05 22:40:05

标签: java android eclipse fatal-error

你们可以帮我解决一下我的错误吗?我的游戏即将发布,桌面上运行的Eclipse没有错误,没有任何通知,项目清理多次,但它只是拒绝在我的手机上启动,或者通过带有致命异常的Eclipse作为Android应用程序启动。

Android清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.omnicubegames.onemorejump"
android:versionCode="0098"
android:versionName="0.0.9.8" >

<uses-sdk
    android:minSdkVersion="9"
    android:targetSdkVersion="19" />

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <meta-data
        android:name="com.google.android.gms.games.APP_ID"
        android:value="@string/app_id" />
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <activity
        android:name="com.omnicubegames.onemorejump.MainActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.google.android.gms.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
        android:screenOrientation="portrait" />
</application>

</manifest>

MainActivity.java

package com.omnicubegames.onemorejump;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.Toast;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.games.Games;
import com.google.android.gms.games.GamesActivityResultCodes;
import com.google.example.games.basegameutils.GameHelper;
import com.google.example.games.basegameutils.GameHelper.GameHelperListener;
import com.omnicubegames.onemorejump.CubeMain;
import com.omnicubegames.onemorejump.MyRequestHandler;
import com.omnicubegames.onemorejump.R;
import com.omnicubegames.onemorejump.CubeMain.GameStates;

public class MainActivity extends AndroidApplication implements
    MyRequestHandler {
private CubeMain cubemain;
private GameHelper gamehelper;
private AdRequest adRequest;
private InterstitialAd mInterstitialAd;
private final int SHOW_ADS = 1;
private final int LOAD_ADS = 0;
public String AD_TEST_DEVICE_ID = "XXXXXXXXXXXXXXXXXXXXXXXXXX";


// The Name of your Game for the share function
String NameOfYourGame = "One More Jump";
//
// The link to your Game in the Playstore
private String PlayStoreLink = "https://play.google.com/store/apps/details?id="
        + "com.omnicubegames.onemorejump";
//
//
// Use AdMob Debug Mode
//
public boolean UseDebugMode = true;
//
// AdMob Unit ID
public String AD_UNIT_ID = "ca-app-pub-XXXXXXXXXXXXXXXXXXX";



@SuppressLint("HandlerLeak") protected Handler handler = new Handler() {

    @Override
    public void handleMessage(Message msg) {
        switch (msg.what) {
        case SHOW_ADS: {

            mInterstitialAd.show();
            Gdx.app.log("Show Ads", "");

            break;
        }

        case LOAD_ADS: {

            if (!mInterstitialAd.isLoaded()) {
                if (!UseDebugMode) {
                    adRequest = new AdRequest.Builder().build();
                }
                if (UseDebugMode) {
                    adRequest = new AdRequest.Builder()
                            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                            .addTestDevice(AD_TEST_DEVICE_ID).build();
                }
                mInterstitialAd.loadAd(adRequest);
            }

            Gdx.app.log("Load Ads", "");
            break;
        }
        }
    }
};
private final static int REQUEST_CODE_UNUSED = 9002;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
    cfg.useGLSurfaceView20API18 = false;
    cfg.useWakelock = true;
    cfg.useImmersiveMode = true;
    cfg.hideStatusBar = false;

    cubemain = new CubeMain(this);

    initialize(cubemain, cfg);

    // AdMob INTERSTITIAL
    mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId(AD_UNIT_ID);

    // GameHelper for using Google Play Services
    if (gamehelper == null) {
        gamehelper = new GameHelper(this, GameHelper.CLIENT_GAMES);

        GameHelperListener gameHelperListener = new GameHelper.GameHelperListener() {
            @Override
            public void onSignInSucceeded() {

                cubemain.showGooglePlayServices = true;
                cubemain.gamestate = GameStates.Startscreen;
            }

            @Override
            public void onSignInFailed() {

                cubemain.showGooglePlayServices = true;
                cubemain.gamestate = GameStates.Startscreen;
            }
        };

        gamehelper.setMaxAutoSignInAttempts(1);
        gamehelper.setup(gameHelperListener);
    }
}

// Notify the beginning of a user session.
@Override
protected void onStart() {

    super.onStart();
    gamehelper.onStart(this);

}

@Override
protected void onPause() {
    super.onPause();
    cubemain.pause();
}

@Override
protected void onResume() {
    super.onResume();
    // cubemain.resume();
}

@Override
public void showAds(boolean show) {
    handler.sendEmptyMessage(show ? SHOW_ADS : LOAD_ADS);
}

@Override
public void ShowPlaystore() {
    Intent playstoreIntent = new Intent(Intent.ACTION_VIEW);
    playstoreIntent.setData(Uri.parse(PlayStoreLink));
    startActivity(playstoreIntent);
}

@Override
public void ShowShare() {
    Intent share = new Intent(android.content.Intent.ACTION_SEND);
    share.setType("text/plain");
    share.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    share.putExtra(Intent.EXTRA_SUBJECT, NameOfYourGame);
    share.putExtra(Intent.EXTRA_TEXT, PlayStoreLink);
    startActivity(Intent.createChooser(share, "Share Link via..."));
}

@Override
public void signIn() {
    try {
        runOnUiThread(new Runnable() {
            // @Override
            public void run() {
                gamehelper.beginUserInitiatedSignIn();

            }
        });
    } catch (Exception e) {
        Gdx.app.log("MainActivity", "Log in failed: " + e.getMessage()
                + ".");
    }
}

@Override
public void signOut() {
    try {
        // showToast("Logged out from the Google Play Services!");
        runOnUiThread(new Runnable() {
            // @Override
            public void run() {
                gamehelper.signOut();
            }
        });
    } catch (Exception e) {
        Gdx.app.log("MainActivity", "Log out failed: " + e.getMessage()
                + ".");
    }
}

@Override
public void submitScore(long score, int LeaderboardForHowManyCharacters) {
    if (isSignedIn() == true) {

        if (LeaderboardForHowManyCharacters == 3)

        {
            Games.Leaderboards.submitScore(gamehelper.getApiClient(),
                    getString(R.string.leaderboard_leaderboard_3_jumpers), score);
            // startActivityForResult(Games.Leaderboards.getLeaderboardIntent(
            // gamehelper.getApiClient(),
            // getString(R.string.leaderboard_leaderboard)),
            // REQUEST_CODE_UNUSED);
        } else {
            Games.Leaderboards.submitScore(gamehelper.getApiClient(),
                    getString(R.string.leaderboard_leaderboard_5_jumpers), score);
        }
    } else {
        // Maybe sign in here then redirect to submitting score?
    }
}

@Override
public void showScores(int LeaderboardForHowManyCharacters) {
    if (isSignedIn() == true) {
        if (LeaderboardForHowManyCharacters == 3) {
            startActivityForResult(Games.Leaderboards.getLeaderboardIntent(
                    gamehelper.getApiClient(),
                    getString(R.string.leaderboard_leaderboard_3_jumpers)),
                    REQUEST_CODE_UNUSED);
        } else {
            startActivityForResult(Games.Leaderboards.getLeaderboardIntent(
                    gamehelper.getApiClient(),
                    getString(R.string.leaderboard_leaderboard_5_jumpers)),
                    REQUEST_CODE_UNUSED);
        }
    } else {
        showToast("Please Login to the Google Play Services");
    }
}

@Override
public void showAchievements() {
    if (isSignedIn() == true) {
        startActivityForResult(
                Games.Achievements.getAchievementsIntent(gamehelper
                        .getApiClient()), REQUEST_CODE_UNUSED);
    } else {
        // Maybe sign in here then redirect to showing scores?
    }
}

@Override
public boolean isSignedIn() {
    return gamehelper.isSignedIn();
}

@Override
protected void onActivityResult(int request, int response, Intent data) {
    super.onActivityResult(request, response, data);
    if (response == GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED) {
        gamehelper.disconnect();
    } else {
        gamehelper.onActivityResult(request, response, data);
    }

}

@Override
public void unlockAchievement(String AchId) {
    Games.Achievements.unlock(gamehelper.getApiClient(), AchId);
    // Games.Achievements.unlockImmediate(gamehelper.getApiClient(), AchId);

}

public void showToast(String message) {
    final String temp = message;
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            Context context = getApplicationContext();
            Toast toast = Toast.makeText(context, "" + temp,
                    Toast.LENGTH_SHORT);
            toast.show();
        }
    });

}

}

Logcat错误

12-05 17:21:09.260: D/dalvikvm(849): Trying to load lib /data/app-lib/com.omnicubegames.onemorejump-2/libgdx.so 0xb2dada28
12-05 17:21:09.340: D/dalvikvm(849): Added shared lib /data/app-lib/com.omnicubegames.onemorejump-2/libgdx.so 0xb2dada28
12-05 17:21:09.340: D/dalvikvm(849): No JNI_OnLoad found in /data/app-lib/com.omnicubegames.onemorejump-2/libgdx.so 0xb2dada28, skipping init
12-05 17:21:09.590: D/AndroidRuntime(849): Shutting down VM
12-05 17:21:09.590: W/dalvikvm(849): threadid=1: thread exiting with uncaught exception (group=0xb2af8ba8)
12-05 17:21:09.600: E/AndroidRuntime(849): FATAL EXCEPTION: main
12-05 17:21:09.600: E/AndroidRuntime(849): Process: com.omnicubegames.onemorejump, PID: 849
12-05 17:21:09.600: E/AndroidRuntime(849): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.omnicubegames.onemorejump/com.omnicubegames.onemorejump.MainActivity}: com.badlogic.gdx.utils.GdxRuntimeException: Libgdx requires OpenGL ES 2.0
12-05 17:21:09.600: E/AndroidRuntime(849):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
12-05 17:21:09.600: E/AndroidRuntime(849):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
12-05 17:21:09.600: E/AndroidRuntime(849):  at android.app.ActivityThread.access$800(ActivityThread.java:135)
12-05 17:21:09.600: E/AndroidRuntime(849):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
12-05 17:21:09.600: E/AndroidRuntime(849):  at android.os.Handler.dispatchMessage(Handler.java:102)
12-05 17:21:09.600: E/AndroidRuntime(849):  at android.os.Looper.loop(Looper.java:136)
12-05 17:21:09.600: E/AndroidRuntime(849):  at android.app.ActivityThread.main(ActivityThread.java:5017)
12-05 17:21:09.600: E/AndroidRuntime(849):  at java.lang.reflect.Method.invokeNative(Native Method)
12-05 17:21:09.600: E/AndroidRuntime(849):  at java.lang.reflect.Method.invoke(Method.java:515)
12-05 17:21:09.600: E/AndroidRuntime(849):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
12-05 17:21:09.600: E/AndroidRuntime(849):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
12-05 17:21:09.600: E/AndroidRuntime(849):  at dalvik.system.NativeStart.main(Native Method)
12-05 17:21:09.600: E/AndroidRuntime(849): Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Libgdx requires OpenGL ES 2.0
12-05 17:21:09.600: E/AndroidRuntime(849):  at com.badlogic.gdx.backends.android.AndroidGraphics.createGLSurfaceView(AndroidGraphics.java:121)
12-05 17:21:09.600: E/AndroidRuntime(849):  at com.badlogic.gdx.backends.android.AndroidGraphics.<init>(AndroidGraphics.java:101)
12-05 17:21:09.600: E/AndroidRuntime(849):  at com.badlogic.gdx.backends.android.AndroidGraphics.<init>(AndroidGraphics.java:94)
12-05 17:21:09.600: E/AndroidRuntime(849):  at com.badlogic.gdx.backends.android.AndroidApplication.init(AndroidApplication.java:130)
12-05 17:21:09.600: E/AndroidRuntime(849):  at com.badlogic.gdx.backends.android.AndroidApplication.initialize(AndroidApplication.java:96)
12-05 17:21:09.600: E/AndroidRuntime(849):  at com.omnicubegames.onemorejump.MainActivity.onCreate(MainActivity.java:115)
12-05 17:21:09.600: E/AndroidRuntime(849):  at android.app.Activity.performCreate(Activity.java:5231)
12-05 17:21:09.600: E/AndroidRuntime(849):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-05 17:21:09.600: E/AndroidRuntime(849):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
12-05 17:21:09.600: E/AndroidRuntime(849):  ... 11 more

任何帮助都会很棒。

0 个答案:

没有答案