无法找到明确的活动类 [英] Unable to find explicit activity class

查看:221
本文介绍了无法找到明确的活动类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始android的发展,我被困在这个问题上。当应用程序运行,我招呼着以下内容:

I just began android development, and I'm stuck on this issue. When the application runs, I'm greeted with the following:

http://imgur.com/yIFxvd4

(如果该链接被打破或图像都看不出来,那简直就是在横向模式下的菜单有三个按钮。)

(In case the link is broken or the image can't be seen, it is simply a menu in landscape mode with three buttons.)

这是我希望看到的。然而,当我点击开始播放这应该引起Android模拟器去一个空白屏幕,模拟器退出应用程序的我们,说:不幸的是,MainMenu的已经停止。

This is what I want to see. However, when I click "Start Playing" which should cause the android emulator to go to a blank screen, the emulator quits our of the app and says, "Unfortunately, MainMenu has been stopped."

这是我在LogCat中得到的错误:

This is the error I get in LogCat:

04-15 21:49:08.779: W/dalvikvm(985): threadid=1: thread exiting with uncaught exception 
(group=0x409961f8)

04-15 17:56:24.539: E/AndroidRuntime(739): FATAL EXCEPTION: main
04-15 17:56:24.539: E/AndroidRuntime(739):
android.content.ActivityNotFoundException: Unable to find explicit activity class
{com.example.quote.board/android.inputmethodservice.Keyboard}; have you declared this
activity in your AndroidManifest.xml?
04-15 17:56:24.539: E/AndroidRuntime(739):  at 
android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1508)
04-15 17:56:24.539: E/AndroidRuntime(739):  at 
android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
04-15 17:56:24.539: E/AndroidRuntime(739):  at 
android.app.Activity.startActivityForResult(Activity.java:3190)
04-15 17:56:24.539: E/AndroidRuntime(739):  at 
android.app.Activity.startActivity(Activity.java:3297)
04-15 17:56:24.539: E/AndroidRuntime(739):  at 
com.example.quote.board.MainMenu$1.onClick(MainMenu.java:30)
04-15 17:56:24.539: E/AndroidRuntime(739):  at 
android.view.View.performClick(View.java:3480)
04-15 17:56:24.539: E/AndroidRuntime(739):  at 
android.view.View$PerformClick.run(View.java:13983)
04-15 17:56:24.539: E/AndroidRuntime(739):  at 
android.os.Handler.handleCallback(Handler.java:605)
04-15 17:56:24.539: E/AndroidRuntime(739):  at 
android.os.Handler.dispatchMessage(Handler.java:92)
04-15 17:56:24.539: E/AndroidRuntime(739):  at android.os.Looper.loop(Looper.java:137)
04-15 17:56:24.539: E/AndroidRuntime(739):  at 
android.app.ActivityThread.main(ActivityThread.java:4340)
04-15 17:56:24.539: E/AndroidRuntime(739):  at 
java.lang.reflect.Method.invokeNative(Native Method)
04-15 17:56:24.539: E/AndroidRuntime(739):  at 
java.lang.reflect.Method.invoke(Method.java:511)
04-15 17:56:24.539: E/AndroidRuntime(739):  at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-15 17:56:24.539: E/AndroidRuntime(739):  at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-15 17:56:24.539: E/AndroidRuntime(739):  at 
dalvik.system.NativeStart.main(NativeMethod)

我现在有两班。这是我的第一课,叫MainMenu的:

I currently have two classes. Here is my first class, called MainMenu:

package com.example.quote.board;

import android.inputmethodservice.Keyboard;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainMenu extends Activity {

    @SuppressLint({ "NewApi", "NewApi", "NewApi" })
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_menu);
    ActionBar action= getActionBar();
    action.hide();

    Button startPlaying = (Button) findViewById(R.id.startPlaying);
    Button specialKeyboard = (Button) findViewById(R.id.specialKeyboards);
    Button info = (Button) findViewById(R.id.info);

    startPlaying.setOnClickListener(new OnClickListener(){
        public void onClick(View v){
            Intent intent = new Intent(getApplicationContext(), Keyboard.class);
            startActivity(intent);
        }
    });

}
}

我的其他类被称为键盘:

My other class is called Keyboard:

package com.example.quote.board;

import android.app.ActionBar;
import android.app.Activity;
import android.os.Bundle;

public class Keyboard extends Activity{

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.keyboard);
    ActionBar action = getActionBar();
    action.hide();
}



}

下面是我的Andr​​oidManifest.xml文件:

Here is my AndroidManifest.xml file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.quote.board"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
         >
        <activity
            android:name=".MainMenu"
            android:screenOrientation="landscape"
            android:label="@string/title_activity_main_menu" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name="com.example.quote.board.Keyboard"
            android:screenOrientation="landscape"
            android:label="@string/app_name" >
       </activity>

    </application>

</manifest>

顺便说一句,我一直在做这跟我的朋友,谁在Windows计算机上工作。我们使用的Git将文件传输给我。此外,该应用程序能够在完美的它应该为他的方式。

By the way, I had been making this with my friend, who works on a windows computer. We used git to transfer the files to me. Also, this application works the perfectly the way it should for him.

推荐答案

感谢Simon,问题就解决了​​。我的朋友和我一直在使用不同的Andr​​oid版本,当我从混帐拉,我的code是不兼容的。

Thanks to Simon, the problem was resolved. My friend and I had been using different versions of android, and when I pulled from git, my code wasn't compatible.

这篇关于无法找到明确的活动类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