-1

首先,我已经阅读了与我类似的问题,并尝试了所有推荐的解决方案。这些解决方案包括:

  1. 使缓存无效并重新启动
  2. 与 gradle 同步
  3. 重启 Android Studio
  4. 清理和构建
  5. 在启动器部分将配置更改为“无”
  6. 将清单文件上的 android:name 更改为完整的包名(例如:com.example.acer.alertbox.ActivityName)

这些解决方案似乎都不起作用,并且我不断收到错误消息说“未找到默认活动”。我已经尝试解决这个问题一个星期了,所以我希望有人能给我一个新的解决方案,除了我上面提到的 6 个。下面是我的 android 清单代码,对我来说似乎很好,并且我已经检查过多次。

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

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>

    <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"
            tools:ignore="GoogleAppIndexingWarning">

       <activity android:name=".MainActivity">
           <intent-filter>
               <action android:name="android.intent.action.MAIN"/>
               <category android:name="android.intent.category.LAUNCHER"/>
           </intent-filter>
       </activity>

        <activity
                android:name=".LoginActivity"
                android:parentActivityName=".MainActivity">
        </activity>
        <activity
                android:name=".RegisterActivity"
                android:parentActivityName=".MainActivity">
        </activity>
        <activity
                android:name=".SendActivity"
                android:parentActivityName=".MainActivity">
        </activity>
        <activity
                android:name=".Profile"
                android:parentActivityName=".MainActivity">
        </activity>
        <activity android:name=".NotificationActivity">
                  <intent-filter>
                      <action android:name="com.example.acer.alertbox.TARGETNOTIFICATION">
                      </action>
                  </intent-filter>
        </activity>

        <service
            android:name=".FirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT">
                </action>
            </intent-filter>
        </service>

        <meta-data
                android:name="com.google.firebase.messaging.default_notification_channel_id"
                android:value="@string/default_notification_channel_id" />


    </application>

</manifest>

更新:我已经卸载并重新安装了Android Studio,问题解决了,但又来了一个。当我单击“运行”按钮时,它没有做任何事情,并且我在右下角收到警告说内部 IDE 错误:无法找到 adb。我已经下载了 adb 文件并将其定位在这个目录 C:/Acer/Users/Local/Sdk 但它仍然没有改变任何东西。我也重新启动,同步项目 gradle 文件等,但没有任何效果!!请有人帮助我。以下是我从内部错误报告中得到的信息:

Unable to locate adb
java.lang.IllegalArgumentException: Unable to locate adb
    at com.android.tools.idea.run.editor.DeployTargetPickerDialog.<init>(DeployTargetPickerDialog.java:131)
    at com.android.tools.idea.run.editor.ShowChooserTargetProvider.showPrompt(ShowChooserTargetProvider.java:113)
    at com.android.tools.idea.run.AndroidRunConfigurationBase.getDeployTarget(AndroidRunConfigurationBase.java:605)
    at com.android.tools.idea.run.AndroidRunConfigurationBase.getState(AndroidRunConfigurationBase.java:287)
    at com.intellij.execution.runners.ExecutionEnvironment.getState(ExecutionEnvironment.java:158)
    at com.intellij.execution.runners.BaseProgramRunner.execute(BaseProgramRunner.java:55)
    at com.intellij.execution.runners.BaseProgramRunner.execute(BaseProgramRunner.java:50)
    at com.intellij.execution.ProgramRunnerUtil.executeConfigurationAsync(ProgramRunnerUtil.java:97)
    at com.intellij.execution.ProgramRunnerUtil.executeConfiguration(ProgramRunnerUtil.java:44)
    at com.intellij.execution.impl.ExecutionManagerImpl.start(ExecutionManagerImpl.java:111)
    at com.intellij.execution.impl.ExecutionManagerImpl.access$300(ExecutionManagerImpl.java:59)
    at com.intellij.execution.impl.ExecutionManagerImpl$3.run(ExecutionManagerImpl.java:439)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:231)
    at com.intellij.util.Alarm$Request.runSafely(Alarm.java:405)
    at com.intellij.util.Alarm$Request.access$700(Alarm.java:330)
    at com.intellij.util.Alarm$Request$1.run(Alarm.java:371)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:315)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.doRun(LaterInvocator.java:447)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:431)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:415)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
    at java.awt.EventQueue.access$500(EventQueue.java:98)
    at java.awt.EventQueue$3.run(EventQueue.java:715)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:822)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:763)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:423)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

最新更新:通过从 Avast 防病毒软件恢复 adb.exe 解决了问题。

4

1 回答 1

1

以下是您可以检查的一些可能原因

  1. 是否有任何活动被删除但仍存在于清单中
  2. 在意图过滤器中添加这个标签并检查它是否有效

    <category android:name="android.intent.category.DEFAULT"/>

  3. 如果配置正确,请检查配置选项卡以获取更多详细信息,请点击链接 错误:未找到默认活动

于 2018-12-23T08:09:10.227 回答