There is an application class

public class MyApp extends Application { @Override public void onCreate() {...} @Override public void onTerminate() {...} } 

Everything is written in the manifest

  <application android:label="@string/app_name" android:icon="@drawable/ic_launcher" android:name=".MyApp" > 

But here there are devices, where here such a glass goes

 java.lang.RuntimeException: Unable to instantiate application ru.Company.AppName.MyApp: java.lang.ClassNotFoundException: ru.Company.AppName.MyApp at android.app.LoadedApk.makeApplication(LoadedApk.java:501) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4181) at android.app.ActivityThread.access$1300(ActivityThread.java:136) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4802) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:813) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:580) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.ClassNotFoundException: ru.Company.AppName.MyApp at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) at java.lang.ClassLoader.loadClass(ClassLoader.java:501) at java.lang.ClassLoader.loadClass(ClassLoader.java:461) at android.app.Instrumentation.newApplication(Instrumentation.java:967) at android.app.LoadedApk.makeApplication(LoadedApk.java:496) 
  • What is your api? 2.2? 2.3.3? try to change it here =) - Gorets

1 answer 1

As in most cases, the documentation gives all the answers, you just need to read it.

android: name

Implemented for the application. The application is a component.

The subclass is optional; most applications won't need one. In the absence of a subclass, Android uses an instance of the base application class.

PS By the way, I noticed in your successor of Application redefinition of the onTerminate method. You know, according to the documentation ,

Android device

?

  • Are you implying that you need to write the full name of the package? But in the frame, the full name is spelled correctly. - andreich
  • Yes, that is what I am hinting at. Previously, indeed, in android:name allowed to write the class name relative to the root package of the application, but later it was quietly got rid of, scoring on backward compatibility. - falstaf
  • Yes, I know that onTerminate () is not called :) But you can force it through IDE. Well, I hope that this will really solve the problem. - andreich