2 xiaoxiaoaishang xiaoxiaoaishang 于 2012.12.21 13:18 提问

开发app时遇到"Source not found"的错误

我今天在做一个app,但是我好想不能找到代码中的错误。
当我检查的时候,没有语法错误,但是当我想要运行或者是测试的时候,就会报错:
"Source not found" on "ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 2106`

它让我找另外一个路径,但是只有一个可用的默认设置。我代码错了吗?怎么解决?

这是logcat:

12-20 22:12:29.722: I/System.out(1518): debugger has settled (1479) 
12-20 22:12:30.172: W/Trace(1518): Unexpected value from nativeGetEnabledTags: 0 
12-20 22:12:30.222: W/Trace(1518): Unexpected value from nativeGetEnabledTags: 0

这个是控制台报的错误:

[2012-12-20 17:19:45 - rockPaperScissorLizardSpock] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.rockpaperscissorlizardspock/.MainActivity }
[2012-12-20 17:19:45 - rockPaperScissorLizardSpock] ActivityManager: Warning: Activity not started, its current task has been brought to the front

这是我源文件:

package com.example.rockpaperscissorlizardspock;
import java.util.Random;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
import android.view.View.OnClickListener;

public class rockpaperscissorlizardspock extends Activity {
    /**当activity第一次创建的时候调用 */

    private TextView resultText;
    private Button play, reset;
    private ImageButton scissors, paper, rock, lizard, spock;
    private int paperimg, paper_pressedimg, scissorsimg, scissors_pressedimg,     rockimg, rock_pressedimg, lizardimg, lizard_pressedimg, spockimg, spock_pressedimg;
        private ImageView compSciss, compPaper, compRock, compLiz, compSpock;
    Random rand = new Random();
    int compChoice = 0;
    String pChoice ="";
    String cChoice = "";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Initialize();
    }

    /** 初始化所有的组件*/
     private void Initialize()
    {
        play = (Button) findViewById(R.id.button1);
        reset = (Button) findViewById(R.id.button2);
        resultText = (TextView) findViewById(R.id.resultText);
        lizard = (ImageButton) findViewById(R.id.imageButton4);
        spock = (ImageButton) findViewById(R.id.imageButton5);
        scissors = (ImageButton) findViewById(R.id.imageButton3);
        paper = (ImageButton) findViewById(R.id.imageButton2);
        rock = (ImageButton) findViewById(R.id.imageButton1);
        compSciss = (ImageView) findViewById(R.id.computerScissors);
        compPaper = (ImageView) findViewById(R.id.computerPaper);
        compRock = (ImageView) findViewById(R.id.computerRock);
        spockimg = R.raw.spock;
        spock_pressedimg = R.raw.spock_pressed;
        lizardimg = R.raw.lizard;
        lizard_pressedimg = R.raw.lizard_pressed;
        paperimg = R.raw.paper;
        paper_pressedimg = R.raw.paper_pressed;
        scissorsimg = R.raw.scissors;
        scissors_pressedimg = R.raw.scissors_pressed;
        rockimg = R.raw.rock1;
        rock_pressedimg = R.raw.rock1_pressed;

        /**设置按钮 Listeners*/
        play.setOnClickListener(new OnClickListener(){
            public void onClick(View arg0){
                play();
            }
        });

        reset.setOnClickListener(new OnClickListener(){
             public void onClick(View arg0){
                paper.setImageResource(paperimg);

                 rock.setImageResource(rockimg);
                scissors.setImageResource(scissorsimg);
                lizard.setImageResource(lizardimg);
                spock.setImageResource(spockimg);
                compPaper.setImageResource(paperimg);
                compRock.setImageResource(rockimg);
                compSciss.setImageResource(scissorsimg);
                compLiz.setImageResource(lizardimg);
                compSpock.setImageResource    (spockimg);               
                pChoice = "";
                cChoice = "";
                play.setEnabled(false);
                reset.setEnabled(true);
                scissors.setEnabled(true);
                paper.setEnabled(true);
                rock.setEnabled(true);
                lizard.setEnabled(true);
                spock.setEnabled(true);
                resultText.setText("");
            }
        });

        /*
         * 当特殊的选择做出的时候声明
         */

        scissors.setOnClickListener(new OnClickListener(){
             public void onClick(View arg0){    
                     scissors.setImageResource(scissors_pressedimg);
                    paper.setImageResource(paperimg);
                    rock.setImageResource(rockimg);
                    spock.setImageResource(spockimg);
                    lizard.setImageResource(lizardimg);
                    pChoice = "S";
                    play.setEnabled(true);
             }
         });

         paper.setOnClickListener(new OnClickListener(){
            public void onClick(View arg0){
                    paper.setImageResource(paper_pressedimg);
                    scissors.setImageResource(scissorsimg);
                    spock.setImageResource(spockimg);
                    rock.setImageResource(rockimg);
                    lizard.setImageResource(lizardimg);
                    pChoice = "P";
                    play.setEnabled(true);
            }
         });

        rock.setOnClickListener(new OnClickListener(){
            public void onClick(View arg0){
                rock.setImageResource(rock_pressedimg);
                scissors.setImageResource(scissorsimg);
                paper.setImageResource(paperimg);
                spock.setImageResource(spockimg);
                lizard.setImageResource(lizardimg);
                pChoice = "R";
                play.setEnabled(true);
            }
        });

        lizard.setOnClickListener(new OnClickListener(){
             public void onClick(View arg0){
                 lizard.setImageResource(lizard_pressedimg);
                 spock.setImageResource(spockimg);
                 rock.setImageResource(rockimg);
                 scissors.setImageResource(scissorsimg);
                 paper.setImageResource(paperimg);
                 pChoice = "L";
                 play.setEnabled(true);
            }
         });

        spock.setOnClickListener(new OnClickListener(){
            public void onClick(View arg0){
                spock.setImageResource(spock_pressedimg);
                lizard.setImageResource(lizardimg);
                rock.setImageResource(rockimg);
                scissors.setImageResource(scissorsimg);
                paper.setImageResource(paperimg);
                pChoice = "SP";
                play.setEnabled(true);
            }
        });

    }

    /**这个方法是对电脑的移动和player的移动做出选择
     *  
     */
    public void play()
    {
        compChoice = rand.nextInt(5);

        if(compChoice == 0)
        {
            cChoice = "R";
            compRock.setImageResource(rock_pressedimg);
            }
        else if(compChoice == 1){
            cChoice = "P";
            compPaper.setImageResource(paper_pressedimg);
        }       
         else if(compChoice == 2)
        {
            cChoice = "S";
            compSciss.setImageResource(scissors_pressedimg);
            }
        else if(compChoice == 3)
           {
            cChoice = "L";
             compLiz.setImageResource(lizard_pressedimg);
            }
        else if(compChoice == 4)
       { 
       cChoice = "SP";
       compSpock.setImageResource(spock_pressedimg);
       }

    check();
}

