无法从没有启动选项“默认”或“特定”活动的Android Studio启动应用程序

问题描述 投票:1回答:1

问题在一夜之间发生。一天,一切正常。我关闭了计算机,并在另一天将其重新启动。但是,我没有做任何更改,而是尝试在以前拥有的同一虚拟设备上启动我的App,但由于以下原因,它无法启动:

“运行'app'时出错。找不到默认活动。”

我的清单看起来像这样。我更改了程序包名称和下面的两个活动(请参见下面的评论)。其余部分完全相同。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="MyPackageName">

<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.INTERNET" />

<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=".LoginActivity"
        android:label="@string/title_activity_login"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main"
        android:screenOrientation="portrait">
    </activity>
    <activity android:name=".AnotherActivity" />
    <activity android:name=".OneMoreActivity">
    </activity>

    <meta-data
        android:name="io.fabric.ApiKey"
        android:value="364e8b3f6acfddf9ad32bed8c1503bb762b19cd5" />


</application>

</manifest>

[通常,我的应用只是从登录活动开始。但是,现在没有。我试图“使缓存无效/重新启动”。没有改变。我多次重新启动了AS。仍然没有。

然后我尝试更改启动选项。当前选项设置为“默认活动”。所以我试图将其更改为特定的。即,LoginActivity。但是它告诉我:

“运行'app'时出错。未在AndroidManifest.xml中声明活动'LoginActivity'。”

它告诉我它没有声明,显然是。否则,我将无法从下拉列表中选择它。我也尝试着开始另一个活动。 “主要活动”。还是一无所有。

我到底在做什么错?可能有一种解决方法,可以在虚拟设备上手动获取APK,以便至少可以继续工作?

编辑

我已经尝试删除.gradle-folder。不幸的是,这没有用。我尝试将其推入git并将其再次克隆到另一个文件夹中。那也不起作用。

解决方法

到目前为止,我只能找到一种解决方法:

  • 转到运行/编辑配置...
  • 转到常规/启动选项->启动:无]
  • 像往常一样运行。 Android Studio将构建项目并将应用程序安装到您的设备上,但不会启动它!
  • 在设备上手动启动您的应用程序。
  • 转到运行/将调试器附加到Android进程。
  • 选择您的应用。
  • 显然,这有点麻烦,并且可能会使调试应用程序的启动变得更加困难。因此,我仍在寻找实际的解决方案。

问题在一夜之间发生。一天,一切正常。我关闭了计算机,并在另一天将其重新启动。但是,我没有做任何更改,而是尝试在相同的...上启动我的App ...

android android-studio android-launcher
1个回答
0
投票

[当我尝试寻找另一个突然从哪里冒出来的问题的解决方案时,我已经找到了答案。

Androidstudio不会加载任何预览并将警告放置在我的布局中,因为

© www.soinside.com 2019 - 2024. All rights reserved.