I'm using Android-Studio and since last week I couldn't stop at any break point set to any fragment.
If I put a break point in the activity, the debugger breaks as expected.
If the debugger comes to a line like: MyFragment f = new MyFragment(); or any line with a reference to a fragment, and I press "Step into" the debuggeperforms the actions but I still see the debugger stands on the lineMyFragment f = new MyFragment();`
Moreover, I noticed that I get a messages like this in the Debug section:
fragment = No such static field: 'fragment'
chgPicBtn = No such instance field: 'chgPicBtn'
I don't know if it's related but it was worth mentioning.
I've been looking for similar problem online and found nothing. Thanks for the help
Edit: This is a function that calls the activity:
public void displayView(int position) {
String tag = "";
fragment = null;
switch (position) {
case 0:
fragment = new NewFragmentMain();
if (chgPicBtn != null)
chgPicBtn.setVisibility(View.GONE);
tag = "NewFragmentMain";
break;
case 1:
fragment = EditProfileFragment.newInstance(!bool);
tag = "EditProfileFragment";
if (chgPicBtn != null)
chgPicBtn.setVisibility(View.VISIBLE);
break;
...
default:
break;
}
if (fragment != null) {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.container_body, fragment, tag);
fragmentTransaction.addToBackStack(tag).commit();
}
}
The constructor of NewFragmentMain is empty.
EDIT:
The problem was due to:
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
in the gradle file. I turned it to false and everything worked.
Aucun commentaire:
Enregistrer un commentaire