/**
 * 比较电脑和player的移动
 */
public void check()
{
    if(pChoice == "R") //Rock
    {
        if(cChoice == "R")
            resultText.setText("Draw");

        else if(cChoice == "P")
            resultText.setText("You Lose");

        else if(cChoice == "S")
            resultText.setText("You Win");

        else if(cChoice == "L")
            resultText.setText("You Win");

        else if(cChoice == "SP")
            resultText.setText("You Lose");
    }

    else if(pChoice == "P") //Paper
    {
        if(cChoice == "R")
            resultText.setText("You Win");

        else if(cChoice == "P")
            resultText.setText("Draw");

        else if(cChoice == "S")
            resultText.setText("You Lose");

        else if(cChoice == "SP")
            resultText.setText("You Win");

        else if(cChoice == "L")
            resultText.setText("You Lose");


    }

    else if(pChoice == "S") //Scissors
    {
        if(cChoice == "R")
            resultText.setText("You Lose");

        else if(cChoice == "P")
            resultText.setText("You Win");

        else if(cChoice == "S")
            resultText.setText("Draw");

        else if(cChoice == "L")
            resultText.setText("You Win");

        else if(cChoice == "SP")
            resultText.setText("You Lose");


    }

    else if(pChoice == "L") //Lizard
    {
      if(cChoice == "R")
        resultText.setText("You Lose");

      else if(cChoice == "L")
        resultText.setText("Draw");

      else if(cChoice == "SP")
        resultText.setText("You Win");

      else if(cChoice == "S")
        resultText.setText("You Lose");

      else if(cChoice == "P")
        resultText.setText("You Win");
    }

    else if(pChoice == "SP") //Spock
    {
        if(cChoice == "SP")
            resultText.setText("Draw");

        else if(cChoice == "L")
            resultText.setText("You Lose");

        else if(cChoice == "S")
            resultText.setText("You Win");

        else if(cChoice == "P")
            resultText.setText("You Lose");

        else if(cChoice == "R")
            resultText.setText("You Win");

    }

    gameOver();
}


