Answer the question
In order to leave comments, you need to log in
Android VK SDK. Why is the NullPointerException thrown?
There is such a code, but an exception is triggered on the 22nd line, and it is called on the 137th line of the VKSdk.java file from the library
public class Application extends android.app.Application
{
VKAccessTokenTracker tokenTracker = new VKAccessTokenTracker() {
@Override
public void onVKAccessTokenChanged(VKAccessToken oldToken, VKAccessToken newToken) {
if (newToken == null) {
Intent intent = new Intent(Application.this, LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
}
};
@Override
public void onCreate() {
super.onCreate();
tokenTracker.startTracking();
VKSdk.initialize(this); // вот 22-я строка
}
}
E/AndroidRuntime(27724): FATAL EXCEPTION: main
E/AndroidRuntime(27724): Process: ru.redozote.vkfs, PID: 27724
E/AndroidRuntime(27724): java.lang.RuntimeException: Unable to create application ru.redozote.vkfs.Application: java.lang.NullPointerException
E/AndroidRuntime(27724): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4331)
E/AndroidRuntime(27724): at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
E/AndroidRuntime(27724): at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631)
E/AndroidRuntime(27724): at android.app.ActivityThread.handleBindApplication(Native Method)
E/AndroidRuntime(27724): at android.app.ActivityThread.access$1500(ActivityThread.java:135)
E/AndroidRuntime(27724): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
E/AndroidRuntime(27724): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(27724): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime(27724): at android.app.ActivityThread.main(ActivityThread.java:5001)
E/AndroidRuntime(27724): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(27724): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(27724): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
E/AndroidRuntime(27724): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
E/AndroidRuntime(27724): at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
E/AndroidRuntime(27724): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(27724): Caused by: java.lang.NullPointerException
E/AndroidRuntime(27724): at com.vk.sdk.VKSdk.initialize(VKSdk.java:137)
E/AndroidRuntime(27724): at ru.redozote.vkfs.Application.onCreate(Application.java:23)
E/AndroidRuntime(27724): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
E/AndroidRuntime(27724): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4328)
E/AndroidRuntime(27724): ... 14 more
public static void initialize(Context applicationContext) {
if (applicationContext == null) {
throw new NullPointerException("Application context cannot be null");
}
sCurrentAppId = getIntResByName(applicationContext, SDK_APP_ID);
sCurrentApiVersion = getStringResByName(applicationContext, SDK_API_VERSION);
if (sCurrentApiVersion == null) {
sCurrentApiVersion = VKSdkVersion.DEFAULT_API_VERSION;
}
sCurrentLoginState = LoginState.Unknown; // 137-я строка
wakeUpSession(applicationContext);
if (sCurrentAppId == 0) {
throw new RuntimeException("String <integer name=\"com_vk_sdk_AppId\">your_app_id</integer> did not find in your resources.xml");
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question