2013-04-09 105 views
0

正在關注this tutorial我在IntelliJ IDEA中爲我的Android項目添加了Maven,ABS和AndroidAnnotations。眼下ABS + IntelliJ IDEA:無法啓動活動

app deps

abs deps

我得到java.lang.RuntimeException: Unable to start activity錯誤:首先,我掙扎着DEX/cannot access android.support.v4.app.FragmentActivity例外,而且似乎具有以下配置修復它。

清單:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
      package="ru.erarta.erarta" 
      android:versionCode="1" 
      android:versionName="1.0"> 
    <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="16" /> 
    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
    <application android:label="@string/app_name" 
       android:theme="@style/Theme.Sherlock" 
       android:icon="@drawable/ic_launcher" 
       android:name=".Erarta"> 
     <activity android:name=".TabsFragmentActivity" 
        android:label="@string/app_name"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN"/> 
       <category android:name="android.intent.category.LAUNCHER"/> 
      </intent-filter> 
     </activity> 
     <activity android:name=".DayActivity_" /> 
     <activity android:name=".CalendarActivity"/> 
     <activity android:name=".AboutActivity"/> 
     <activity android:name=".EventActivity"/> 
     <activity android:name=".PermanentExhibitionActivity"/> 
     <activity android:name=".MediaActivity"/> 
     <activity android:name=".MapActivity"/> 
     <activity android:name=".TypesActivity" android:label="Типы событий"/> 
     <!-- uses-library android:name="com.google.android.maps" /--> 
    </application> 
</manifest> 

主要活動聲明:

public class TabsFragmentActivity extends SherlockFragmentActivity 
     implements TabHost.OnTabChangeListener 

logcat的輸出:

04-09 16:45:48.614: ERROR/AndroidRuntime(26562): FATAL EXCEPTION: main 
     java.lang.RuntimeException: Unable to start activity ComponentInfo{ru.erarta.erarta/ru.erarta.erarta.TabsFragmentActivity}: java.lang.ClassCastException: ru.erarta.erarta.CalendarActivity 
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1872) 
     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893) 
     at android.app.ActivityThread.access$1500(ActivityThread.java:135) 
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054) 
     at android.os.Handler.dispatchMessage(Handler.java:99) 
     at android.os.Looper.loop(Looper.java:150) 
     at android.app.ActivityThread.main(ActivityThread.java:4385) 
     at java.lang.reflect.Method.invokeNative(Native Method) 
     at java.lang.reflect.Method.invoke(Method.java:507) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607) 
     at dalvik.system.NativeStart.main(Native Method) 
     Caused by: java.lang.ClassCastException: ru.erarta.erarta.CalendarActivity 
     at android.support.v4.app.Fragment.instantiate(Fragment.java:384) 
     at ru.erarta.erarta.TabsFragmentActivity.onTabChanged(TabsFragmentActivity.java:108) 
     at ru.erarta.erarta.TabsFragmentActivity.initialiseTabHost(TabsFragmentActivity.java:73) 
     at ru.erarta.erarta.TabsFragmentActivity.onCreate(TabsFragmentActivity.java:51) 
     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072) 
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1836) 
     ... 11 more 

我反編譯APK與apktool這裏是$ find . | grep support

./smali/android/support 
./smali/android/support/v4 
./smali/android/support/v4/app 
./smali/android/support/v4/app/Watson$OnCreateOptionsMenuListener.smali 
./smali/android/support/v4/app/Watson$OnOptionsItemSelectedListener.smali 
./smali/android/support/v4/app/Watson$OnPrepareOptionsMenuListener.smali 
./smali/android/support/v4/app/Watson.smali 
./smali/com/actionbarsherlock/internal/view/View_HasStateListenerSupport.smali 

這裏是代碼周圍TabsFragmentActivity.java:108:

public void onTabChanged(String tag) { 
    TabInfo newTab = this.mapTabInfo.get(tag); 
    if (mLastTab != newTab) { 
     FragmentTransaction ft = this.getSupportFragmentManager().beginTransaction(); 
     if (mLastTab != null) { 
      if (mLastTab.fragment != null) { 
       ft.detach(mLastTab.fragment); 
      } 
     } 
     if (newTab != null) { 
      if (newTab.fragment == null) { 
       newTab.fragment = Fragment.instantiate(this, 
         newTab.clss.getName(), newTab.args); 
       ft.add(R.id.realtabcontent, newTab.fragment, newTab.tag); 
      } else { 
       ft.attach(newTab.fragment); 
      } 
     } 

     mLastTab = newTab; 
     ft.commit(); 
     this.getSupportFragmentManager().executePendingTransactions(); 
    } 
} 
+0

向我們展示您的'CalendarActivity'和第108行的'TabsFragmentActivity' – WarrenFaith 2013-04-09 13:27:17

+0

感謝您的快速回復,我已經爲該問題添加了第108行程序,這裏是['CalendarActivity'](https://gist.github.com/cfr/5345763) – Cfr 2013-04-09 13:44:17

+0

ehm,第108行實際上是'newTab.fragment = Fragment.instantiate(this,newTab.clss.getName(),newTab.args);' – Cfr 2013-04-09 13:46:58

回答

0

的問題是非常基本的:我試圖把FragmentActivity而不是Fragment的標籤。 Here is ABS組的相關討論。

相關問題