0

这一次奏效了。我不知道我做了什么来杀死它。App Force 在任何事情发生之前关闭。下面是LogCat

10-21 15:34:14.503: E/AndroidRuntime(22129): java.lang.RuntimeException: 无法实例化活动 ComponentInfo{com.bigtexapps.android.DropBubble/com.bigtexapps.android.DropBubble.Menu}: java.lang .ClassNotFoundException: com.bigtexapps.android.DropBubble.Menu 在加载器 dalvik.system.PathClassLoader[/data/app/com.bigtexapps.android.DropBubble-2.apk]

以下是 Android 清单:

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

 <uses-sdk android:minSdkVersion="7" 
      android:targetSdkVersion="8"/>

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

<application android:icon="@drawable/icon" 
         android:label="@string/app_name">
<activity    android:name=".Menu"
         android:label="@string/app_name">
         <intent-filter>
<action      android:name="android.intent.action.MAIN" />
<category    android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
         </activity>

 <activity android:name=".DropBubble"> </activity>

  <activity android:name=".Help"> </activity>

 <activity android:name=".GameOver"> </activity>


  </application>

 </manifest>

下面是 Menu.java 的第一部分:

package com.bigtexapps.android.DropBubble;

import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.engine.camera.Camera;
import org.anddev.andengine.engine.options.EngineOptions;
import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation;
import org.anddev.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.scene.menu.MenuScene;
import org.anddev.andengine.entity.scene.menu.MenuScene.IOnMenuItemClickListener;
import org.anddev.andengine.entity.scene.menu.item.IMenuItem;
import org.anddev.andengine.entity.scene.menu.item.SpriteMenuItem;
import org.anddev.andengine.entity.sprite.Sprite;
import org.anddev.andengine.opengl.texture.Texture;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.opengl.texture.region.TextureRegion;
import org.anddev.andengine.opengl.texture.region.TextureRegionFactory;
import org.anddev.andengine.ui.activity.BaseGameActivity;
import android.content.Intent;
/**
 * @author Roger Belk
 * 
*/
 public class Menu extends BaseGameActivity implements IOnMenuItemClickListener{

// ===========================================================
// Constants
// ===========================================================

private static final int CAMERA_WIDTH = 320;
private static final int CAMERA_HEIGHT = 480;
protected static final int MENU_START = 0;
protected static final int MENU_HELP = MENU_START +1;
protected static final int MENU_QUIT = MENU_HELP + 1;

// ===========================================================
// Fields
// ===========================================================
private Camera mCamera;
private MenuScene mMenuScene;
private Scene mMainScene;
private Texture mStartBackGroundTexture;
private TextureRegion mStartBackGroundTextureRegion;
private Texture mStartGameTexture;
private TextureRegion mStartGameTextureRegion;
private TextureRegion mHelpTextureRegion;
private TextureRegion mExitTextureRegion;

public Engine onLoadEngine() {
    this.mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
    return new Engine(new EngineOptions(true, ScreenOrientation.PORTRAIT, 
        new RatioResolutionPolicy(CAMERA_WIDTH,CAMERA_HEIGHT),this.mCamera));   
}

public void onLoadResources() {
    //To import background of resources
    this.mStartBackGroundTexture = new Texture(512, 512, TextureOptions.DEFAULT);
    this.mStartBackGroundTextureRegion = TextureRegionFactory.createFromAsset(this.mStartBackGroundTexture, this, "gfx/startbg.png", 0, 0);
    //Import to start the game resources
    this.mStartGameTexture = new Texture(256,256,TextureOptions.BILINEAR);
    this.mStartGameTextureRegion = TextureRegionFactory.createFromAsset(this.mStartGameTexture, this, "gfx/menu_start.png",0,0);
    this.mHelpTextureRegion = TextureRegionFactory.createFromAsset(this.mStartGameTexture, this, "gfx/menu_help.png",0,50);
    this.mExitTextureRegion = TextureRegionFactory.createFromAsset(this.mStartGameTexture, this, "gfx/menu_quit.png",0,100);

    this.mEngine.getTextureManager().loadTextures(this.mStartBackGroundTexture,this.mStartGameTexture);
}

public Scene onLoadScene() {
    this.createMenuScene();
    this.mMainScene = new Scene(1);
    final int centerX = (CAMERA_WIDTH - this.mStartBackGroundTextureRegion.getWidth()) / 2;
    final int centerY = (CAMERA_HEIGHT -      this.mStartBackGroundTextureRegion.getHeight()) / 2;
    final Sprite bg = new Sprite(centerX, centerY, this.mStartBackGroundTextureRegion); 
    this.mMainScene.setChildScene(this.mMenuScene, false, true, true);  
    this.mMainScene.getTopLayer().addEntity(bg);
    return this.mMainScene;
}
4

2 回答 2

0

看起来你的问题在这里:

java.lang.ClassNotFoundException: com.bigtexapps.android.DropBubble.Menu

确保任何 3rd 方 jar 文件位于项目的 /libs 文件夹中。

在旧版本(r16 及更低版本)中,处理此问题的方法是将您的 3rd 方 jar 放入任何文件夹,然后将该文件夹添加到项目路径中。Google 在 r17 中对此进行了更改,以便将所有第 3 方 jar 文件放入 /libs。

于 2012-10-21T20:46:27.210 回答
0

我认为您没有将 jar 与您的 apk 捆绑在一起。您需要做的只是配置您的构建路径设置并检查 eclipse 的导出选项以获取相应的 jar。

于 2012-10-21T20:50:24.300 回答