ImagePicker: App Crashed!!!
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…
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 20
@pe1o2pl try using my forked plugin https://github.com/shaik305/cordova-plugin-image-picker.git
Thanks @thevirajshelke!
@thevirajshelke Thanks, this solution works fine for me ionic v1 - cordova 9 - cordova-android 8.1
Refer this
@shaik305 Thanks! work fine !
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 --saveinstead ofionic cordova plugin add cordova-plugin-telerik-imagepicker --variable PHOTO_LIBRARY_USAGE_DESCRIPTION="your usage message"and thennpm install --save @ionic-native/image-pickerthats 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
@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?
Hi @pe1o2pl
add plugin https://github.com/shaik305/cordova-plugin-image-picker.gitnpm install --save @ionic-native/image-pickerThis is work for me… try this steps and let me know. Thank you.
I’m getting the same issue, have you figured out how to overcome the crashing of app when getpictures called from imagepicker.