【发布时间】:2017-05-27 11:47:44
【问题描述】:
我在运行应用程序时遇到了 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
我在 StackOverflow 上尝试了所有解决方案,但没有任何效果。 我想告诉你,每个项目都会发生这种情况,例如如果我创建了一个新项目并且除了单击运行之外没有做任何事情,我也有以下错误
我尝试了以下方法:
- 重新安装 Android Studio
- 更新的 SDK
- 清理项目
- 未选中的即时运行
- 重建项目
- 更改了项目文件夹
- 已删除 .gradle 和 .idea 并重新创建
- 编辑配置 > 安装标志> -r
但没有任何效果...
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>
布局:
<?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>
【问题讨论】:
-
也许是个愚蠢的问题,但您是否尝试过清除应用数据并卸载应用? Instant Run 在应用程序缓存文件夹中保留了一些奇怪的文件,这曾经给我带来了非常奇怪的问题。
-
我的回答可能对stackoverflow.com/a/60468450/4875245有帮助
标签: java android android-studio