Telerik-Verified-Plugins / ImagePicker

Cordova Plugin For Multiple Image Selection
MIT License
181 stars 330 forks source link

App Crashed!!! #90

Open AnandKumar2610 opened 6 years ago

AnandKumar2610 commented 6 years ago

Whenever i call this code app will be crashed see below this.imagePicker.getPictures({}).then((results) => { for (let i = 0; i < results.length; i++) { // stmt block } }, (err) => { // error block });

Error is 06:53:37 E AndroidRuntime : FATAL EXCEPTION: main 06:53:37 E AndroidRuntime : Process: io.ionic.starter, PID: 7436 06:53:37 E AndroidRuntime : java.lang.NoSuchMethodError: No static method getScreenWidthDp(Landroid/content/res/Resources;)I in class Landroid/support/v4/content/res/ConfigurationHelper; or its super classes (declaration of 'android.support.v4.content.res.ConfigurationHelper' appears in /data/app/io.ionic.starter-1/base.apk) 06:53:37 E AndroidRuntime : at android.support.v7.view.ActionBarPolicy.getMaxActionButtons(ActionBarPolicy.java:57) 06:53:37 E AndroidRuntime : at android.support.v7.widget.ActionMenuPresenter.initForMenu(ActionMenuPresenter.java:108) 06:53:37 E AndroidRuntime : at android.support.v7.view.menu.MenuBuilder.addMenuPresenter(MenuBuilder.java:264) 06:53:37 E AndroidRuntime : at android.support.v7.widget.Toolbar.setMenu(Toolbar.java:569) 06:53:37 E AndroidRuntime : at android.support.v7.widget.ToolbarWidgetWrapper.setMenu(ToolbarWidgetWrapper.java:369) 06:53:37 E AndroidRuntime : at android.support.v7.widget.ActionBarOverlayLayout.setMenu(ActionBarOverlayLayout.java:714) 06:53:37 E AndroidRuntime : at android.support.v7.app.AppCompatDelegateImplV9.preparePanel(AppCompatDelegateImplV9.java:1362) 06:53:37 E AndroidRuntime : at android.support.v7.app.AppCompatDelegateImplV9.doInvalidatePanelMenu(AppCompatDelegateImplV9.java:1648) 06:53:37 E AndroidRuntime : at android.support.v7.app.AppCompatDelegateImplV9$1.run(AppCompatDelegateImplV9.java:140) 06:53:37 E AndroidRuntime : at android.os.Handler.handleCallback(Handler.java:739) 06:53:37 E AndroidRuntime : at android.os.Handler.dispatchMessage(Handler.java:95) 06:53:37 E AndroidRuntime : at android.os.Looper.loop(Looper.java:135) 06:53:37 E AndroidRuntime : at android.app.ActivityThread.main(ActivityThread.java:5343) 06:53:37 E AndroidRuntime : at java.lang.reflect.Method.invoke(Native Method) 06:53:37 E AndroidRuntime : at java.lang.reflect.Method.invoke(Method.java:372) 06:53:37 E AndroidRuntime : at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) 06:53:37 E AndroidRuntime : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)

Anyone help! How can i fix? Thanks in advance...

sshaik305 commented 6 years ago

I'm getting the same issue, have you figured out how to overcome the crashing of app when getpictures called from imagepicker.

AnandKumar2610 commented 6 years ago

Hi @shaik305 Now I have using camera plugin for image picker. I can't solve that issue just ignore that..

sshaik305 commented 6 years ago

how about picking multiple images ?

AnandKumar2610 commented 6 years ago

Now i'm using single picture select option... Let me know if u fixed this issue

sshaik305 commented 6 years ago

sure @AnandKumar2610

sshaik305 commented 6 years ago

first remove image picker plugins that you installed including native plugin wrapper and then use cordova plugin add https://github.com/shaik305/cordova-plugin-image-picker.git --save instead of ionic cordova plugin add cordova-plugin-telerik-imagepicker --variable PHOTO_LIBRARY_USAGE_DESCRIPTION="your usage message" and then npm install --save @ionic-native/image-picker

thats it - you can use by calling the function below

import { ImagePicker } from '@ionic-native/image-picker';

constructor(private imagePicker: ImagePicker) { }

...

this.imagePicker.getPictures(options).then((results) => { for (var i = 0; i < results.length; i++) { console.log('Image URI: ' + results[i]); } }, (err) => { });

enjoy coding @AnandKumar2610

AnandKumar2610 commented 6 years ago

@shaik305 thank you very much. I'll try this solution... one doubt: import { ImagePicker } from ''; //but from link is empty

sshaik305 commented 6 years ago

@AnandKumar2610 import { ImagePicker } from '@ionic-native/image-picker';

pe1o2pl commented 6 years ago

with cordova-plugin-telerik-imagepicker the app crashes trying to pick multiply images, but with cordova-plugin-image-picker v1.1.3 getting errors:

Native: tried calling ImagePicker.hasReadPermission, but the ImagePicker plugin is not installed.
Install the ImagePicker plugin: 'ionic cordova plugin add cordova-plugin-telerik-imagepicker'

Seems like ionic-native needs telerik-plugin to run

sshaik305 commented 6 years ago

@pe1o2pl try using my forked plugin https://github.com/shaik305/cordova-plugin-image-picker.git

lieunttuit commented 6 years ago

@shaik305 Thanks! work fine !

AnandKumar2610 commented 6 years ago

Hi @shaik305 Thanks man! it's working prefect!!!!

pe1o2pl commented 6 years ago

Hi @AnandKumar2610 , do you use @ionic-native/image-picker wrapper? If yes, how did you manage to uninstall telerik-imagepicker plugin and use the one from @shaik305 repo? I have installed the plugin from https://github.com/shaik305/cordova-plugin-image-picker.git but still get that error:

 Native: tried calling ImagePicker.hasReadPermission, but the ImagePicker plugin is not installed.
Install the ImagePicker plugin: 'ionic cordova plugin add cordova-plugin-telerik-imagepicker'`
AnandKumar2610 commented 6 years ago

Hi @pe1o2pl

  1. remove plugin image picker
  2. delete all folders and files related to image picker from node module folder
  3. Remove package from Package.json, Plugin.xml, fetch.json and all related files
  4. add plugin https://github.com/shaik305/cordova-plugin-image-picker.git
  5. npm install --save @ionic-native/image-picker

This is work for me.. try this steps and let me know. Thank you.

romain10009 commented 6 years ago

@shaik305 Thank you for your repo, I just wonder how come an official ionic-native cordova plugin does not work off the shelf? What was the issue?

zawars commented 6 years ago

@shaik305 Your solution is not working for me. When i try to add the plugin, build fails.

sjregan commented 6 years ago

A solution related to changing supported android platforms resolved the issue for me.

thevirajshelke commented 5 years ago

Refer this

2. ionic cordova plugin add cordova-android-support-gradle-release
2. ionic cordova platform rm android
3. ionic cordova platform add android
4. ionic cordova build android
nicozenf commented 4 years ago

@thevirajshelke Thanks, this solution works fine for me ionic v1 - cordova 9 - cordova-android 8.1

ascherj commented 4 years ago

Thanks @thevirajshelke!