0

As title suggests, illegal forward reference I have already seen already posted posts those are belonging to java code. But in my case, I am having issue in package import. Everything was fine perfectly but suddenly I don't know what happened to Android Studio, it started showing me below error

error: illegal forward reference

When I checked build area of Android Studio section under Java compiler and double clicked the error it took me to below packed import statement.

import com.abacusoft.util.AppController;

What is missing or wrong in it? Any help?

My AppController class extending Application class as mentioned below

public class AppController extends Application

EDIT: Below is my complete AppController class

package com.abacusoft.util;

import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import com.abacusoft.services.CallReceivingService;
import com.android.volley.Request;
import com.android.volley.RequestQueue; 
import com.android.volley.toolbox.Volley;

public class AppController extends Application {
public static final String TAG = AppController.class.getSimpleName();

private RequestQueue mRequestQueue;
private static SharedPreferences preferences;

private static AppController mInstance;
private boolean isAppRunningFirstTime = true;

@Override
public void onCreate() {
    super.onCreate();
    mInstance = this;
    preferences = this.getSharedPreferences(AppSharedPref.APP_PREFS, Context.MODE_PRIVATE);

}

@Override
public void onTerminate() {
    super.onTerminate();
    stopService(new Intent(getApplicationContext(), CallReceivingService.class));
}

public static synchronized AppController getInstance() {
    return mInstance;
}

//Get Shared Preference
public SharedPreferences getPreferences() {
    return preferences;
}

public RequestQueue getRequestQueue() {
    if (mRequestQueue == null) {
        mRequestQueue = Volley.newRequestQueue(getApplicationContext());
    }

    return mRequestQueue;
}


public <T> void addToRequestQueue(Request<T> req, Object tag) {
    req.setTag(tag);
    getRequestQueue().add(req);

}

public <T> void addToRequestQueue(Request<T> req) {
    req.setTag(TAG);
    getRequestQueue().add(req);
}

public void cancelPendingRequests(Object tag) {
    if (mRequestQueue != null) {
        mRequestQueue.cancelAll(tag);
    }
}

public boolean isAppRunningFirstTime() {
    return isAppRunningFirstTime;
}

public void setAppRunningFirstTime(boolean appRunningFirstTime) {
    isAppRunningFirstTime = appRunningFirstTime;
}

}

Abdul Waheed
  • 4,540
  • 6
  • 35
  • 58

1 Answers1

0

you are probably calling AppController.getInstance not on the class but on the instance you want to create

something like AppController appController=appController.getinstance()should be

AppController appController=AppController.getinstance()

capital A

jonathan Heindl
  • 844
  • 7
  • 16