Eclipse Android - 应用程序在启动时崩溃

时间:2014-07-16 14:42:33

标签: java android xml crash logcat

我刚刚开始学习Andriod app开发,特别是eclipse游戏。我最近完成了(过早地)我的项目,并且当我尝试在我的三星Galaxy s4上运行时,应用程序在手机上崩溃,说它停止了。我将不胜感激任何帮助。在下面你将看到我的LogCat和我的Manifest.xml。谢谢。 :

这是我的LogCat:

07-16 16:12:17.565: E/AndroidRuntime(28886): FATAL EXCEPTION: main
07-16 16:12:17.565: E/AndroidRuntime(28886): Process: com.matinshah.fighter, PID: 28886
07-16 16:12:17.565: E/AndroidRuntime(28886): java.lang.RuntimeException: Unable to     instantiate activity ComponentInfo{com.matinshah.fighter/com.matinshah.fighter.Start}: java.lang.ClassNotFoundException: Didn't find class "com.matinshah.fighter.Start" on path: DexPathList[[zip file "/data/app/com.matinshah.fighter-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.matinshah.fighter-1, /vendor/lib, /system/lib]]
07-16 16:12:17.565: E/AndroidRuntime(28886):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at android.app.ActivityThread.access$900(ActivityThread.java:161)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at android.os.Handler.dispatchMessage(Handler.java:102)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at android.os.Looper.loop(Looper.java:157)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at android.app.ActivityThread.main(ActivityThread.java:5356)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at java.lang.reflect.Method.invokeNative(Native Method)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at java.lang.reflect.Method.invoke(Method.java:515)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at dalvik.system.NativeStart.main(Native Method)
07-16 16:12:17.565: E/AndroidRuntime(28886): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.matinshah.fighter.Start" on path: DexPathList[[zip file "/data/app/com.matinshah.fighter-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.matinshah.fighter-1, /vendor/lib, /system/lib]]
07-16 16:12:17.565: E/AndroidRuntime(28886):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at android.app.Instrumentation.newActivity(Instrumentation.java:1079)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2222)
07-16 16:12:17.565: E/AndroidRuntime(28886):    ... 11 more

这是我的Manifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest 
 android:versionCode="4" 
 android:versionName="1.41"
 package="com.matinshah.fighter"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <application 
    android:label="Fighter Chip" 
    android:icon="@drawable/ic_launcher" 
    android:allowBackup="true">
        <activity
        android:label="Fighter Chip" 
        android:name="com.matinshah.fighter.Start">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode" />
    </application>
</manifest>

@Raghunandan这是Start.java:

package com.matinshah.fighter;

import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;
import android.view.Display;
import android.view.WindowManager;
import java.io.IOException;
import org.andengine.audio.sound.Sound;
import org.andengine.audio.sound.SoundFactory;
import org.andengine.engine.Engine;
import org.andengine.engine.LimitedFPSEngine;
import org.andengine.engine.camera.Camera;
import org.andengine.engine.options.AudioOptions;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.RenderOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.entity.scene.Scene;
import org.andengine.opengl.font.BitmapFont;
import org.andengine.opengl.texture.TextureOptions;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.andengine.opengl.texture.region.TextureRegion;
import org.andengine.opengl.texture.region.TiledTextureRegion;
import org.andengine.ui.IGameInterface.OnCreateResourcesCallback;
import org.andengine.ui.IGameInterface.OnCreateSceneCallback;
import org.andengine.ui.IGameInterface.OnPopulateSceneCallback;
import org.andengine.ui.activity.LayoutGameActivity;

