Android Studio无法在设备上运行应用程序:卡在“等待进程:< project>"
尝试在Samsung Galaxy S4上调试应用程序时,得到以下输出:
When trying to debug my application on my Samsung Galaxy S4, I get this output:
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开发的新手,我缺少什么吗?
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?
仅供参考,我以前能够在仿真器中启动应用程序,但是在尝试了此操作并返回仿真器后,出现了同样的等待进程"消息.
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.
这是我的manifest.xml文件:
Here's my manifest.xml file:
<?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文件:
And here's the my only java file:
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);
}
}
谢谢
UDPATE: 我想我找到了你的问题.在查看清单之后,我发现在其他任何地方都找不到的异常之处是关于Android启动模式的提示.
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.
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: 我认为这是活动未在Android清单中正确注册的问题.我将确保它是启动过程.
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.
只是为了获得更多信息,我将其导出到APK,然后绕过调试器直接在设备上运行.但是,如果执行此测试,请确保关闭可调试功能.如果其他解决方案不起作用,而您只想收集有关该问题的更多信息,那么当然可以这样做.
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.