/**
 * 在每次round后运行,除了reset按钮禁用所有按钮
 * 
 */
public void gameOver()
{
    play.setEnabled(false);
    scissors.setEnabled(false);
    rock.setEnabled(false);
    paper.setEnabled(false);
    spock.setEnabled(false);
    lizard.setEnabled(false);
    reset.setEnabled(true);
}

1个回答

niangzhi
niangzhi   2012.12.21 14:04
已采纳

看起来好像你需要给你的AndroidManifest.xml加activity。看起来应该是这样,被定位在app的部分manifest中。详细的你可以看看这个http://developer.android.com/guide/topics/manifest/manifest-intro.html
这个是一个例子:

<activity
    android:name=".rockpaperscissorlizardspock"
    android:label="@string/app_name"
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
xiaoxiaoaishang
xiaoxiaoaishang 谢谢!
5 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
eclipse临时目录 虚拟目录与Eclipse中启动tomcat 浏览器无法访问8080端口问题
第一次: CommonResVO commonResVO =JSON.parseObject(result, CommonResVO.class);   本来JSON.parseObject()方法的第一个参数应该是一个json字符串,但在这里我传的参数是xml字符串。   例子:        Debug到这一句的时候,再step over 就报source notfound
debug后显示Source not found的问题处理
今天在进行新的项目调试时,在jboss7.1的环境下进行debug模式的调试。调试后出现了Source not found,并且下方出现了edit source lookup的按钮。 最后解决的方法很简单: 1.点击edit source lookup的按钮,或者右击线程选择edit source lookup path 2.里面会有个默认的default项目,我们只
对于eclipse写java程序时,想查看一下java源代码,出现Source not found 的原因与解决办法
对于eclipse写java程序时,想查看一下java源代码,出现Source not found 如下图: 原因Eclipse默认设定的自带的JDK是没有源src的,需要引入,点击attach Source...添加jdk的src.zip就可以了
elipes遇到 source not found解决方案
在用Myeclipse 或者是eclipse进行开发时候经常遇到这个问题。  File class editor  source not found问题。原因很简单,就是因为这是一个源码包,相应的没有编辑器能够打开它。 工具/原料  myeclipse、eclipse 方法/步骤1 1  首先,需要下载两个必须的插件包。
AD分发JRE提示Error 1311.Source file not found.
今天要在AD通过GPO给特定的客户端分发最新版的JRE。因为官方不提供msi文件下载,按照Oracle的文档说明(图一所示),需要在一台电脑上通过JRE的EXE文件安装好JRE后,在X:\Users\\AppData\LocalLow\Sun\Java\jreX.X\(Windows7)下找到JRE的msi文件,把它copy到Server,然后就可以在GPO上新建Package,选择保存的那份ms
MyElipes遇到 source not found解决方案
在用Myeclipse 或者是eclipse进行开发时候经常遇到这个问题。  File class editor  source not found问题。原因很简单,就是因为这是一个源码包,相应的没有编辑器能够打开它。 工具/原料  myeclipse、eclipse 方法/步骤1
解决eclipse调试程序时source not found的问题
之前debug还好好的,今天debug就出现source not found的问题,baidugu
mysql source 忽略错误继续执行
mysql -h$1 -P$2 -u$3 -p$4 -D$5 -s -N -e  " source$TAB_ONLY_LIST" 发现一个语句报错,整个过程就失败了。 增加--force 或-f依旧报错 mysql -h$1 -P$2 -u$3 -p$4 -D$5 -s -N -f -e  " source$TAB_ONLY_LIST" 网上查了一下,说这不是bug,解
hibernate 遇到Source not found for 错误
以下代码运行时有个没有任何错误提示,但无法取得结果 @Service public class KCardService extends HibernateEntityHwattDao{ @SuppressWarnings("unchecked") public List getCardsByEmployee(KEmployee employee,Date start,Date end){
debug时遇到source not found
先检查布局文件中各个控件的全名称是否,清理缓存