Java – Android – landroid/app/instrumentation is not accessible when extending application classes

Android – landroid/app/instrumentation is not accessible when extending application classes… here is a solution to the problem.

Android – landroid/app/instrumentation is not accessible when extending application classes

I’m slowly trying to learn android, but I’m coming across a hang up that I don’t quite understand. I’m trying to use some global variables. I extended the application class. I added what I think is correct in the list (the name of the class is Fortune Crunch):

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

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

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

This is what is in my FortuneCrunchActivity.java file:

package com.marctremblay.test.fortunecrunch;
import android.app.Activity;
import android.app.Application;


import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

class FortuneCrunch extends Application{

FortuneCrunch()
{   
}


}


class FortuneCrunchActivity extends Activity {
    /** Called when the activity is first created. */

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

    }

}

I’ve basically removed all my code to try and get this class to work, just to make sure the problem isn’t with anything else. If I remove android::name from my list, I will no longer get the error.

This is an accurate error

newInstance failed: Lcom/marctremblay/test/fortunecrunch/FortuneCrunch; Landroid/app/Instrumentation is inaccessible;

I was stumped. As I’ve seen in many examples, I have this setup. Ideas would be appreciated! Thank you.

Solution

Also, make sure to explicitly expose your class by placing public class XYZ not just class XYZ the .

Otherwise the class will be treated, which will result in the same error.

Related Problems and Solutions