jaydeepw / poly-picker

Android library project for providing multiple image selection from the device.
406 stars 114 forks source link

ImagePickerActivity throws NullPointerException #28

Closed fotock closed 8 years ago

fotock commented 9 years ago

My code: Intent intent = new Intent(view.getContext(), ImagePickerActivity.class); intent.putExtra(ImagePickerActivity.EXTRA_SELECTION_LIMIT, 9); startActivityForResult(intent, INTENT_REQUEST_GET_IMAGES);

exception thrown: Caused by: java.lang.NullPointerException at nl.changer.polypicker.ImagePickerActivity.setupActionBar(ImagePickerActivity.java:104) at nl.changer.polypicker.ImagePickerActivity.onCreate(ImagePickerActivity.java:83) at android.app.Activity.performCreate(Activity.java:5020) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)             at android.app.ActivityThread.access$600(ActivityThread.java:149)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)             at android.os.Handler.dispatchMessage(Handler.java:99)

Any help? Thanks.

jaydeepw commented 9 years ago

The crash is in your setupActionBar() method. Probably your theme has no ActionBar but you are trying to get a handle to it. Possible?

anuragdadheech commented 9 years ago

I was having the same issue. Turned out my application base theme was AppCompat, which was causing issues. Changed the theme for particular activity and it worked. Hope it helps someone else.

azam3d commented 9 years ago

This is step by step guide to change particular activity theme. In styles.xml, add this lines

<style name="HoloTheme" parent="@android:style/Theme.Holo.Light">

</style>

In AndroidManifest.xml change these lines to these

<activity android:name="nl.changer.polypicker.ImagePickerActivity"
          android:theme="@style/HoloTheme"/>

No more crash after that.

HwanIk commented 9 years ago

@azam3d Thanks!!!!!!!!!!! you save me!! :D

fotock commented 9 years ago

@anuragdadheech, @azam3d are both correct. In my case:

<activity android:name="nl.changer.polypicker.ImagePickerActivity"
          android:theme="@style/AppTheme"/>
anand171 commented 6 years ago

Hi Jaydeepw,

I am using your library, and that is giving an error regarding classpath. my app classpath is ... classpath 'com.android.tools.build:gradle:3.0.1'

error is ..... Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.github.jaydeepw:poly-picker:1.0.23.

Could not resolve com.github.jaydeepw:poly-picker:1.0.23. Required by: project :app

Could not resolve com.github.jaydeepw:poly-picker:1.0.23. Could not get resource 'https://repo.commonsware.com.s3.amazonaws.com/com/github/jaydeepw/poly-picker/1.0.23/poly-picker-1.0.23.pom'. Could not GET 'https://repo.commonsware.com.s3.amazonaws.com/com/github/jaydeepw/poly-picker/1.0.23/poly-picker-1.0.23.pom'. Host name 'repo.commonsware.com.s3.amazonaws.com' does not match the certificate subject provided by the peer (CN=*.s3.amazonaws.com, O=Amazon.com Inc., L=Seattle, ST=Washington, C=US)

please help me as soon as possible.