-1

Help I am new to Android Programming but it is something that I would like to look at more, I was following a tutorial from this website on creating a small app based on Space Invaders. I can't get my app to run from Eclipse I only get LogCat Output error opening trace file: No such file or directory (2).

The rest of my Logcat looks like this:

03-30 23:05:00.758: E/Trace(19674): error opening trace file: No such file or directory (2)
03-30 23:05:00.808: D/AndroidRuntime(19674): Shutting down VM
03-30 23:05:00.808: W/dalvikvm(19674): threadid=1: thread exiting with uncaught exception(group=0x4193a318)
03-30 23:05:00.818: E/AndroidRuntime(19674): FATAL EXCEPTION: main
03-30 23:05:00.818: E/AndroidRuntime(19674): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.spaceyspace/com.example.spaceyspace.BaseActivity}: java.lang.ClassNotFoundException: com.example.spaceyspace.BaseActivity
03-30 23:05:00.818: E/AndroidRuntime(19674):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1987)
03-30 23:05:00.818: E/AndroidRuntime(19674):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2088)
03-30 23:05:00.818: E/AndroidRuntime(19674):    at android.app.ActivityThread.access$600(ActivityThread.java:134)
03-30 23:05:00.818: E/AndroidRuntime(19674):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1199)
03-30 23:05:00.818: E/AndroidRuntime(19674):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-30 23:05:00.818: E/AndroidRuntime(19674):    at android.os.Looper.loop(Looper.java:137)
03-30 23:05:00.818: E/AndroidRuntime(19674):    at android.app.ActivityThread.main(ActivityThread.java:4744)
03-30 23:05:00.818: E/AndroidRuntime(19674):    at java.lang.reflect.Method.invokeNative(Native Method)
03-30 23:05:00.818: E/AndroidRuntime(19674):    at java.lang.reflect.Method.invoke(Method.java:511)
03-30 23:05:00.818: E/AndroidRuntime(19674):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
03-30 23:05:00.818: E/AndroidRuntime(19674):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-30 23:05:00.818: E/AndroidRuntime(19674):    at dalvik.system.NativeStart.main(Native Method)
03-30 23:05:00.818: E/AndroidRuntime(19674): Caused by: java.lang.ClassNotFoundException: com.example.spaceyspace.BaseActivity
03-30 23:05:00.818: E/AndroidRuntime(19674):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-30 23:05:00.818: E/AndroidRuntime(19674):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-30 23:05:00.818: E/AndroidRuntime(19674):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-30 23:015:00.818: E/AndroidRuntime(19674):   at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
03-30 23:05:00.818: E/AndroidRuntime(19674):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1978)
03-30 23:05:00.818: E/AndroidRuntime(19674):    ... 11 more

Please help me

Thanks Mattyhammers

import org.andengine.engine.camera.Camera;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.scene.background.Background;
import org.andengine.entity.util.FPSLogger;
import org.andengine.opengl.font.Font;
import org.andengine.opengl.font.FontFactory;
import org.andengine.ui.activity.SimpleBaseGameActivity;

import android.graphics.Typeface;


public class BaseActivity extends SimpleBaseGameActivity {

    static final int CAMERA_WIDTH = 800;
static final int CAMERA_HEIGHT = 480;

public Font mFont;
public Camera mCamera;

public Scene mCurrentScene;
public static BaseActivity instance;

public EngineOptions onCreateEngineOptions(){
    instance = this;
    mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);

    return new EngineOptions(true, ScreenOrientation.LANDSCAPE_SENSOR, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), mCamera);
}

protected void onCreateResources(){
    mFont = FontFactory.create(this.getFontManager(), this.getTextureManager(), 256, 256, Typeface.create(Typeface.DEFAULT, Typeface.BOLD), 32);
    mFont.load();
}

