iamovie
iamovie

Reputation: 21

AndroidAnnotations + SherlockFragmentActivity - fragment class not found

I'm having troubles with implementing SherlockFragmentActivity using AndroidAnnotations. I'm using AndroidKickstartR bootstrap project.

When I start the activity I receive an error:

java.lang.ClassNotFoundException: pl.itify.fichas.app.set.FichasSetsNewFragment_

Before extracting the fragments the application worked perfectly well so I assume the problem is not with AndroidAnnotations configuration.

I've tried already changing SherlockFragment into Fragment or v4.Fragment and the error was the same.

I build the app with Maven. I've checked the target folder, the pl.itify.fichas.app.set.FichasSetsNewFragment_ class is generated properly and also included in the .jar file.

I have three classes:

FichasSetsActivity:

@EActivity(R.layout.fichas_sets_activity)
@OptionsMenu(R.menu.fichas_sets_activity)
public class FichasSetsActivity extends SherlockFragmentActivity
{

    @FragmentById(R.id.fichas_set_list_new_fragment)
    FichasSetsNewFragment fichasSetsNewFragment;

    @FragmentById(R.id.fichas_set_list_list_fragment)
    FichasSetsListFragment fichasSetsListFragment;

}

FichasSetsNewFragment:

@EFragment(R.layout.fichas_sets_new_fragment)
public class FichasSetsNewFragment extends SherlockFragment {

}

FichasSetsListFragment:

@EFragment(R.layout.fichas_sets_list_fragment)
public class FichasSetsListFragment extends SherlockFragment {

}

The fichas_sets_activity.xml layout file looks as follows:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <fragment
        android:id="@+id/fichas_set_list_new_fragment"
        android:name="pl.itify.fichas.app.set.FichasSetsNewFragment_"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

    <fragment
        android:id="@+id/fichas_set_list_list_fragment"
        android:name="pl.itify.fichas.app.set.FichasSetsListFragment_"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

</LinearLayout>

Any hint would be appreciated since I've been stuck with the issue for a couple of hours now :(

Cheers!

Upvotes: 1

Views: 1038

Answers (1)

iamovie
iamovie

Reputation: 21

EDIT:

FIXED. It appears that the AndroidKickstartR Proguard configuration filters out all the fragments hence a minor change had to be introduced in proguard.cfg not delete them:

-keep class android.support.v4.** { *; }

-keep public class * extends android.support.v4.**
-keep public class * extends android.app.Fragment

I have already posted an issue in AndroidKickstartR's Github.

Upvotes: 1

Related Questions