Rasmus
Rasmus

Reputation: 1685

Java, Android: Activity not found exception when exporting

I am creating this game for android with java. It works like it should but when I export it and send it to others it gives the activity not found exception, does anyone know why?

Here is my main class:

public class Main extends Activity implements Constants
{
    private GameView mGameView;

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

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        mGameView = new GameView(this, getAssets());
        setContentView(mGameView);

        ActivityManager am = ((ActivityManager)getSystemService(Activity.ACTIVITY_SERVICE));
        mGameView.setMemoryLimit(am.getMemoryClass());
    }
}

And here is the manifest:

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

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

    <application android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" android:theme="@style/AppTheme"
        android:largeHeap="true">
        <activity android:name=".Main" android:label="@string/title_activity_main"
            android:screenOrientation="landscape">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Upvotes: 0

Views: 302

Answers (2)

Imran Khan
Imran Khan

Reputation: 158

unchecke Android Dependencies from Project--> Properties-->Java builder Path-->android dependencies

Upvotes: 0

Oleg Vaskevich
Oleg Vaskevich

Reputation: 12672

Make sure you're not using Proguard improperly which may cause the Activity class to get obfuscated and thus not be found. To do this make sure your proguard.cfg file contains:

-keep public class * extends android.app.Activity

Check that your Main activity is located in the com.testcompany.testgame package (i.e. the package declaration at the top of Main.java). If you are using a subpackage then you need to include that in your AndroidManifest.xml file.

Upvotes: 1

Related Questions