简体   繁体   English

Android线性日历java.lang.RuntimeException

[英]Android Linear Calendar java.lang.RuntimeException

So I am new to Android and have been working on a project to develop a linear calendar. 因此,我是Android的新手,并且一直在从事开发线性日历的项目。 While I have developed my code and there are no build errors, there are however runtime errors and I have no idea how to fix them. 虽然我已经开发了代码并且没有构建错误,但是有运行时错误,我也不知道如何解决它们。

12-05 08:51:54.116: E/AndroidRuntime(611): FATAL EXCEPTION: main
12-05 08:51:54.116: E/AndroidRuntime(611): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{cs.nuim.ie.finaltimeline/cs.nuim.ie.finaltimeline.MainActvity}: java.lang.ClassNotFoundException: cs.nuim.ie.finaltimeline.MainActvity
12-05 08:51:54.116: E/AndroidRuntime(611):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
12-05 08:51:54.116: E/AndroidRuntime(611):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
12-05 08:51:54.116: E/AndroidRuntime(611):  at android.app.ActivityThread.access$600(ActivityThread.java:130)
12-05 08:51:54.116: E/AndroidRuntime(611):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
12-05 08:51:54.116: E/AndroidRuntime(611):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-05 08:51:54.116: E/AndroidRuntime(611):  at android.os.Looper.loop(Looper.java:137)
12-05 08:51:54.116: E/AndroidRuntime(611):  at android.app.ActivityThread.main(ActivityThread.java:4745)
12-05 08:51:54.116: E/AndroidRuntime(611):  at java.lang.reflect.Method.invokeNative(Native Method)
12-05 08:51:54.116: E/AndroidRuntime(611):  at java.lang.reflect.Method.invoke(Method.java:511)
12-05 08:51:54.116: E/AndroidRuntime(611):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-05 08:51:54.116: E/AndroidRuntime(611):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-05 08:51:54.116: E/AndroidRuntime(611):  at dalvik.system.NativeStart.main(Native Method)
12-05 08:51:54.116: E/AndroidRuntime(611): Caused by: java.lang.ClassNotFoundException: cs.nuim.ie.finaltimeline.MainActvity
12-05 08:51:54.116: E/AndroidRuntime(611):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
12-05 08:51:54.116: E/AndroidRuntime(611):  at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
12-05 08:51:54.116: E/AndroidRuntime(611):  at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-05 08:51:54.116: E/AndroidRuntime(611):  at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
12-05 08:51:54.116: E/AndroidRuntime(611):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
12-05 08:51:54.116: E/AndroidRuntime(611):  ... 11 more

Here is my MainActivity where the error is arising 这是我的MainActivity发生错误的地方

public class MainActivity extends Activity {
private static final String LogTag = "drgn";

// TODO move timer thing to view itself
Handler handler = new Handler();
Runnable runnable = new Runnable() {
    public void run() {
        contentView.postInvalidate();
        handler.postDelayed(runnable, 250);
    }
};

private TLView contentView;
private CalStuff calstuff;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    calstuff = new CalStuff(this);
    setContentView(R.layout.activity_main);
    contentView= (TLView) findViewById(R.id.fullscreen_content);

}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);

    calstuff.LoadCalendars();
    Log.d(LogTag, "calendars loaded: " + calstuff.ourCalendars.size());

    calstuff.LoadEvents();
    Log.d(LogTag, "events loaded: " + calstuff.ourEvents.size());

    /*
     * calstuff.LoadInstances(); Log.d(LogTag, "instances loaded: " +
     * calstuff.ourInstances.size());
     */

    contentView.SetCalStuff(calstuff);
}

@Override
protected void onPause() {
    Log.d(LogTag, "pause");
    super.onPause();

    handler.removeCallbacks(runnable);
}

@Override
protected void onResume() {
    Log.d(LogTag, "resume");
    super.onResume();

    runnable.run();
}

}

Thanks for any help in advance :) 感谢您的任何帮助:)

Just a thought, but have you checked your Manifest file? 只是一个想法,但是您是否检查了清单文件? There is, as pointed out by EWit, a spelling error in the class name (MainActvity vs MainActivity). 正如EWit指出的那样,类名(MainActvity与MainActivity)之间存在拼写错误。 I think that could come from your AndroidManifest.xml file. 我认为这可能来自您的AndroidManifest.xml文件。

The same issue occurs while including in AndroidManifest reference with: AndroidManifest参考中包含以下内容时,会发生相同的问题:

  <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

and hardcoded wrong google_play_services_version value. 并硬编码错误的google_play_services_version值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM