Attempt to invoke virtual method 'java.io.File com.parse.ParsePlugins.getFilesDir()' on a null object reference
Fanom2813 opened this issue · comments
New Issue Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
- I can reproduce the issue with the latest version of Parse Server and the Parse Flutter SDK.
Issue Description
Attempt to invoke virtual method 'java.io.File com.parse.ParsePlugins.getFilesDir()' on a null object reference after following steps for push notification
Actual Outcome
it fails the first time the apk getting install , the second time i run debug , the app opens perfectly
Expected Outcome
Environment
Parse Flutter SDK
- SDK version:
7.0.0 - Flutter version:
3.16.3 - Dart version:
3.2.3 - Operating system version:
macos 14.2 (23C64)
Server
- Parse Server version:
6.4.0
Logs
E/AndroidRuntime( 5729): java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File com.parse.ParsePlugins.getFilesDir()' on a null object reference
E/AndroidRuntime( 5729): at com.parse.ParseCorePlugins.getCurrentInstallationController(ParseCorePlugins.java:280)
E/AndroidRuntime( 5729): at com.parse.ParseInstallation.getCurrentInstallationController(ParseInstallation.java:63)
E/AndroidRuntime( 5729): at com.parse.ParseInstallation.getCurrentInstallation(ParseInstallation.java:68)
E/AndroidRuntime( 5729): at com.parse.fcm.ParseFCM.register(ParseFCM.java:29)
E/AndroidRuntime( 5729): at com.parse.fcm.ParseFirebaseMessagingService.onNewToken(ParseFirebaseMessagingService.java:16)
E/AndroidRuntime( 5729): at com.google.firebase.messaging.FirebaseMessagingService.handleIntent(FirebaseMessagingService.java:165)
E/AndroidRuntime( 5729): at com.google.firebase.messaging.EnhancedIntentService.lambda$processIntent$0$com-google-firebase-messaging-EnhancedIntentService(EnhancedIntentService.java:82)
E/AndroidRuntime( 5729): at com.google.firebase.messaging.EnhancedIntentService$$ExternalSyntheticLambda0.run(Unknown Source:6)
E/AndroidRuntime( 5729): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
E/AndroidRuntime( 5729): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
E/AndroidRuntime( 5729): at com.google.android.gms.common.util.concurrent.zza.run(com.google.android.gms:play-services-basement@@18.1.0:2)
E/AndroidRuntime( 5729): at java.lang.Thread.run(Thread.java:1012)
Thanks for opening this issue!
- 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.
Please, if possible, provide more explanations step by step
In my manifest
<!--region Parse SDK-->
<service android:name="com.parse.fcm.ParseFirebaseInstanceIdService" android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<service android:name="com.parse.fcm.ParseFirebaseMessagingService"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<receiver
android:name="com.parse.ParsePushBroadcastReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<!--endregion-->
I initialize like this
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
await Parse().initialize(
"key",
"url",
debug: true,
coreStore: await CoreStoreSharedPreferences.getInstance(),
);
ParsePush.instance.initialize(FirebaseMessaging.instance, parseNotification:
ParseNotification(onShowNotification: (message) async {
print(message);
}));
FirebaseMessaging.onMessage
.listen((message) => ParsePush.instance.onMessage(message));
FirebaseMessaging.onBackgroundMessage(onBackgroundMessage);
currentUser = await ParseUser.currentUser();
if (currentUser != null) {
await initInstallation();
}
Future<void> initInstallation() async {
final ParseInstallation installation =
await ParseInstallation.currentInstallation();
final ParseResponse response = await installation.create();
print(response);
}
when i do a fresh install i get java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File com.parse.ParsePlugins.getFilesDir()' on a null object reference however when i run the app a second time the error doesnt appear
i dont know it is a miss configration but install object is not saved in the database yet deviceToken is set and the object is well populated here is the log
I/flutter (27336): API Request (_Installation : ParseApiRQ.save) :
I/flutter (27336): Uri: http://192.168.8.101:1337/parse/installations/Ipgt3ngJJt
I/flutter (27336): Body: {"deviceToken":"token","pushType":"gcm","deviceType":"android","localeIdentifier":"en_US","timeZone":"Indian/Mayotte","appName":"app","appVersion":"0","appIdentifier":"id","parseVersion":"5.1.3"}
I/flutter (27336): ----
server response :
{"code":101,"stack":"Error: Object not found for update.\n api/node_modules/parse-server/lib/RestWrite.js:1027:15\n at processTicksAndRejections (node:internal/process/task_queues:96:5)"}
In my manifest
<!--region Parse SDK--> <service android:name="com.parse.fcm.ParseFirebaseInstanceIdService" android:exported="true"> <intent-filter> <action android:name="com.google.firebase.INSTANCE_ID_EVENT" /> </intent-filter> </service> <service android:name="com.parse.fcm.ParseFirebaseMessagingService" android:exported="true"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT"/> </intent-filter> </service> <receiver android:name="com.parse.ParsePushBroadcastReceiver" android:exported="false"> <intent-filter> <action android:name="com.parse.push.intent.RECEIVE" /> <action android:name="com.parse.push.intent.DELETE" /> <action android:name="com.parse.push.intent.OPEN" /> </intent-filter> </receiver> <!--endregion-->I initialize like this
await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform, ); await Parse().initialize( "key", "url", debug: true, coreStore: await CoreStoreSharedPreferences.getInstance(), ); ParsePush.instance.initialize(FirebaseMessaging.instance, parseNotification: ParseNotification(onShowNotification: (message) async { print(message); })); FirebaseMessaging.onMessage .listen((message) => ParsePush.instance.onMessage(message)); FirebaseMessaging.onBackgroundMessage(onBackgroundMessage); currentUser = await ParseUser.currentUser(); if (currentUser != null) { await initInstallation(); }Future<void> initInstallation() async { final ParseInstallation installation = await ParseInstallation.currentInstallation(); final ParseResponse response = await installation.create(); print(response); }when i do a fresh install i get
java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File com.parse.ParsePlugins.getFilesDir()' on a null object referencehowever when i run the app a second time the error doesnt appeari dont know it is a miss configration but install object is not saved in the database yet
deviceTokenis set and the object is well populated here is the logI/flutter (27336): API Request (_Installation : ParseApiRQ.save) : I/flutter (27336): Uri: http://192.168.8.101:1337/parse/installations/Ipgt3ngJJt I/flutter (27336): Body: {"deviceToken":"token","pushType":"gcm","deviceType":"android","localeIdentifier":"en_US","timeZone":"Indian/Mayotte","appName":"app","appVersion":"0","appIdentifier":"id","parseVersion":"5.1.3"} I/flutter (27336): ----
server response :
{"code":101,"stack":"Error: Object not found for update.\n api/node_modules/parse-server/lib/RestWrite.js:1027:15\n at processTicksAndRejections (node:internal/process/task_queues:96:5)"}
These items you added in the manifest are for Parse Android, these items are not needed for Parse Flutter, please check the push notifications document again.
after removing the manifest, the app doesnt crash on fresh install , but initinstallation only works the first time when i reload the app i get
at least one ID field (deviceToken, installationId) must be specified in this operation {"code":135,"stack":"Error: at least one ID field (deviceToken, installationId) must be specified in this operation\n at RestWrite.handleInstallation (node_modules/parse-server/lib/RestWrite.js:954:11)\n at node_modules/parse-server/lib/RestWrite.js:105:17\n at runMicrotasks ()\n at processTicksAndRejections (node:internal/process/task_queues:96:5)"}
thanks for your help
after removing the manifest, the app doesnt crash on fresh install , but
initinstallationonly works the first time when i reload the app i getat least one ID field (deviceToken, installationId) must be specified in this operation {"code":135,"stack":"Error: at least one ID field (deviceToken, installationId) must be specified in this operation\n at RestWrite.handleInstallation (node_modules/parse-server/lib/RestWrite.js:954:11)\n at node_modules/parse-server/lib/RestWrite.js:105:17\n at runMicrotasks ()\n at processTicksAndRejections (node:internal/process/task_queues:96:5)"}
thanks for your help
Is the current user logged in?
after removing the manifest, the app doesnt crash on fresh install , but
initinstallationonly works the first time when i reload the app i get
at least one ID field (deviceToken, installationId) must be specified in this operation {"code":135,"stack":"Error: at least one ID field (deviceToken, installationId) must be specified in this operation\n at RestWrite.handleInstallation (node_modules/parse-server/lib/RestWrite.js:954:11)\n at node_modules/parse-server/lib/RestWrite.js:105:17\n at runMicrotasks ()\n at processTicksAndRejections (node:internal/process/task_queues:96:5)"}
thanks for your helpIs the current user logged in?
when user is not logged in initinstallation completes normally , when i reload with user logged in it brings the above message