我创建了自己的应用程序类之后:
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();
}
}
我已经更改了manifest.xml文件(将application更改为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>
我收到了一条消息,错误信息为“运行未命名的应用程序时出错:找不到默认活动”。
如果我在manifest.xml文件中将我的类app
改回application
,一切都正常了。
问题出在哪里呢?
谢谢。
<application android:name=".app">
并遵循 Java 准则,其中类名应为 CamelCase(在你的情况下不是 app,而是 App)。 - shimatai