0
01-28 13:51:17.332: D/AndroidRuntime(766): Shutting down VM
01-28 13:51:17.332: W/dalvikvm(766): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
01-28 13:51:17.522: E/AndroidRuntime(766): FATAL EXCEPTION: main
01-28 13:51:17.522: E/AndroidRuntime(766): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.canadaqbank.usmle/com.canadaqbank.usmle.USMLEActivity}: java.lang.ClassNotFoundException: com.canadaqbank.usmle.USMLEActivity in loader dalvik.system.PathClassLoader[/data/app/com.canadaqbank.usmle-1.apk]
01-28 13:51:17.522: E/AndroidRuntime(766):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
01-28 13:51:17.522: E/AndroidRuntime(766):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-28 13:51:17.522: E/AndroidRuntime(766):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-28 13:51:17.522: E/AndroidRuntime(766):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-28 13:51:17.522: E/AndroidRuntime(766):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 13:51:17.522: E/AndroidRuntime(766):  at android.os.Looper.loop(Looper.java:123)
01-28 13:51:17.522: E/AndroidRuntime(766):  at android.app.ActivityThread.main(ActivityThread.java:4627)
01-28 13:51:17.522: E/AndroidRuntime(766):  at java.lang.reflect.Method.invokeNative(Native Method)
01-28 13:51:17.522: E/AndroidRuntime(766):  at java.lang.reflect.Method.invoke(Method.java:521)
01-28 13:51:17.522: E/AndroidRuntime(766):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-28 13:51:17.522: E/AndroidRuntime(766):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-28 13:51:17.522: E/AndroidRuntime(766):  at dalvik.system.NativeStart.main(Native Method)
01-28 13:51:17.522: E/AndroidRuntime(766): Caused by: java.lang.ClassNotFoundException: com.canadaqbank.usmle.USMLEActivity in loader dalvik.system.PathClassLoader[/data/app/com.canadaqbank.usmle-1.apk]
01-28 13:51:17.522: E/AndroidRuntime(766):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
01-28 13:51:17.522: E/AndroidRuntime(766):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
01-28 13:51:17.522: E/AndroidRuntime(766):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
01-28 13:51:17.522: E/AndroidRuntime(766):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
01-28 13:51:17.522: E/AndroidRuntime(766):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
01-28 13:51:17.522: E/AndroidRuntime(766):  ... 11 more

我想将一个项目类调用到另一个项目中而不保留该项目中的所有整个代码,我将它添加到构建路径中,并在清单文件中声明了该类,但是当我调用它时,它给了我一个android.view.InflateException: Binary XML file line #8: Error inflating class . I am calling it from intent.

