应用程序在调用Activity启动程序方法时随机崩溃

时间:2013-07-11 14:43:45

标签: android android-emulator crash

当按下调用跟随侦听器的两个按钮之一时

OnClickListener mSportiveListener = new OnClickListener() {
    public void onClick(View v) {
        String title = getResources().getString(
                R.string.function_sport_i);
        String category="SPORT";
        startFunctionSelector(title, category);
    }
};

OnClickListener mClassicListener = new OnClickListener() {
    public void onClick(View v) {
        String title = getResources().getString(
                R.string.function_classic_i);
        String category="CLASSIC";
        startFunctionSelector(title, category);
    }
};

应用程序崩溃时通常会在行

上发生有关错误的任何详细信息
startActivity(selector);

方法

public void startFunctionSelector(String title, String functionCategory) {
    Intent selector = new Intent(Home.this, FunctionSelector.class);
    selector.putExtra("Title", title);
    selector.putExtra("FunctionCategory", functionCategory);
    try {
        startActivity(selector);
    } catch (RuntimeException e) {
        e.printStackTrace();
    }

}

该错误与FunctionSelector.class无关,因为我提出的任何内容都与行为完全相同(我也尝试过Hello World)

不幸的是,由于一些奇怪的原因Eclipse没有给我任何关于错误的细节只有一个通用的SourceNotFound 与

// Compiled from Handler.java (version 1.5 : 49.0, super bit)
public class android.os.Handler {

  // Method descriptor #11 ()V
  // Stack: 3, Locals: 1
  public Handler();
     0  aload_0 [this]
     1  invokespecial java.lang.Object() [1]
     4  new java.lang.RuntimeException [2]
     7  dup
     8  ldc <String "Stub!"> [3]
    10  invokespecial java.lang.RuntimeException(java.lang.String) [4]
    13  athrow
      Line numbers:
        [pc: 0, line: 8]
      Local variable table:
        [pc: 0, pc: 14] local: this index: 0 type: android.os.Handler

但没有具体说明这个问题。

更多详情

FunctionSelector的onCreate,但是如果我在这个Activity中只留下一个helloWorld,我也说崩溃了

 public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
                    .permitAll().build();
            StrictMode.setThreadPolicy(policy);
            setContentView(R.layout.selector_gui);

            selectorTitle = getIntent().getStringExtra("Title");
            functionCategory = getIntent().getStringExtra("FunctionCategory");

            buttonBack = (ImageButton) findViewById(R.id.btBack);
            buttonBack.setOnClickListener(mBackListener);

            txtTitle = (TextView) findViewById(R.id.txtTitle);
            txtTitle.setText(selectorTitle);

            list = (ListView) findViewById(R.id.listaFunzioni);

        }

如果我尝试使用模拟器并进入AllMessage(每个App未经过滤),我可以看到

07-11 14:25:51.139: E/ActivityThread(1550): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@b2f46948 that was originally bound here
07-11 14:25:51.139: E/ActivityThread(1550): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@b2f46948 that was originally bound here
07-11 14:25:51.139: E/ActivityThread(1550):     at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.app.ContextImpl.bindService(ContextImpl.java:1418)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.app.ContextImpl.bindService(ContextImpl.java:1407)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.service.AccountServiceProxy.getDeviceId(AccountServiceProxy.java:116)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.exchange.ExchangeService.getDeviceId(ExchangeService.java:1249)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
07-11 14:25:51.139: E/ActivityThread(1550):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
07-11 14:25:51.139: E/ActivityThread(1550):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
07-11 14:25:51.139: E/ActivityThread(1550):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
07-11 14:25:51.139: E/ActivityThread(1550):     at java.lang.Thread.run(Thread.java:856)
07-11 14:25:51.139: E/StrictMode(1550): null
07-11 14:25:51.139: E/StrictMode(1550): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@b2f46948 that was originally bound here
07-11 14:25:51.139: E/StrictMode(1550):     at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
07-11 14:25:51.139: E/StrictMode(1550):     at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
07-11 14:25:51.139: E/StrictMode(1550):     at android.app.ContextImpl.bindService(ContextImpl.java:1418)
07-11 14:25:51.139: E/StrictMode(1550):     at android.app.ContextImpl.bindService(ContextImpl.java:1407)
07-11 14:25:51.139: E/StrictMode(1550):     at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.service.AccountServiceProxy.getDeviceId(AccountServiceProxy.java:116)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.exchange.ExchangeService.getDeviceId(ExchangeService.java:1249)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
07-11 14:25:51.139: E/StrictMode(1550):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
07-11 14:25:51.139: E/StrictMode(1550):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
07-11 14:25:51.139: E/StrictMode(1550):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
07-11 14:25:51.139: E/StrictMode(1550):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
07-11 14:25:51.139: E/StrictMode(1550):     at java.lang.Thread.run(Thread.java:856)
07-11 14:25:51.139: W/ActivityManager(1201): Unbind failed: could not find connection for android.os.BinderProxy@b3149200
07-11 14:25:51.139: E/ActivityThread(1550): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@b2f7f7c0 that was originally bound here
07-11 14:25:51.139: E/ActivityThread(1550): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@b2f7f7c0 that was originally bound here
07-11 14:25:51.139: E/ActivityThread(1550):     at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.app.ContextImpl.bindService(ContextImpl.java:1418)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.app.ContextImpl.bindService(ContextImpl.java:1407)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
07-11 14:25:51.139: E/ActivityThread(1550):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
07-11 14:25:51.139: E/ActivityThread(1550):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
07-11 14:25:51.139: E/ActivityThread(1550):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
07-11 14:25:51.139: E/ActivityThread(1550):     at java.lang.Thread.run(Thread.java:856)
07-11 14:25:51.139: E/StrictMode(1550): null
07-11 14:25:51.139: E/StrictMode(1550): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@b2f7f7c0 that was originally bound here
07-11 14:25:51.139: E/StrictMode(1550):     at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
07-11 14:25:51.139: E/StrictMode(1550):     at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
07-11 14:25:51.139: E/StrictMode(1550):     at android.app.ContextImpl.bindService(ContextImpl.java:1418)
07-11 14:25:51.139: E/StrictMode(1550):     at android.app.ContextImpl.bindService(ContextImpl.java:1407)
07-11 14:25:51.139: E/StrictMode(1550):     at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
07-11 14:25:51.139: E/StrictMode(1550):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
07-11 14:25:51.139: E/StrictMode(1550):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
07-11 14:25:51.139: E/StrictMode(1550):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
07-11 14:25:51.139: E/StrictMode(1550):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
07-11 14:25:51.139: E/StrictMode(1550):     at java.lang.Thread.run(Thread.java:856)

1 个答案:

答案 0 :(得分:1)

尝试以下步骤

1)尝试在初始化Intent时包含活动的完整路径,例如

Intent selector = new Intent(Home.this, com.yourpackagename.YourActivity.class); 

清单

中的活动声明中的相同内容

2)验证所有资源是否正确链接,并且清单和gui的xml文件中没有错误

3)假设您已在清单中声明了Activity,并且on create中的资源已正确初始化。可能在Eclipse缓存中出现问题删除工作区中的.metadata文件夹并尝试重新导入项目。