protected Scene onCreateScene(){
    mEngine.registerUpdateHandler(new FPSLogger());
    mCurrentScene = new Scene();
    mCurrentScene.setBackground(new Background(0.09804f, 0.7274f, 0.8f));
    return mCurrentScene;
}

}

  • What part of my code? – Mattyhammers Mar 30 '14 at 22:56
  • Your mainactivity java class – Noob Mar 30 '14 at 22:57
  • Did you follow https://jimmaru.wordpress.com/2012/04/23/setting-up-andengine-gles2-0/ to setup AndEngine? – Ozan Mar 30 '14 at 22:57
  • Yes I followed that to install andengine – Mattyhammers Mar 30 '14 at 22:59
  • @Noob I Don't have a main activity class only a class called Base activity – Mattyhammers Mar 30 '14 at 23:00
  • Ok post that one then – Noob Mar 30 '14 at 23:01
  • @Noob I have added the Base activity to the original question – Mattyhammers Mar 30 '14 at 23:04
  • Ok. Do you have any other classes? – Noob Mar 30 '14 at 23:05
  • Only ones from the android platform – Mattyhammers Mar 30 '14 at 23:06
  • Your class 'com.example.spaceyspace.BaseActivity' can not be found at runtime. Make sure it is available, check your project setup. – Ozan Mar 30 '14 at 23:08
  • @Ozan my project is set up as shown in the tutorials that I mentioned earlier – Mattyhammers Mar 30 '14 at 23:12
  • is there a 'bin/classes/com/example/spaceyspace/BaseActivity.class'? – Ozan Mar 30 '14 at 23:15
  • No, the BaseActivity.class is in 'bin/classes/BaseActivity.class' should I move it? – Mattyhammers Mar 30 '14 at 23:18
  • Hmm I don't know much about Android development but this doesn't seem right. The bin folder layout should reflect the package names in the folder names. 'AndroidManifest.xml' has a 'package' attribute that says, I guess, 'com.example.spaceyspace', so this is the folder that BaseActivity.class shoud be in. Maybe put them there manually and try it? – Ozan Mar 30 '14 at 23:25
  • I have now moved the BaseActivity class to the 'com.example.spaceyspace' file location and it still doesn't work – Mattyhammers Mar 30 '14 at 23:32
  • You mean 'bin/classes/com/example/spaceyspace/'? – Ozan Mar 30 '14 at 23:52
  • You should consider opening a new question focusing on the classloading issue. – Ozan Mar 30 '14 at 23:56
  • Changed your title to reflect the real error. Your classes (which matter) should be under the src/ folder, those under the bin/ folder are compilation artifacts. As your class extends something called "SimpleBaseGameActivity" which is not part of Android itself, your class will be removed by the installer if SimpleBaseGameActivity is not present in your compiled project. – Chris Stratton Mar 31 '14 at 00:02
  • @ChrisStratton I fail to see how changing the title of the post is actually going to change the outcome of what people have to say on the issue. SimpleBaseGameActivity is from the andengine game engine that I am trying to use as shown in the link that I included within my post – Mattyhammers Mar 31 '14 at 01:45
  • Your title needs to reflect your **actual problem** and that is not the spurious traces file line, but rather the missing class. Either BaseActivity is not in package com.example.spaceyspace (we'd know if you hadn't left the package declaration line out of the posted sources) or else the SimpleBaseGameActivity from Andengine on which it depends is not getting built into the package, causing the installer to remove your Activity class due to its broken dependency. – Chris Stratton Mar 31 '14 at 02:48
  • What’s going on with the rollbacks here? – Ry- Mar 31 '14 at 02:53
  • The OP insists on reverting to a title that is unrelated to the question (it's a spurious issue in the crash reporting system, not the actual cause of the crash), and in the process removing half their code, making the question unanswerable - in that form the only thing that could be done with it would be to close it as such. – Chris Stratton Mar 31 '14 at 02:54
  • @chrisstratton I don't want people correcting me I want a solution to my problem I don't need people telling me how to ask for help I just want people to give me the help if you know the solution then tell me if not then please stop changing my post – Mattyhammers Mar 31 '14 at 14:19
  • 2
    Your problem has been explained several times. But you don't want to listen. So now you have a downvote for sabotaging your question by putting an irrelevant title back on it and removing the information needed to answer it, and a close vote because your question is now unanswerable. – Chris Stratton Mar 31 '14 at 14:38
  • @minitech - since the OP insists that "error opening trace file" is the proper title, this should be closed as a duplicate of http://stackoverflow.com/questions/11446049/error-opening-trace-file-no-such-file-or-directory-2 – Chris Stratton Mar 31 '14 at 14:50
  • @ChrisStratton by putting an error that is the first thing from the log I believe that it will help others who are trying to find a solution without the need to ask the question. Before I posted on this site I spent a couple of hours trying to find the solution on the internet people with very little experience like myself will only search for the main error that they see and not the cause I am trying to help those who aren't confident with their programming skills. Maybe I have chosen the wrong forum as twice I have posted on here and twice people have changed my questions which annoys me – Mattyhammers Mar 31 '14 at 16:24
  • 1
    If you want your question to have that role, then it should be **closed as a duplicate** of the highly upvoted (but utterly useless) question **which already has that role**: http://stackoverflow.com/questions/11446049/error-opening-trace-file-no-such-file-or-directory-2 Unlike in that question, your question actually has the clues to your real problem - but you insist on directing attention away from those, to something which is entirely spurious. – Chris Stratton Mar 31 '14 at 16:27
  • I am not trying to direct attention away from the real problem. It is really annoying having people I don't know changing something that I actually understand to something that I don't understand properly – Mattyhammers Mar 31 '14 at 16:53
  • What you do not seem to understand is that the trace file message **is not your actual problem**. Your actual problem is the class not found exception - and its possible causes have been explained repeatedly. If you were willing to post your *entire* Java file (so that we could see its package declaration line), this could have been solved quite a while ago. – Chris Stratton Mar 31 '14 at 17:35
  • I pasted my file yesterday. I understand that it is not the acctual problem I understand what the problem is it is just that it makes more sense to me to have the trace file message as this is what most people will search for when they have the same problem – Mattyhammers Mar 31 '14 at 20:53
  • Someone having the trace file error message **does not have the same problem as you** because the trace file error message is **universal** on devices where it occurs. It has **nothing to do with the actual problem or its solution**, but will simply show up **anytime a program crashes for ANY reason**. The reason your *particular* program crashes is the class not found exception, so **that** is what you need to fix. But the next person who sees a trace file error will have **an entirely different actual problem and solution**. – Chris Stratton Mar 31 '14 at 21:28

1 Answers1

1

You don't have a class whose name is com.example.spaceyspace.BaseActivity.

03-30 23:05:00.818: E/AndroidRuntime(19674): Caused by: java.lang.ClassNotFoundException: com.example.spaceyspace.BaseActivity

You may have a class called BaseActivity, but it's full name is not com.example.spaceyspace.BaseActivity. You should check the package name for that file and fix it. Your problems are all described in the error messages. Fix them, start with the ones prefixed with "Caused by".

See the comments for alternatives. Note, as you address error messages, the combination of what you did to fix an error and errors that recur will narrow down you true problem.

iheanyi
  • 3,107
  • 2
  • 23
  • 22
  • 1
    Yes, this is the meaningful error message. However, there's a second possible cause, which is that BaseActivity exists in the correct package at compile time but is removed by the installer, because the org.andengine.ui.activity.SimpleBaseGameActivity on which it depends may not be getting included in the .apk. Without the code, specifically the package declaration line from BaseActivity.java, we can't really tell which. – Chris Stratton Mar 31 '14 at 15:39
  • Hmm, this makes sense too! – iheanyi Mar 31 '14 at 15:41
  • @iheanyi thank you for an answer that i am able to understand I will give it a go – Mattyhammers Mar 31 '14 at 16:08