public class Start
  extends LayoutGameActivity
{
  private static final int CAMERA_HEIGHT = 512;
  private static final int CAMERA_WIDTH = 288;
  private TextureRegion _bas;
  private TextureRegion _bouton_p;
  private TextureRegion[] _fond;
  private TextureRegion _haut;
  private TextureRegion[] _medaille;
  private TiledTextureRegion[] _player;
  private TextureRegion[] _sol;
  private BitmapTextureAtlas atlas;
  private TextureRegion bouton_s;
  private TextureRegion debut;
  private Sound die;
  Display display;
  private TextureRegion game_over;
  private TextureRegion get_ready;
  private Sound hit;
  private BitmapFont mBitmapFont;
  private Camera m_Camera;
  private TextureRegion noir;
  private TextureRegion nouveau;
  private BitmapFont petit;
  private Sound point;
  private TextureRegion tableau;
  private TextureRegion titre;
  private Sound transition;
  private Sound wing;

  protected int getLayoutID()
  {
    return 2130903063;
  }

  protected int getRenderSurfaceViewID()
  {
    return 2131034172;
  }

  public void loadGraphics()
  {
    this.atlas = new BitmapTextureAtlas(getTextureManager(), 1024, 1024, TextureOptions.NEAREST);
    this._fond[0] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/bg_day.png", 0, 0);
    this._fond[1] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/bg_night.png", 148, 0);
    this._fond[2] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/bg_grey.png", 296, 0);
    this._bouton_p = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/boutonplay.png", 589, 0);
    this.bouton_s = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/rate.png", 699, 0);
    this._sol[0] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/sol.png", 0, 518);
    this._sol[1] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/sol_gris.png", 323, 518);
    this._haut = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/obs_haut.png", 817, 0);
    this._bas = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/obs_bas.png", 874, 0);
    this.titre = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/titre.png", 0, 763);
    this.noir = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/noir.png", 720, 80);
    this._player[0] = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.atlas, getAssets(), "gfx/jaune.png", 592, 80, 3, 1);
    this._player[1] = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.atlas, getAssets(), "gfx/rouge.png", 592, 112, 3, 1);
    this._player[2] = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.atlas, getAssets(), "gfx/bleu.png", 592, 144, 3, 1);
    this._player[3] = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.atlas, getAssets(), "gfx/vert.png", 592, 176, 3, 1);
    this._player[4] = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.atlas, getAssets(), "gfx/rose.png", 592, 208, 3, 1);
    this._player[5] = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.atlas, getAssets(), "gfx/orange.png", 592, 240, 3, 1);
    this._player[6] = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.atlas, getAssets(), "gfx/nul.png", 592, 272, 3, 1);
    this.game_over = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/game_over.png", 0, 816);
    this.debut = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/debut.png", 247, 768);
    this.get_ready = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/get_ready.png", 0, 864);
    this.tableau = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/tableau.png", 0, 636);
    this._medaille[0] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/bronze.png", 720, 130);
    this._medaille[1] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/argent.png", 720, 180);
    this._medaille[2] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/or.png", 720, 230);
    this._medaille[3] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/platine.png", 720, 280);
    this._medaille[4] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/rien.png", 720, 330);
    this.nouveau = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/new.png", 720, 380);
    this.atlas.load();
    this.mBitmapFont = new BitmapFont(getTextureManager(), getAssets(), "font/fin.fnt", TextureOptions.NEAREST);
    this.mBitmapFont.load();
    this.petit = new BitmapFont(getTextureManager(), getAssets(), "font/petit.fnt", TextureOptions.NEAREST);
    this.petit.load();
  }

  public int loadSavedPreferences()
  {
    return PreferenceManager.getDefaultSharedPreferences(this).getInt("best", 0);
  }

  public void loadSounds()
    throws IOException
  {
    this.wing = SoundFactory.createSoundFromAsset(getSoundManager(), getApplicationContext(), "mfx/wing.ogg");
    this.point = SoundFactory.createSoundFromAsset(getSoundManager(), getApplicationContext(), "mfx/point.ogg");
    this.hit = SoundFactory.createSoundFromAsset(getSoundManager(), getApplicationContext(), "mfx/hit.ogg");
    this.die = SoundFactory.createSoundFromAsset(getSoundManager(), getApplicationContext(), "mfx/die.ogg");
    this.transition = SoundFactory.createSoundFromAsset(getSoundManager(), getApplicationContext(), "mfx/transition.ogg");
  }

  public Engine onCreateEngine(EngineOptions paramEngineOptions)
  {
    return new LimitedFPSEngine(paramEngineOptions, 60);
  }

  public EngineOptions onCreateEngineOptions()
  {
    this.m_Camera = new Camera(0.0F, 0.0F, 288.0F, 512.0F);
    EngineOptions localEngineOptions = new EngineOptions(true, ScreenOrientation.PORTRAIT_FIXED, new CropResolutionPolicy(288.0F, 512.0F), this.m_Camera);
    localEngineOptions.getAudioOptions().setNeedsSound(true);
    localEngineOptions.getRenderOptions().setDithering(true);
    this.display = getWindowManager().getDefaultDisplay();
    return localEngineOptions;
  }

  public void onCreateResources(IGameInterface.OnCreateResourcesCallback paramOnCreateResourcesCallback)
    throws IOException
  {
    if (this.display.getHeight() / this.display.getWidth() < 1.61D) {
      this.m_Camera.setCenter(144.0F, 220.0F);
    }
    this._player = new TiledTextureRegion[11];
    this._medaille = new TextureRegion[5];
    this._sol = new TextureRegion[2];
    this._fond = new TextureRegion[3];
    loadGraphics();
    loadSounds();
    paramOnCreateResourcesCallback.onCreateResourcesFinished();
  }

  public void onCreateScene(IGameInterface.OnCreateSceneCallback paramOnCreateSceneCallback)
    throws IOException
  {
    paramOnCreateSceneCallback.onCreateSceneFinished(new MenuScene(this._player, this._fond, this._sol, this._haut, this._bas, this._bouton_p, this.wing, this.point, this.hit, getVertexBufferObjectManager(), this.mBitmapFont, this.mEngine, this.bouton_s, this.game_over, this.get_ready, this.tableau, this.die, this.transition, this.titre, this.bouton_s, this, this.noir, this._medaille, this.debut, this.petit, this.nouveau));
  }

  public void onPopulateScene(Scene paramScene, IGameInterface.OnPopulateSceneCallback paramOnPopulateSceneCallback)
    throws IOException
  {
    paramOnPopulateSceneCallback.onPopulateSceneFinished();
  }

  public void savePreferences(int paramInt)
  {
    SharedPreferences.Editor localEditor = PreferenceManager.getDefaultSharedPreferences(this).edit();
    localEditor.putInt("best", paramInt);
    localEditor.commit();
  }
}

1 个答案:

答案 0 :(得分:1)

你在清单中引用了你的第一个类错误,因此创建了一个classnotfoundexception。确保您完全准确地引用正确的路径。