[英]Android Studio: Session 'app': Error Launching activity
I have a problem with Android Studio when run the App, I have following error: 运行应用程序时,Android Studio出现问题,出现以下错误:
$ adb shell am start -n "com.ta94.xahmad.theerror/com.ta94.xahmad.theerror.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while executing: am start -n "com.ta94.xahmad.theerror/com.ta94.xahmad.theerror.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.ta94.xahmad.theerror/.MainActivity }
Error while Launching activity
I tried every solutions on StackOverflow but nothing works. 我在StackOverflow上尝试了所有解决方案,但没有任何效果。 I would like to tell you that this happens to every project, for example if I created a new project and didn't do anything but click Run, I also had the following error
我想告诉您,这在每个项目中都会发生,例如,如果我创建了一个新项目并且除了单击“运行”之外什么也不做,那么我也遇到以下错误
I tried the following: 我尝试了以下方法:
But nothing works ... 但是什么都行不通...
Manifest.xml: 的Manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ta94.xahmad.theerror">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity"
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>
</manifest>
Layout: 布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ta94.xahmad.theerror.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
I has the same problem and none of recommended methods worked. 我有同样的问题,没有推荐的方法有效。 Since at least in my case application still launched on emulator/phone, so I figured, that debugging still possible if you use Run->Attach debugger to android process.
由于至少在我的情况下,应用程序仍在模拟器/电话上启动,因此我认为,如果您使用Run-> Attach调试器对Android进程进行调试,则仍然可以进行调试。 The problem is that it was hard to debug startup errors.
问题是很难调试启动错误。 In that case the following method works:
在这种情况下,可以使用以下方法:
That's a workaround, but worked for me. 这是一种解决方法,但对我有用。 Hope that will help.
希望对您有所帮助。
我通过手机调试时遇到了类似的问题...我关注了帖子的数量,但对我没有任何帮助...然后,我手动从Mobile手动卸载了先前安装的应用程序...然后一切正常预期!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.