本文介绍了Android应用程序,"源未发现"调试错误 - 尝试下载Android源$ C ​​$ C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到在我的Andr​​oid应用程序的错误,说:源未发现,并导致程序崩溃。我已经读了一些帖子说,解决办法是下载Android源$ C ​​$ c和加载在Eclipse的,但我想也没有用。

I'm getting an error in my Android app that says "source not found" and crashes the program. I've already read a number of posts saying that the solution is to download the android source code and load that up in Eclipse, but I tried to no avail.

下面是一堆的,可能与我的问题有所帮助,让我知道,如果你需要更多的!信息

Here is a bunch of information that may help with my problem, let me know if you need more!

堆栈:

Thread [<1> main] (Suspended (exception RuntimeException))
ActivityThread.performLaunchActivity(ActivityThrea d$ActivityRecord, Intent) line: 2663
ActivityThread.handleLaunchActivity(ActivityThread $ActivityRecord, Intent) line: 2679
ActivityThread.access$2300(ActivityThread, ActivityThread$ActivityRecord, Intent) line: 125
ActivityThread$H.handleMessage(Message) line: 2033
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4627
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 868
ZygoteInit.main(String[]) line: 626
NativeStart.main(String[]) line: not available [native method]

是很奇怪的第一项是ActivityThrea D'与'D'切断?如果是这样的问题,哪里出了问题,我如何解决这个问题?

Is it weird that the first entry is 'ActivityThrea d' with the 'd' cut off? If this is the problem, what went wrong and how do I fix it?

code调试的行停在:

The line of code the debug stops on:

public void AddAnimationID(String index, Integer view)
{
 animations.put(index, view);
}

动画是一个字典,是外星人类的成员。我打电话像:

'animations' is a Dictionary and is a member of class Alien. I am calling it like:

Alien alien;
alien.AddAnimationID("idle", R.drawable.idle);

我在想,R.drawable.idle是一个int权是否正确? findViewByID需要一个int的参数...

I am correct in thinking that R.drawable.idle is an int right? findViewByID takes an int for the argument...

下面是logcat中,我试图找出其中的记录它启动的应用程序,对不起,如果它的太多了。

Here is the logcat, I tried to pinpoint where in the log it started the application, sorry if its too much.

I/ActivityManager(   59): Displayed activity com.android.launcher/com.android.la
uncher2.Launcher: 21357 ms (total 21357 ms)
I/Launcher.Model(  118): not binding apps: no Launcher activity
D/dalvikvm(  118): GC_EXPLICIT freed 5222 objects / 297520 bytes in 114ms
D/dalvikvm(  118): GC_EXPLICIT freed 11360 objects / 562112 bytes in 94ms
D/PackageParser(   59): Scanning package: /data/app/vmdl45576.tmp
I/PackageParser(   59): Game.Main: compat added android.permission.WRITE_EXTERNA
L_STORAGE android.permission.READ_PHONE_STATE
I/PackageManager(   59): Removing non-system package:Game.Main
I/ActivityManager(   59): Force stopping package Game.Main uid=10032
D/dalvikvm(  118): GC_EXTERNAL_ALLOC freed 319 objects / 18064 bytes in 73ms
D/dalvikvm(   59): GC_FOR_MALLOC freed 6857 objects / 349752 bytes in 400ms
D/PackageManager(   59): Scanning package Game.Main
I/PackageManager(   59): Package Game.Main codePath changed from /data/app/Game.
Main-2.apk to /data/app/Game.Main-1.apk; Retaining data and using new
I/PackageManager(   59): /data/app/Game.Main-1.apk changed; unpacking
D/installd(   34): DexInv: --- BEGIN '/data/app/Game.Main-1.apk' ---
I/ActivityManager(   59): Starting activity: Intent { act=android.intent.action.
MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=Game.Main/.Main }

D/dalvikvm(  258): DexOpt: load 116ms, verify 200ms, opt 2ms
D/installd(   34): DexInv: --- END '/data/app/Game.Main-1.apk' (success) ---
W/PackageManager(   59): Code path for pkg : Game.Main changing from /data/app/G
ame.Main-2.apk to /data/app/Game.Main-1.apk
W/PackageManager(   59): Resource path for pkg : Game.Main changing from /data/a
pp/Game.Main-2.apk to /data/app/Game.Main-1.apk
D/PackageManager(   59):   Activities: Game.Main.Main
I/ActivityManager(   59): Force stopping package Game.Main uid=10032
E/Launcher(  118): Unable to launch. tag=ApplicationInfo(title=Alien Game) inten
t=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]
 flg=0x10200000 cmp=Game.Main/.Main }