android.view.InflateException: Binary XML file line #8: Error inflating class com.bank.Header
01-28 10:42:57.503: E/AndroidRuntime(309):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
01-28 10:42:57.503: E/AndroidRuntime(309):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-28 10:42:57.503: E/AndroidRuntime(309):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-28 10:42:57.503: E/AndroidRuntime(309):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-28 10:42:57.503: E/AndroidRuntime(309):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 10:42:57.503: E/AndroidRuntime(309):  at android.os.Looper.loop(Looper.java:123)
01-28 10:42:57.503: E/AndroidRuntime(309):  at android.app.ActivityThread.main(ActivityThread.java:4627)
01-28 10:42:57.503: E/AndroidRuntime(309):  at java.lang.reflect.Method.invokeNative(Native Method)
01-28 10:42:57.503: E/AndroidRuntime(309):  at java.lang.reflect.Method.invoke(Method.java:521)
01-28 10:42:57.503: E/AndroidRuntime(309):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-28 10:42:57.503: E/AndroidRuntime(309):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-28 10:42:57.503: E/AndroidRuntime(309):  at dalvik.system.NativeStart.main(Native Method)
01-28 10:42:57.503: E/AndroidRuntime(309): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.bank.Header
01-28 10:42:57.503: E/AndroidRuntime(309):  at android.view.LayoutInflater.createView(LayoutInflater.java:513)
01-28 10:42:57.503: E/AndroidRuntime(309):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
01-28 10:42:57.503: E/AndroidRuntime(309):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
01-28 10:42:57.503: E/AndroidRuntime(309):  at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
01-28 10:42:57.503: E/AndroidRuntime(309):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-28 10:42:57.503: E/AndroidRuntime(309):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-28 10:42:57.503: E/AndroidRuntime(309):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
01-28 10:42:57.503: E/AndroidRuntime(309):  at android.app.Activity.setContentView(Activity.java:1647)
01-28 10:42:57.503: E/AndroidRuntime(309):  at com.bank.us.USActivity.onCreate(USActivity.java:25)
01-28 10:42:57.503: E/AndroidRuntime(309):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-28 10:42:57.503: E/AndroidRuntime(309):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
01-28 10:42:57.503: E/AndroidRuntime(309):  ... 11 more
01-28 10:42:57.503: E/AndroidRuntime(309): Caused by: java.lang.reflect.InvocationTargetException
01-28 10:42:57.503: E/AndroidRuntime(309):  at com.bank.Header.<init>(Header.java:223)
01-28 10:42:57.503: E/AndroidRuntime(309):  at java.lang.reflect.Constructor.constructNative(Native Method)
01-28 10:42:57.503: E/AndroidRuntime(309):  at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
01-28 10:42:57.503: E/AndroidRuntime(309):  at android.view.LayoutInflater.createView(LayoutInflater.java:500)
01-28 10:42:57.503: E/AndroidRuntime(309):  ... 21 more
01-28 10:42:57.503: E/AndroidRuntime(309): Caused by: java.lang.NullPointerException
01-28 10:42:57.503: E/AndroidRuntime(309):  ... 25 more

更新: - 新的 logcat 错误

01-28 13:51:17.332: D/AndroidRuntime(766): Shutting down VM
01-28 13:51:17.332: W/dalvikvm(766): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
01-28 13:51:17.522: E/AndroidRuntime(766): FATAL EXCEPTION: main
01-28 13:51:17.522: E/AndroidRuntime(766): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.bank.us/com.bank.us.USActivity}: java.lang.ClassNotFoundException: com.bank.us.USActivity in loader dalvik.system.PathClassLoader[/data/app/com.bank.us-1.apk]
01-28 13:51:17.522: E/AndroidRuntime(766):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
01-28 13:51:17.522: E/AndroidRuntime(766):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-28 13:51:17.522: E/AndroidRuntime(766):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-28 13:51:17.522: E/AndroidRuntime(766):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-28 13:51:17.522: E/AndroidRuntime(766):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 13:51:17.522: E/AndroidRuntime(766):  at android.os.Looper.loop(Looper.java:123)
01-28 13:51:17.522: E/AndroidRuntime(766):  at android.app.ActivityThread.main(ActivityThread.java:4627)
01-28 13:51:17.522: E/AndroidRuntime(766):  at java.lang.reflect.Method.invokeNative(Native Method)
01-28 13:51:17.522: E/AndroidRuntime(766):  at java.lang.reflect.Method.invoke(Method.java:521)
01-28 13:51:17.522: E/AndroidRuntime(766):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-28 13:51:17.522: E/AndroidRuntime(766):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-28 13:51:17.522: E/AndroidRuntime(766):  at dalvik.system.NativeStart.main(Native Method)
01-28 13:51:17.522: E/AndroidRuntime(766): Caused by: java.lang.ClassNotFoundException: com.canadaqbank.usmle.USMLEActivity in loader dalvik.system.PathClassLoader[/data/app/com.canadaqbank.usmle-1.apk]
01-28 13:51:17.522: E/AndroidRuntime(766):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
01-28 13:51:17.522: E/AndroidRuntime(766):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
01-28 13:51:17.522: E/AndroidRuntime(766):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
01-28 13:51:17.522: E/AndroidRuntime(766):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
01-28 13:51:17.522: E/AndroidRuntime(766):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
01-28 13:51:17.522: E/AndroidRuntime(766):  ... 11 more
4

1 回答 1

0

如果您正在开始另一个项目的活动,那么您可以通过以下方式进行:

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName(
                "com.abc.def.packname",
                "com.abc.def.packname.MyActivity"));

startActivity(intent);
于 2013-01-28T05:43:48.747 回答