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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24043149/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 07:45:01  来源:igfitidea点击:

Android Studio can't run application on device: stuck on "Waiting for process: <project>"

androiddebuggingandroid-4.4-kitkat

提问by awebberley

When trying to debug my application on my Samsung Galaxy S4, I get this output:

尝试在我的 Samsung 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

It just stays on the "waiting for process" message without running the application. I'm new to android development, is there something I'm missing?

它只是停留在“等待进程”消息上,而不运行应用程序。我是 android 开发的新手,有什么我遗漏的吗?

FYI, I was able to launch the application in an emulator before, but after I tried this and went back to the emulator, the same "waiting for process" message appeared.

仅供参考,我之前能够在模拟器中启动该应用程序,但是在我尝试此操作并返回模拟器后,出现了相同的“等待进程”消息。

Here's my manifest.xml file:

这是我的 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>

And here's the my only java file:

这是我唯一的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);
    }

}

Thanks

谢谢

采纳答案by AeroVTP

UDPATE: I think I found your problem. After looking at the Manifest, the one anomaly I found that I have not found anywhere else is the line about the Android launchmode.

UDPATE:我想我发现了你的问题。查看Manifest后,我发现我在其他任何地方都没有发现的异常是关于Android启动模式的那一行。

    android:launchMode="standard"

This seems to be related to the problem and is the first glaring issue that I see with this. Remove it, if it works, feel happy, accept the answer :). Make sure you rebuild the project to ensure that the changes are incorporated.

这似乎与问题有关,并且是我看到的第一个明显问题。删除它,如果它有效,感到高兴,接受答案:)。确保重建项目以确保包含更改。

OLD: I think that this is a problem with the Activity not being registered correctly in the Android Manifest. I would make sure that it is the launch process.

OLD:我认为这是 Activity 未在 Android Manifest 中正确注册的问题。我会确保这是启动过程。

Just to get more information, I would export it to an APK and then run it directly on the device, bypassing the debugger. If you do this test though, make sure you turn debuggable off. Of course do this if the other solution doesn't work and you just want to collect more information about the problem.

为了获得更多信息,我会将其导出到 APK,然后直接在设备上运行,绕过调试器。但是,如果您进行此测试,请确保关闭可调试功能。当然,如果其他解决方案不起作用并且您只想收集有关该问题的更多信息,请执行此操作。

回答by Array

"File" --> "Invalidate Caches / Restart" worked for me like a charm.

“文件”-->“使缓存无效/重新启动”对我来说就像一个魅力。

回答by Bill Myers

I had the same error after upgrading to a new version of the SDK. After updating my build.gradle from 'com.android.tools.build:gradle:1.0.0-rc2' to 'com.android.tools.build:gradle:1.0.0' and invalidating caches/restart, it's working again.

升级到新版本的 SDK 后,我遇到了同样的错误。在将我的 build.gradle 从 'com.android.tools.build:gradle:1.0.0-rc2' 更新为 'com.android.tools.build:gradle:1.0.0' 并使缓存/重启无效后,它又开始工作了。

回答by mohghaderi

In Android Studio, Run->Edit Configuration choose Launch default Activity.

在 Android Studio 中,Run->Edit Configuration 选择 Launch default Activity。

Otherwise, it doesn't even bother to start the application.

否则,它甚至不会费心启动应用程序。

回答by Aashi

In case , you are importing the project from some folder and android studio shows - " Waiting for process", then this did work for me. I copied the project to C:\Users[your account]\AndroidStudioProjects (this path might be different for different users), and then imported the project from there.

如果您从某个文件夹导入项目并且 android studio 显示 -“等待进程”,那么这对我有用。我将项目复制到 C:\Users[your account]\AndroidStudioProjects(不同用户的路径可能不同),然后从那里导入项目。

Before doing this, I tried everything like , kill-start server, plugging-unplugging ,reinstalling android, USB tethering mode on in android device etc. etc. , but none of them worked for me.

在执行此操作之前,我尝试了诸如终止启动服务器、插入拔出、重新安装 android、在 android 设备中打开 USB 网络共享模式等所有内容,但没有一个对我有用。