E/Launcher(  118): android.content.ActivityNotFoundException: Unable to find exp
licit activity class {Game.Main/Game.Main.Main}; have you declared this activity
 in your AndroidManifest.xml?
E/Launcher(  118):      at android.app.Instrumentation.checkStartActivityResult(
Instrumentation.java:1404)
E/Launcher(  118):      at android.app.Instrumentation.execStartActivity(Instrum
entation.java:1378)
E/Launcher(  118):      at android.app.Activity.startActivityForResult(Activity.
java:2817)
E/Launcher(  118):      at com.android.launcher2.Launcher.startActivityForResult
(Launcher.java:1053)
E/Launcher(  118):      at android.app.Activity.startActivity(Activity.java:2923
)
E/Launcher(  118):      at com.android.launcher2.Launcher.startActivitySafely(La
uncher.java:1462)
E/Launcher(  118):      at com.android.launcher2.AllApps2D.onItemClick(AllApps2D
.java:178)
E/Launcher(  118):      at android.widget.AdapterView.performItemClick(AdapterVi
ew.java:284)
E/Launcher(  118):      at android.widget.AbsListView$PerformClick.run(AbsListVi
ew.java:1696)
E/Launcher(  118):      at android.os.Handler.handleCallback(Handler.java:587)
E/Launcher(  118):      at android.os.Handler.dispatchMessage(Handler.java:92)
E/Launcher(  118):      at android.os.Looper.loop(Looper.java:123)
E/Launcher(  118):      at android.app.ActivityThread.main(ActivityThread.java:4
627)
E/Launcher(  118):      at java.lang.reflect.Method.invokeNative(Native Method)
E/Launcher(  118):      at java.lang.reflect.Method.invoke(Method.java:521)
E/Launcher(  118):      at com.android.internal.os.ZygoteInit$MethodAndArgsCalle
r.run(ZygoteInit.java:868)
E/Launcher(  118):      at com.android.internal.os.ZygoteInit.main(ZygoteInit.ja
va:626)
E/Launcher(  118):      at dalvik.system.NativeStart.main(Native Method)
I/installd(   34): move /data/dalvik-cache/data@[email protected]@classes.dex
-> /data/dalvik-cache/data@[email protected]@classes.dex
D/PackageManager(   59): New package installed in /data/app/Game.Main-1.apk
I/ActivityManager(   59): Force stopping package Game.Main uid=10032
I/ActivityManager(   59): Start proc com.svox.pico for broadcast com.svox.pico/.
VoiceDataInstallerReceiver: pid=259 uid=10028 gids={}
D/dalvikvm(  157): GC_EXPLICIT freed 4079 objects / 247824 bytes in 605ms
D/dalvikvm(   59): GC_EXPLICIT freed 6136 objects / 382312 bytes in 493ms
W/RecognitionManagerService(   59): no available voice recognition services foun
d
I/installd(   34): unlink /data/dalvik-cache/data@[email protected]@classes.de
x
D/AndroidRuntime(  191): Shutting down VM
D/jdwp    (  191): adbd disconnected
I/AndroidRuntime(  191): NOTE: attach of thread 'Binder Thread #3' failed
I/ActivityThread(  259): Publishing provider com.svox.pico.providers.SettingsPro
vider: com.svox.pico.providers.SettingsProvider
D/AndroidRuntime(  269):
D/AndroidRuntime(  269): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
D/AndroidRuntime(  269): CheckJNI is ON
D/AndroidRuntime(  269): --- registering native functions ---
I/ActivityManager(   59): Starting activity: Intent { act=android.intent.action.
MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=Game.Main/.Main }

I/ActivityManager(   59): Start proc Game.Main for activity Game.Main/.Main: pid
=273 uid=10032 gids={1015}
I/ARMAssembler(   59): generated scanline__00000077:03545404_00000004_00000000 [
 47 ipp] (67 ins) at [0x322b68:0x322c74] in 4370882 ns
