Skip to content

点击预览空指针 #71

@Jack-bin183

Description

@Jack-bin183

安卓8和安卓10均报空指针,其他功能正常

    <activity android:name="com.donkingliang.imageselector.ImageSelectorActivity"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar"
    android:configChanges="orientation|keyboardHidden|screenSize"/>
    <activity android:name="com.donkingliang.imageselector.PreviewActivity"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar"
        android:configChanges="orientation|keyboardHidden|screenSize"/>

    <activity
        android:name="com.donkingliang.imageselector.ClipImageActivity"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
    <activity
        android:name=".wxapi.WXEntryActivity"
        android:configChanges="keyboardHidden|orientation|screenSize"
        android:exported="true"
        android:theme="@android:style/Theme.Translucent.NoTitleBar"/>

java代码:
//单选并剪裁
ImageSelector.builder()
.useCamera(true) // 设置是否使用拍照
.setCrop(true) // 设置是否使用图片剪切功能。
.setCropRatio(1.0f) // 图片剪切的宽高比,默认1.0f。宽固定为手机屏幕的宽。
.setSingle(true) //设置是否单选
.canPreview(true) //是否可以预览图片,默认为true
.start(this, REQ_CD_IMAGE); // 打开相册

错误log:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.yayan.app, PID: 13904
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.yayan.app/com.donkingliang.imageselector.PreviewActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewGroup$LayoutParams android.widget.RelativeLayout.getLayoutParams()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2983)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3061)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1747)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:192)
at android.app.ActivityThread.main(ActivityThread.java:6825)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewGroup$LayoutParams android.widget.RelativeLayout.getLayoutParams()' on a null object reference
at com.donkingliang.imageselector.PreviewActivity.initView(PreviewActivity.java:125)
at com.donkingliang.imageselector.PreviewActivity.onCreate(PreviewActivity.java:107)
at android.app.Activity.performCreate(Activity.java:7066)
at android.app.Activity.performCreate(Activity.java:7057)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1216)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2931)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3061) 
at android.app.ActivityThread.-wrap12(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1747) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:192) 
at android.app.ActivityThread.main(ActivityThread.java:6825) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions