我想在我的应用程序中使用GreenDroid库 我在项目设置中将其添加为库。
我的XML:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.korn.tvbrain"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.GreenDroid"
android:name=".TVBrainApplication">>
<activity
android:label="@string/app_name"
android:name=".TVBrainActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
TVBrainActivity:
public class TVBrainActivity extends GDActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setActionBarContentView(R.layout.gd_action_bar_empty);
}
}
申请类:
public class AppBrainApplication extends GDApplication{
@Override
public Class<?> getHomeActivityClass() {
return AppBrainApplication.class;
}
}
错误日志:
10-24 10:25:55.265: E/AndroidRuntime(524): Uncaught handler: thread main exiting due to uncaught exception
10-24 10:25:55.295: E/AndroidRuntime(524): java.lang.RuntimeException: Unable to instantiate application com.korn.tvbrain.TVBrainApplication: java.lang.ClassNotFoundException: com.korn.tvbrain.TVBrainApplication in loader dalvik.system.PathClassLoader@44bfd908
10-24 10:25:55.295: E/AndroidRuntime(524): at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:523)
10-24 10:25:55.295: E/AndroidRuntime(524): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3996)
10-24 10:25:55.295: E/AndroidRuntime(524): at android.app.ActivityThread.access$2900(ActivityThread.java:119)
10-24 10:25:55.295: E/AndroidRuntime(524): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1901)
10-24 10:25:55.295: E/AndroidRuntime(524): at android.os.Handler.dispatchMessage(Handler.java:99)
10-24 10:25:55.295: E/AndroidRuntime(524): at android.os.Looper.loop(Looper.java:123)
10-24 10:25:55.295: E/AndroidRuntime(524): at android.app.ActivityThread.main(ActivityThread.java:4363)
10-24 10:25:55.295: E/AndroidRuntime(524): at java.lang.reflect.Method.invokeNative(Native Method)
10-24 10:25:55.295: E/AndroidRuntime(524): at java.lang.reflect.Method.invoke(Method.java:521)
10-24 10:25:55.295: E/AndroidRuntime(524): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
10-24 10:25:55.295: E/AndroidRuntime(524): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
10-24 10:25:55.295: E/AndroidRuntime(524): at dalvik.system.NativeStart.main(Native Method)
10-24 10:25:55.295: E/AndroidRuntime(524): Caused by: java.lang.ClassNotFoundException: com.korn.tvbrain.TVBrainApplication in loader dalvik.system.PathClassLoader@44bfd908
10-24 10:25:55.295: E/AndroidRuntime(524): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
10-24 10:25:55.295: E/AndroidRuntime(524): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
10-24 10:25:55.295: E/AndroidRuntime(524): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
10-24 10:25:55.295: E/AndroidRuntime(524): at android.app.Instrumentation.newApplication(Instrumentation.java:942)
10-24 10:25:55.295: E/AndroidRuntime(524): at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:518)
10-24 10:25:55.295: E/AndroidRuntime(524): ... 11 more
我总是得到一个ClassNotFound异常。
答案 0 :(得分:2)
在AndroidManifest文件的应用标记中,我猜android:name=".TVBrainApplication"
这里的名称应为android:name=".AppBrainApplication"
答案 1 :(得分:0)
看起来您应该在AndroidManifest中添加android:name=".AppBrainApplication"
而不是android:name=".TVBrainApplication"