W/Game.Main.Main(  273): SIS is null
D/AndroidRuntime(  273): Shutting down VM
W/dalvikvm(  273): threadid=1: thread exiting with uncaught exception (group=0x4
001d800)
E/AndroidRuntime(  273): FATAL EXCEPTION: main
E/AndroidRuntime(  273): java.lang.RuntimeException: Unable to start activity Co
mponentInfo{Game.Main/Game.Main.Main}: java.lang.NullPointerException
E/AndroidRuntime(  273):        at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2663)
E/AndroidRuntime(  273):        at android.app.ActivityThread.handleLaunchActivi
ty(ActivityThread.java:2679)
E/AndroidRuntime(  273):        at android.app.ActivityThread.access$2300(Activi
tyThread.java:125)
E/AndroidRuntime(  273):        at android.app.ActivityThread$H.handleMessage(Ac
tivityThread.java:2033)
E/AndroidRuntime(  273):        at android.os.Handler.dispatchMessage(Handler.ja
va:99)
E/AndroidRuntime(  273):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(  273):        at android.app.ActivityThread.main(ActivityThrea
d.java:4627)
E/AndroidRuntime(  273):        at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime(  273):        at java.lang.reflect.Method.invoke(Method.java:5
21)
E/AndroidRuntime(  273):        at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime(  273):        at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:626)
E/AndroidRuntime(  273):        at dalvik.system.NativeStart.main(Native Method)

E/AndroidRuntime(  273): Caused by: java.lang.NullPointerException
E/AndroidRuntime(  273):        at Game.Main.Main.onCreate(Main.java:81)
E/AndroidRuntime(  273):        at android.app.Instrumentation.callActivityOnCre
ate(Instrumentation.java:1047)
E/AndroidRuntime(  273):        at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2627)
E/AndroidRuntime(  273):        ... 11 more
W/ActivityManager(   59):   Force finishing activity Game.Main/.Main
I/ActivityManager(   59): Starting activity: Intent { act=android.intent.action.
MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=Game.Main/.Main }

D/AndroidRuntime(  269): Shutting down VM
D/jdwp    (  269): adbd disconnected
I/AndroidRuntime(  269): NOTE: attach of thread 'Binder Thread #3' failed
W/ActivityManager(   59): Activity pause timeout for HistoryRecord{43ed84f8 Game
.Main/.Main}
I/ARMAssembler(   59): generated scanline__00000077:03515104_00000000_00000000 [
 33 ipp] (47 ins) at [0x305640:0x3056fc] in 1148283 ns
W/ActivityManager(   59): Launch timeout has expired, giving up wake lock!

下面是类异形:

package Game.Main;

import java.util.Dictionary;

import android.graphics.drawable.AnimationDrawable;
import android.widget.ImageView;

public class Alien
{
    private AlienState state;
    private Dictionary<String, Integer> animations;
    private ImageView imageView;

    public Alien()
    {

    }

    public void AddAnimationID(String index, Integer view)
    {
        animations.put(index, view);
    }

    public Integer GetAnimationID(String index)
    {
        return animations.get(index);
    }

    public void SetImageView(ImageView view)
    {
        imageView = view;
        if(animations.get("idle") != null)
        {
            imageView.setBackgroundResource(R.drawable.idle);
            state = AlienState.idle;
        }
    }

    public ImageView GetImageView()
    {
        return imageView;
    }

    public void ChangeView(String index)
    {
        if(animations.get(index) != null)
        {
            imageView.setBackgroundResource(animations.get(index));
            state = AlienState.valueOf(index);
        }
    }
}

下面是的onCreate函数,这就是所谓的从和相关信息:

Here is the onCreate function that this is called from and related information:

package Game.Main;

import java.util.ArrayList;
import java.util.List;

