活动没有注册,但确实如此

时间:2016-04-09 09:17:59

标签: java android manifest

当我打开'NotizBearbeiten.java'(它是一个Activity)时,我得到一个例外。 爪哇:

viewHolderKlasse.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, NotizBearbeiten.class);
                File file = new File(Environment.getExternalStorageDirectory() + "/Notizen/");
                File[] files = file.listFiles();
                File absoluteFile = files[files.length - i - 1].getAbsoluteFile();
                intent.putExtra("text", absoluteFile);
                context.startActivity(intent);
            }
        });

清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="at.wurz.david.recyclerviewtemplate">

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".RecyclerViewActivity"
            android:label="@string/app_name">
        </activity>
        <activity
            android:name=".NotizBearbeiten"
            android:label="@string/app_name">
        </activity>
    </application>

</manifest>

错误:

04-09 11:09:52.823 19738-19738/at.wurz.david.recyclerviewtemplate E/AndroidRuntime: FATAL EXCEPTION: main
Process: at.wurz.david.recyclerviewtemplate, PID: 19738
android.content.ActivityNotFoundException: Unable to find explicit activity class {at.wurz.david.recyclerviewtemplate/at.wurz.david.recyclerviewtemplate.NotizBearbeiten}; have you declared this activity in your AndroidManifest.xml?
    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1772)
    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1496)
    at android.app.Activity.startActivityForResult(Activity.java:3780)
    at android.app.Activity.startActivityForResult(Activity.java:3741)
    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:843)
    at android.app.Activity.startActivity(Activity.java:4051)
    at android.app.Activity.startActivity(Activity.java:4019)
    at at.wurz.david.recyclerviewtemplate.RvAdapterKlasse$1.onClick(RvAdapterKlasse.java:60)
    at android.view.View.performClick(View.java:4811)
    at android.view.View$PerformClick.run(View.java:20136)
    at android.os.Handler.handleCallback(Handler.java:815)
    at android.os.Handler.dispatchMessage(Handler.java:104)
    at android.os.Looper.loop(Looper.java:194)
    at android.app.ActivityThread.main(ActivityThread.java:5546)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)

我的项目结构

enter image description here

我该怎么办?我知道还有其他帖子,但没有解决方案帮助过我:(

现在stackoverflow告诉我我应该添加更多细节,但很抱歉我没有更多。我认为这是你需要知道的一切。

2 个答案:

答案 0 :(得分:0)

请检查您的包裹名称,确保NotizBearbeiten.java位于包裹名称at.wurz.david.recyclerviewtemplate,我相信它不是,因此是例外。

答案 1 :(得分:0)

尝试清理项目或使缓存无效......

enter image description here