无法使用BetterPickers库实例化活动ComponentInfo

时间:2013-08-20 18:21:29

标签: android android-activity android-manifest runtimeexception

我的应用在添加this库后抛出RuntimeException。现在,例如other posts建议我必须在Activity中声明Manifest。我怎么能用BetterPickers做到这一点? here是来自图书馆的示例应用的Manifest文件,这是我的:

<?xml version="1.0" encoding="utf-8"?>

              

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
     <!-- First item is for saving state while rotating -->
    <activity
        android:windowSoftInputMode="stateHidden|adjustNothing"
        android:configChanges="orientation|keyboardHidden|screenSize" 
        android:launchMode="singleTop"
        android:name="com.foodbuilder.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <!-- Searchable configuration -->
        <intent-filter>
            <action android:name="android.intent.action.SEARCH" />
        </intent-filter>

        <meta-data android:name="android.app.searchable"
        android:resource="@xml/searchable" />
    </activity>
</application>

</manifest>

编辑:这是我的LogCat

08-20 14:32:00.740: E/AndroidRuntime(24371): FATAL EXCEPTION: main
08-20 14:32:00.740: E/AndroidRuntime(24371): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.foodbuilder/com.foodbuilder.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.foodbuilder.MainActivity" on path: /data/app/com.foodbuilder-2.apk
08-20 14:32:00.740: E/AndroidRuntime(24371):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2224)
08-20 14:32:00.740: E/AndroidRuntime(24371):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
08-20 14:32:00.740: E/AndroidRuntime(24371):    at android.app.ActivityThread.access$600(ActivityThread.java:153)
08-20 14:32:00.740: E/AndroidRuntime(24371):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
08-20 14:32:00.740: E/AndroidRuntime(24371):    at android.os.Handler.dispatchMessage(Handler.java:99)
08-20 14:32:00.740: E/AndroidRuntime(24371):    at android.os.Looper.loop(Looper.java:137)
08-20 14:32:00.740: E/AndroidRuntime(24371):    at android.app.ActivityThread.main(ActivityThread.java:5227)
08-20 14:32:00.740: E/AndroidRuntime(24371):    at java.lang.reflect.Method.invokeNative(Native Method)
08-20 14:32:00.740: E/AndroidRuntime(24371):    at java.lang.reflect.Method.invoke(Method.java:511)
08-20 14:32:00.740: E/AndroidRuntime(24371):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
08-20 14:32:00.740: E/AndroidRuntime(24371):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
08-20 14:32:00.740: E/AndroidRuntime(24371):    at dalvik.system.NativeStart.main(Native Method)
08-20 14:32:00.740: E/AndroidRuntime(24371): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.foodbuilder.MainActivity" on path: /data/app/com.foodbuilder-2.apk
08-20 14:32:00.740: E/AndroidRuntime(24371):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
08-20 14:32:00.740: E/AndroidRuntime(24371):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
08-20 14:32:00.740: E/AndroidRuntime(24371):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
08-20 14:32:00.740: E/AndroidRuntime(24371):    at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
08-20 14:32:00.740: E/AndroidRuntime(24371):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2215)
08-20 14:32:00.740: E/AndroidRuntime(24371):    ... 11 more

这就是我的尝试:

<activity>
...
    <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="com.doomonafireball.betterpickers"/>
    </intent-filter>
</activity>

以下是我添加图书馆的方式:

enter image description here

这也是我的实施:

package com.foodbuilder;

import com.doomonafireball.betterpickers.numberpicker.NumberPickerBuilder;
import com.doomonafireball.betterpickers.numberpicker.NumberPickerDialogFragment;

public class MainActivity extends FragmentActivity implements TablesDialogFragment.NoticeDialogListener, NumberPickerDialogFragment.NumberPickerDialogHandler {

...
private NumberPickerBuilder numberPickerBuilder;
...
}

非常感谢!

1 个答案:

答案 0 :(得分:1)

天啊,天啊。经过两天与这个图书馆的斗争。我去了图书馆的properties -> Build Path -> Order and Export and "Unchecked" android-support-v4.jar.我甚至不知道为什么要检查它。