import Game.Main.MainView.MainThread;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation.AnimationListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class Main extends Activity implements OnClickListener {

    private static final int VOICE_RECOGNITION_REQUEST_CODE = 1234;

    private ArrayList<String> dictionary;
    private TextView txtText;

    private MainThread thread;
    private MainView view;

    private AnimationDrawable anim;

    private Alien alien;

    @Override // called when Main is created.
    public void onCreate(Bundle savedInstanceState) {

        // reload from previous instance
        super.onCreate(savedInstanceState);

        // set default content view
        setContentView(R.layout.main);

        view = (MainView)findViewById(R.id.mainView);
        thread = view.GetThread();

        if (savedInstanceState == null) {
            // we were just launched: set up a new game
            thread.SetState(GameState.Active);
            Log.w(this.getClass().getName(), "SIS is null");
        } else {
            // we are being restored: resume a previous game
            thread.RestoreState(savedInstanceState);
            Log.w(this.getClass().getName(), "SIS is nonnull");
        }



        // setup speak button
        Button speakButton = (Button)findViewById(R.id.btn_speak);

        // setup text box
        txtText = (TextView)findViewById(R.id.txt_text);

        // setup our dictionary
        dictionary = new ArrayList<String>();
        dictionary.add("sit");
        dictionary.add("eat");
        dictionary.add("jump");
        dictionary.add("think");

        alien.AddAnimationID("idle", R.drawable.idle);
        alien.AddAnimationID("eat", R.drawable.eat);
        alien.AddAnimationID("jump", R.drawable.jump);
        alien.AddAnimationID("think", R.drawable.think);
        alien.AddAnimationID("run", R.drawable.run);
        alien.AddAnimationID("sit", R.drawable.sit);
        alien.SetImageView((ImageView)findViewById(R.id.alien_image));

        // check to see if a recognition activity is present
        PackageManager pm = getPackageManager();
        List<ResolveInfo> activities = pm.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);

        // if activities were found, cancel speech recognition
        if (activities.size() != 0)
            speakButton.setOnClickListener(this);
        else
        {
            speakButton.setEnabled(false);
            speakButton.setText("Recognizer not present");
        }
    }

我使用的Windows 7 64位的Eclipse。我有所有最新的更新到Android SDK以及我下载了Android源$ C ​​$ c和它添加到Eclipse修补程序,因为previous的帖子促使我尝试。用于调试的code休息的时候第一次AddAnimationID被调用。我希望这是你所需要的,谢谢!很抱歉,如果我这样做是错误的方式,我有点新的这个。

I am using Eclipse on Windows 7 x64. I have all of the newest updates to the android SDK and I downloaded the android source code and added it to the Eclipse patch because previous posts led me to try that. The code breaks for debug when the first time AddAnimationID is called. I hope this is all you need, thanks! Sorry if I'm doing this wrong by the way, I'm somewhat new at this.

编辑:貌似我没有足够的断点,罪魁祸首不是AddAnimationID功能,但实际上SetImageView之一。 if语句似乎无法工作,所以我评论过它现在。我会后回来一次,我想通了。这可能是一些愚蠢的,在另一种语言的作品,但不是Java ...

Looks like I didn't have enough breakpoints, the culprit is not the AddAnimationID function but actually the SetImageView one. The if statement seems to not work, so I've commented it out for now. I'll post back once I've figured it out. It's probably something silly that works in another language but not Java...

推荐答案

问题结束了Dictionary类,我得到了它隐约在一堆try / catch块投掷工作,但是这不是我想要的,所以我用地图取代它,它工作正常。

The problem ended up being the Dictionary class, I got it to vaguely work by throwing in a bunch of try/catch blocks, but that wasn't what I wanted, so I replaced it with a Map and it works fine.

要追加从那时起,我发现这个答案一些有用的信息,为的人访问此页面体面号:Eclipse会说找不到源代码近在你的应用程序使每个随机误差。这里有一些步骤,以找到code的这些麻烦的线路如下:

To append some useful information I've found since then to this answer, as a decent number of people have visited this page: Eclipse will say "Source not found" for nearly every random error you make in your app. Here are some steps to follow in order to locate these troublesome lines of code:

1)通过你的code步骤行由行(使用步进器忽略code,你没写),直到找到问题的行,这是最有可能的,你做你的错误。如果误差在code系列,将接近破发点,但不是之后,你觉得问题出现,并一步从那里。

1) Step through your code line-by-line (using step filters to ignore code that you did not write) until you find the offending line, this is most likely where you made your mistake. If the error is deep in the code, place a break point close to, but not after, where you feel the issue occurs and step from there.

2)捕获的异常和其他有用的信息有时可以在变量面板找到。

2) Uncaught exceptions and other useful information can sometimes be found in the Variables panel.

3)源未找到只是意味着code对产生的例外是二进制文件就行了。它确实存在,Eclipse的只是不能给你看。

3) "Source Not Found" just means the line of code that generated the exception is in a binary file. It does exist, Eclipse just can't show it to you.

这篇关于Android应用程序,&QUOT;源未发现&QUOT;调试错误 - 尝试下载Android源$ C ​​$ C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 02:20