未找到Android工作室默认活动

Анд*_*й Б 6 android android-manifest

在我创建了自己的appplication类之后:

package com.example.bezzabarovaa.myapplication;
import android.app.Application;
import android.content.Context;

/**
 * Created by bezzabarovaa on 04.08.2017.
 */

public class app extends Application {
public static Context context;

@Override public void onCreate() {
    super.onCreate();
    context = getApplicationContext();
}

}
Run Code Online (Sandbox Code Playgroud)

并更改了manifest.xml(将应用程序更改为app类)

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

<app
    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" />
            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
    </activity>
</app>
Run Code Online (Sandbox Code Playgroud)

我收到一条消息错误运行未命名:未找到默认活动

如果我将我的课程改app回applicationmanifest.xml中 - 一切都好.哪里有问题?谢谢.

Mat*_*cco 8

这<app应该是<application您在此处指定自定义应用程序:

<application android:name=".app" ...
Run Code Online (Sandbox Code Playgroud)

查看文档名称部分说:

为应用程序实现的Application子类的完全限定名称.启动应用程序进程时,将在任何应用程序的组件之前实例化此类.子类是可选的; 大多数应用程序不需要一个.在没有子类的情况下,Android使用基本Application类的实例.

完整示例(使用您的代码):

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

<application
    android:name=".app"
    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" />
            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
    </activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)