java 运行应用程序时 Android 应用程序错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35330756/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 00:00:46  来源:igfitidea点击:

Android Application Error while running the Application

javaandroid

提问by HariPriya

Whenever I try running my application - this window in the screenshot is popping up in my screen. Stating that default activity is not found because of this I am not able to deploy my app:

每当我尝试运行我的应用程序时 - 屏幕截图中的这个窗口就会在我的屏幕上弹出。声明未找到默认活动,因此我无法部署我的应用程序:

enter image description here

在此处输入图片说明

Manifest file of my code

我的代码的清单文件

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android3.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MainActivity2"
            android:label="@string/app_name" >

        </activity>
        <activity
            android:name=".Sigin"
            android:label="@string/app_name" >
        </activity>
    </application>

</manifest>

This is what the window which I am getting while clicking the Run-> Edit Congiguration:

这是我在单击运行-> 编辑配置时得到的窗口:

enter image description here

在此处输入图片说明

Gradle file of my code:

我的代码的 Gradle 文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "com.example.mcs.oodoeg"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

        packagingOptions {
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/DEPENDENCIES'
        }

}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile files('libs/xmlrpc-client-3.1.3.jar')
    compile files('libs/gson-2.2.2.jar')
}

回答by htafoya

I had a similar problem, the issue was the device.

我有一个类似的问题,问题是设备。

When you uninstalledthe app (to install it again after running project), instead of actually uninstalling it, it deactivatedit.

当您卸载该应用程序(在运行项目后再次安装它)时,它并没有实际卸载它,而是将其停用

That means, the app was still installed but it was blocked by OS.

这意味着,该应用程序仍被安装,但被操作系统阻止。

So I couldn't run the project, and no more information was given. (Activity launcher not foundwas the only message)

所以我无法运行该项目,也没有提供更多信息。(Activity launcher not found是唯一的消息)

Effectively deleting the app (going through device settings) solved the issue.

有效地删除应用程序(通过设备设置)解决了这个问题。

回答by user3568896

The error occurs when you delete the app when you are still testing it on your phone. The app shows as deleted because it disappears from your launcher, To fully delete the app follow the steps below.

当您仍在手机上测试该应用程序时删除该应用程序时会出现该错误。该应用程序显示为已删除,因为它从您的启动器中消失了,要完全删除该应用程序,请按照以下步骤操作。

It worked perfectly after clicking on settings => Apps & notification => App info => find the name of the app => on top right corner click on the three dots => Uninstall for all users.

单击设置 => 应用程序和通知 => 应用程序信息 => 找到应用程序的名称 => 在右上角单击三个点 => 为所有用户卸载后,它运行良好。

回答by Vishal Thakkar

try this if you upgrade android studio IDEA

如果您升级 android studio IDEA,请尝试此操作

File -> Invalidate Caches / Restart...ref. link=> Default Activity not found in Android Studio

File -> Invalidate Caches / Restart ...ref. 链接=> Android Studio 中未找到默认活动

回答by Shoaib Mushtaq

It's working perfectly for me after clicking on settings => Apps & notification => App info => find the name of the app => on top right corner click on the three dots => Uninstall for all users.

单击设置 => 应用程序和通知 => 应用程序信息 => 找到应用程序的名称 => 在右上角单击三个点 => 为所有用户卸载后,它对我来说非常有用。

回答by kyrie

it's studio setting problem. please click app => Edit Configrations => Deploy. select Default apk and apply.after click ok

是工作室设置问题。请单击应用程序 => 编辑配置 => 部署。选择默认 apk 并应用。点击确定后

回答by Sokdara Cheng

I faced the same problem.

我遇到了同样的问题。

Solved by going to the other user account on my phone and uninstall the app. Seems this problem is caused by first installing this app on "A" user account then we uninstall this app in "B" account. So when we try to run our app again in "B" account the old app is still exist in "A" account.

通过转到我手机上的其他用户帐户并卸载该应用程序来解决。似乎这个问题是由于首先在“A”用户帐户上安装此应用程序然后我们在“B”帐户中卸载此应用程序引起的。因此,当我们尝试在“B”帐户中再次运行我们的应用程序时,旧应用程序仍然存在于“A”帐户中。

回答by Ahmed Al-hajri

I solved the issue by uninstalling the app on my device for other user.

我通过为其他用户卸载我设备上的应用程序解决了这个问题。

  • when you run the app on your device installation will happen for every user on your device

  • uninstalling the app only uninstall it for the current user you are using on the device

  • 当您在您的设备上运行该应用程序时,您设备上的每个用户都会安装

  • 卸载应用程序仅为您在设备上使用的当前用户卸载它

回答by Learning Always

  1. Restart your IDE.
  2. Clean your project, goto Build > Clean Project.
  3. Run again and see if your error is resolved.
  1. 重新启动您的 IDE。
  2. 清理您的项目,转到Build > Clean Project
  3. 再次运行并查看您的错误是否已解决。

Go to Run > Edit configurationand check this detail. Check this image

转到运行 > 编辑配置并检查此详细信息。 检查这张图片

回答by Andrea Leganza

In my case the problem was due to the emulator which started in "safe mode" making impossible to run on the device, changing emulator device worked.

在我的情况下,问题是由于在“安全模式”下启动的模拟器无法在设备上运行,更改模拟器设备工作。

回答by sana ebadi

just find the application on your phone and Uninstall it.

只需在您的手机上找到该应用程序并将其卸载即可。

and Clean the app and run it again.

并清理应用程序并再次运行它。