Android Studio无法在设备上运行应用程序:卡在“等待进程:<project>”上。

12

在尝试调试我的应用程序时,在我的三星Galaxy S4上,我得到了以下输出:

Waiting for device.
Target device: samsung-samsung_sgh_i337-8c8aa2c7
Uploading file
    local path: C:\Users\awebberley\AndroidStudioProjects\Contacts\app\build\apk\app-debug-unaligned.apk
    remote path: /data/local/tmp/org.intracode.contacts
Installing org.intracode.contacts
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/org.intracode.contacts"
pkg:/data/local/tmp/org.intracode.contacts
Success


Waiting for process: org.intracode.contacts

应用程序一直停留在“等待进程”消息,没有运行应用程序。 我是Android开发的新手,我错过了什么吗?

顺便说一下,在此之前我能够在模拟器中启动该应用程序,但是在尝试后并返回到模拟器后,出现了相同的“等待进程”消息。

这是我的manifest.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<application
    android:debuggable="true"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="org.intracode.contacts.MainActivity"
        android:launchMode="standard"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

这是我的唯一 Java 文件:

package org.intracode.contacts;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TabHost;
import android.widget.Toast;


public class MainActivity extends ActionBarActivity {

    EditText nameTxt, phoneTxt, emailTxt, addressTxt;

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

        nameTxt = (EditText) findViewById(R.id.txtName);
        phoneTxt = (EditText) findViewById(R.id.txtPhone);
        emailTxt = (EditText) findViewById(R.id.txtEmail);
        addressTxt = (EditText) findViewById(R.id.txtAddress);
        TabHost tabHost = (TabHost) findViewById(R.id.tabHost);

        tabHost.setup();

        TabHost.TabSpec tabSpec = tabHost.newTabSpec("Creator");
        tabSpec.setContent(R.id.creator);
        tabSpec.setIndicator("Creator");
        tabHost.addTab(tabSpec);

        tabSpec = tabHost.newTabSpec("List");
        tabSpec.setContent(R.id.tabContactList);
        tabSpec.setIndicator("List");
        tabHost.addTab(tabSpec);

        final Button addBtn = (Button) findViewById(R.id.btnCreate);
        addBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(getApplicationContext(), "Your Contact has been created!", Toast.LENGTH_SHORT).show();
            }
        });

        nameTxt.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                addBtn.setEnabled(!nameTxt.getText().toString().trim().isEmpty());

            }

                @Override
                public void afterTextChanged(Editable editable) {

            }
        });
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

}

谢谢


看起来它正在等待您的活动启动,您在清单文件中定义了一个“可启动”的活动,并设置了Android Studio启动吗? - Mgamerz
@Mgamerz 我只有一个服务,而且出现了这个消息... - powder366
5个回答

9
"

"文件" --> "无效缓存 / 重启" 对我起到了不错的作用。

"

6

更新: 我想我找到了你的问题所在。在查看清单文件后,我发现一个异常,即关于Android启动模式的那一行。

    android:launchMode="standard"

这似乎与问题有关,也是我看到的第一个明显的问题。如果它能够解决问题,那就很好了,请接受答案并感到高兴:)。确保重新构建项目以确保更改被纳入。

旧版: 我认为这是Activity没有在Android清单中正确注册的问题。我会确保它是启动进程。

为了获得更多信息,我将其导出为APK,然后直接在设备上运行它,绕过调试器。如果您进行此测试,请确保关闭debuggable。当然,如果其他解决方案无法解决问题,您可以这样做,只是想收集有关问题的更多信息。


我刚刚发布了我的清单文件,看起来正确吗?还是问题出在其他地方? - awebberley
很不幸,去除那行代码似乎没有改变任何东西。我已经发布了我的Java文件进行分析,谢谢。 - awebberley
其实我不确定我改了什么,但我刚刚重新构建了项目,现在它运行得很好。感谢您的意见! - awebberley
重建项目可以将清单更改合并,因此这实际上是问题所在。 - AeroVTP

4
在Android Studio中,选择Run-> Edit Configuration,然后选择Launch default Activity。
否则,它甚至不会开始运行应用程序。

将启动选项指定为“默认活动”不会解决通过AS部署的应用程序坚持以调试附加方式启动的问题。 - dubmojo

4

在升级SDK版本后,我遇到了同样的错误。 我将我的 build.gradle 文件从 'com.android.tools.build:gradle:1.0.0-rc2' 更新到 'com.android.tools.build:gradle:1.0.0',然后进行了无效缓存重启,现在它又可以正常运行了。


2
我已经在这上面工作了24小时,而这个技巧让它成功了。谢谢伙计! - varun bhardwaj

0

如果您从某个文件夹导入项目,而Android Studio显示“等待进程”,那么这对我有用。我将项目复制到C:\ Users [您的帐户] \ AndroidStudioProjects(此路径可能因用户而异),然后从那里导入项目。

在执行此操作之前,我尝试了所有方法,如杀死-启动服务器,插拔,重新安装Android,打开Android设备上的USB网络共享模式等等,但都没有对我起作用。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接