Issue
I'm facing this error while eclipse project migration to Android studio. I'm getting this error on 3 classes. All these classes are extending BaseActivity and calling fields from BaseActivity. For example in class SavingActivity inside the onPostExcuteMethod
I'm calling field called mProgressDlg
from BaseActivity and IDE points illegal forward reference to there (well, there is no red line showing under this).
Part of the BaseActivity class code
public abstract class BaseActivity extends Activity implements OnClickListener {
public Button mBtnRefresh = null;
public Context mContext = null;
public GridView mGridView = null;
public ImageLoader mImageLoader = null;
public static ProgressDialog mProgressDlg;
public boolean mRefreshing = false;
public int mScreenWidth = 0;
public TextView mTxtNoData = null;
onPostExcute method in SavingActivity:
protected void onPostExecute(Void result) {
super.onPostExecute(result);
if (SavingActivity.this.mProgressDlg != null) {
try {
SavingActivity.this.mProgressDlg.dismiss();
} catch (Exception e) {
e.printStackTrace();
}
}
SavingActivity.this.mProgressDlg = null;
if (SavingActivity.this.mMusicInfo != null) {
SavingActivity.this.mStrMusicFilePath = SavingActivity.this.mContext.getFilesDir() + CookieSpec.PATH_DELIM + SavingActivity.this.mMusicInfo.strMusicFileName;
SavingActivity.this.refreshPage();
}
}
}
Let me know if you need anything else to analyse.
EDIT: I even commented out the onPostExecute
method and tried building apk from cli gradlew lintRelease
but it's pointing out the error `illegal forward reference to the line which I actually commented. Please see attached images.
Error Log From Terminal:
> Task :app:compileReleaseJavaWithJavac FAILED
E:\Android-Projects-Workspace\name\app\src\main\java\com\name\activities\SavingActivity.java:113: error: illegal forward reference
if (BaseActivity.mProgressDlg != null) {
^
Solution
It seems that Android Studio points you to the wrong class for that error illegal forward reference
. Well, actually compiler experience that error in any one of the classes inside the package. So do check on All classes and you'll definitely find that actual class which has illegal forward reference error
.
Answered By - Nithis Kumar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.