sarriaroman / photoviewer

PhotoViewer Cordova Plugin
MIT License
157 stars 213 forks source link

Crashes on Android Devices With Ionic #112

Closed checosele closed 6 years ago

checosele commented 6 years ago

Hello i have been trying to use the plugin but i get an error, when i want to see an image, the app crashes and the app close.

I´m working with ionic

cordova (Cordova CLI) : 8.0.0 @ionic/app-scripts : 3.1.8 Cordova Platforms : android 7.0.0 Ionic Framework : ionic-angular 3.9.2

This is my code

`import { Component } from '@angular/core'; import { NavController, NavParams } from 'ionic-angular'; import { PhotoViewer } from '@ionic-native/photo-viewer';

@Component({ selector: 'page-detail-note', templateUrl: 'detail-note.html', }) export class DetailNotePage { note:Object = {};

constructor(public navCtrl: NavController, public navParams: NavParams, private photoViewer: PhotoViewer) { this.note = this.navParams.get('i'); console.log(this.note); }

ionViewDidLoad() { console.log('ionViewDidLoad DetailNotePage'); }

public returnHome(){ this.navCtrl.pop(); } public showImage(url:string){ // const options = { share:true }; this.photoViewer.show(url); } } `

I have this versions on my package.json

@ionic-native/photo-viewer: "^4.5.3", com-sarriaroman-photoviewer: "^1.1.15",

I have tested on Android Devices with Android 8.0, 5.1 and 7.0.

I get this error on the Android Studio Logcat

E/AndroidRuntime: FATAL EXCEPTION: main Process: io.ionic.starter, PID: 15644 java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ProgressBar.setVisibility(int)' on a null object reference at com.sarriaroman.PhotoViewer.PhotoActivity.hideLoadingAndUpdate(PhotoActivity.java:143) at com.sarriaroman.PhotoViewer.PhotoActivity.access$200(PhotoActivity.java:33) at com.sarriaroman.PhotoViewer.PhotoActivity$3.onSuccess(PhotoActivity.java:161) at com.squareup.picasso.ImageViewAction.complete(ImageViewAction.java:51) at com.squareup.picasso.Picasso.deliverAction(Picasso.java:558) at com.squareup.picasso.Picasso.complete(Picasso.java:510) at com.squareup.picasso.Picasso$1.handleMessage(Picasso.java:117) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6592) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:769)

amitkatiyar0692 commented 6 years ago

I am facing this issue too.Have u resolved yet?

checosele commented 6 years ago

@amitkatiyar0692 I have not solved it, i´m going to use other tool

jgutierro commented 6 years ago

Same here

baltejsingh88 commented 6 years ago

Same here as well... is there any other plugin that can be used?

amedeo61 commented 6 years ago

I found that in the file activity_photo.xml the id for ProgressBar is "progressBar1" while the line 120 in PhotoActivity.java

loadingBar = (ProgressBar) findViewById (getApplication (). getResources (). getIdentifier ("loadingBar", "id", getApplication (). getPackageName ()));

refers to the id "loadingBar".

I solved for the moment changing in the activity_photo.xml the id from "progressBar1" to "loadingBar".

jgutierro commented 6 years ago

@amedeo61 I changed it, but still not working. I have to do something else like ¿remove android platform and adding again?

amedeo61 commented 6 years ago

@jgutierro you have to edit the file in platform folder not in plugins folder and then redo the build. if you remove the plugin and re-add it, the error reappears

mtshare commented 6 years ago

Same for me!

nginx17 commented 6 years ago

Hi, I fixed this issue with downgrade to version 1.1.10

checosele commented 6 years ago

@codecrab-studios I use https://github.com/Riron/ionic-img-viewer, but i will try the solutions that other users give us.

Ross-Rawlins commented 6 years ago

+1 here for this issue =)

chrisvltn commented 6 years ago

+1 for this issue. Downgrading to 1.1.10 solved the problem here

baltejsingh88 commented 6 years ago

@checosele yea i had also started using https://github.com/Riron/ionic-img-viewer and it works great!

sarriaroman commented 6 years ago

Thanks for the reports and to recommend how to improve. It's always a pleasure to learn from other developers. I will keep trying to keep this plugin generic and not only for Ionic :)

toddkaufmann commented 6 years ago

I saw the exact same stacktrace under the emulator and crashes on Android with 1.1.15 (worked on iOS); had to downgrade to 1.1.11.

Testing 1.1.16 today and this seems to fix the problem with crashing. Thanks.

karim-ting commented 6 years ago

this plugin crushes on android8 and above