awesome-cordova-plugins
awesome-cordova-plugins copied to clipboard
Photo Library plugin error - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.json.JSONObject.toString()' on a null object reference
I'm submitting a ... (check one with "x") [x] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://ionicworldwide.herokuapp.com/
Current behavior:
Expected behavior:
Steps to reproduce:
Related code:
try {
this.photoLibrary.requestAuthorization({
read: true,
write: true
}).then(() => {
var album = "XXXX";
if (filePath != null) {
this.photoLibrary.saveImage(filePath, album, {
quality: 1
}).then((savingResp) => {
console.log(`savingResp `, savingResp);
}).catch((savingErr) => {
console.log(`savingErr `, savingErr);
});
}
}).catch((er) => {
console.log(er);
})
} catch (error) {
console.log(error);
}
Other information:
Ionic info: (run ionic info
from a terminal/cmd prompt and paste output below):
[WARN] Error loading @capacitor/ios package.json: Error: Cannot find module '@capacitor/ios/package'
Require stack:
- /usr/local/lib/node_modules/@ionic/cli/lib/project/index.js
- /usr/local/lib/node_modules/@ionic/cli/lib/index.js
- /usr/local/lib/node_modules/@ionic/cli/index.js
- /usr/local/lib/node_modules/@ionic/cli/bin/ionic
Ionic:
Ionic CLI : 6.18.1 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.8.5
@angular-devkit/build-angular : 12.1.4
@angular-devkit/schematics : 12.1.4
@angular/cli : 12.1.4
@ionic/angular-toolkit : 4.0.0
Capacitor:
Capacitor CLI : 3.3.1
@capacitor/android : 3.3.2
@capacitor/core : 3.3.1
@capacitor/ios : not installed
Cordova:
Cordova CLI : 10.0.0 ([email protected])
Cordova Platforms : none
Cordova Plugins : no whitelisted plugins (2 plugins total)
Utility:
cordova-res (update available: 0.15.4) : 0.15.3
native-run : 1.5.0
System:
NodeJS : v14.15.5 (/usr/local/bin/node)
npm : 6.14.11
OS : Linux 5.13
=== ERROR ===
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.json.JSONObject.toString()' on a null object reference
at org.apache.cordova.PluginResult.<init>(PluginResult.java:55)
at org.apache.cordova.CallbackContext.success(CallbackContext.java:70)
at com.terikon.cordova.photolibrary.PhotoLibrary$5$1.run(PhotoLibrary.java:212)
at com.terikon.cordova.photolibrary.PhotoLibraryService$2.run(PhotoLibraryService.java:214)
at com.terikon.cordova.photolibrary.PhotoLibraryService$5.onScanCompleted(PhotoLibraryService.java:579)
at android.media.MediaScannerConnection.runCallBack(MediaScannerConnection.java:211)
at android.media.MediaScannerConnection.lambda$scanFile$1(MediaScannerConnection.java:188)
at android.media.-$$Lambda$MediaScannerConnection$X7K_c7l7bfQR6Mg9eCJVPmLMn6I.run(Unknown Source:6)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:248)
at android.os.HandlerThread.run(HandlerThread.java:67)
There has been no recent activity and this issue has been marked inactive.
@adeshkrsingh, did you solve it? I have the same problem
There has been no recent activity and this issue has been marked inactive.
Same issue here.
Ok I applied this and it fixed it.
There has been no recent activity and this issue has been marked inactive.