H
H
Horoko2015-08-25 13:02:04
Java
Horoko, 2015-08-25 13:02:04

Why does Android VK SDK crash VKSdk.initialize(this) when called?

Subject. wrote the application for 3 days. On the 4th, turning on the studio and running the project , I crashed
Caused by: java.lang.RuntimeException: VKSdk.initialize(Context) must be call from Application#onCreate().
The code where I call the method:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        VKSdk.initialize(this);
    }

I created a new project in the studio, and I needed it on a clean, unplowed field, launched the method, and it also turned off. I created a new application in Vk developer, everything is the same. Naturally, the fingerprint names of the packages and MainActivity are correct. I even removed all the applications that I had there, and created one new one, filled it in, and crashed again. Tested on 2 devices.
08-25 12:56:33.588  12482-12482/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vktab/com.vktab.MainActivity}: java.lang.RuntimeException: VKSdk.initialize(Context) must be call from Application#onCreate()
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2263)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2313)
            at android.app.ActivityThread.access$600(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:152)
            at android.app.ActivityThread.main(ActivityThread.java:5132)
            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:793)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.RuntimeException: VKSdk.initialize(Context) must be call from Application#onCreate()
            at com.vk.sdk.VKSdk.initialize(VKSdk.java:136)
            at com.vktab.MainActivity.onCreate(MainActivity.java:57)
            at android.app.Activity.performCreate(Activity.java:5104)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2227)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2313)
            at android.app.ActivityThread.access$600(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:152)
            at android.app.ActivityThread.main(ActivityThread.java:5132)
            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:793)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
            at dalvik.system.NativeStart.main(Native Method)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question