我有一个标记为库的项目和一个使用该库的主要项目。看起来一切都很好,主项目的清单包含来自库的活动,带有孔名(package.name),但我不知道如何调用我导入 mainactivity 的库类(import com.example. libreriasuscripcion.MainActivity;) 从库到主库,当我这样调用它时:
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.d("Juego - onCreate", "en Onclick");
Intent i = new Intent(getBaseContext(), MainActivity.class);
startActivity(i);
}
有一个错误:这是 logCat
03-21 09:45:00.534: E/AndroidRuntime(413): FATAL EXCEPTION: main
03-21 09:45:00.534: E/AndroidRuntime(413): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.juego/com.example.libreriasuscripcion.MainActivity}: java.lang.InstantiationException: com.example.libreriasuscripcion.MainActivity
03-21 09:45:00.534: E/AndroidRuntime(413): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
03-21 09:45:00.534: E/AndroidRuntime(413): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-21 09:45:00.534: E/AndroidRuntime(413): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-21 09:45:00.534: E/AndroidRuntime(413): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-21 09:45:00.534: E/AndroidRuntime(413): at android.os.Handler.dispatchMessage(Handler.java:99)
03-21 09:45:00.534: E/AndroidRuntime(413): at android.os.Looper.loop(Looper.java:123)
03-21 09:45:00.534: E/AndroidRuntime(413): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-21 09:45:00.534: E/AndroidRuntime(413): at java.lang.reflect.Method.invokeNative(Native Method)
03-21 09:45:00.534: E/AndroidRuntime(413): at java.lang.reflect.Method.invoke(Method.java:521)
03-21 09:45:00.534: E/AndroidRuntime(413): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-21 09:45:00.534: E/AndroidRuntime(413): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-21 09:45:00.534: E/AndroidRuntime(413): at dalvik.system.NativeStart.main(Native Method)
03-21 09:45:00.534: E/AndroidRuntime(413): Caused by: java.lang.InstantiationException: com.example.libreriasuscripcion.MainActivity
03-21 09:45:00.534: E/AndroidRuntime(413): at java.lang.Class.newInstanceImpl(Native Method)
03-21 09:45:00.534: E/AndroidRuntime(413): at java.lang.Class.newInstance(Class.java:1429)
03-21 09:45:00.534: E/AndroidRuntime(413): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
03-21 09:45:00.534: E/AndroidRuntime(413): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
03-21 09:45:00.534: E/AndroidRuntime(413): ... 11 more
请你帮助我好吗??提前致谢