1

我在使用AndroidAnnotations实现 SherlockFragmentActivity 时遇到了麻烦。我正在使用AndroidKickstartR引导项目。

当我开始活动时,我收到一个错误:

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

在提取片段之前,应用程序运行良好,所以我认为问题不在于 AndroidAnnotations 配置。

我已经尝试将 SherlockFragment 更改为 Fragment 或 v4.Fragment 并且错误是相同的。

我使用 Maven 构建应用程序。我检查了目标文件夹,正确生成了 pl.itify.fichas.app.set.FichasSetsNewFragment_ 类并且也包含在 .jar 文件中。

我有三个班级:

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 {

}

fichas_sets_activity.xml 布局文件如下所示:

<?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>

任何提示将不胜感激,因为我已经被这个问题困扰了几个小时了:(

干杯!

4

1 回答 1

1

编辑:

固定的。看来 AndroidKickstartR Proguard 配置过滤掉了所有片段,因此必须在 proguard.cfg 中引入一个小的更改,而不是删除它们:

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

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

我已经在 AndroidKickstartR 的 Github 上发布了一个问题。

于 2013-08-31T10:29:06.447 回答