-
Notifications
You must be signed in to change notification settings - Fork 3k
PictureSelector 3.0 常见错误
一、部分华为Android 10以上机型出现图片加载不出来,或者一直loading黑屏问题,经验证是系统兼容性问题;
1.当频繁调用context.getContentResolver().openInputStream();方法时可能会造成io线程阻塞问题;
2.现提供的解决方案是回退targetSdkVersion=28; 或者targetSdkVersion=29且在AndroidManifest.xml设置(requestLegacyExternalStorage=true)
二、 ImageEngine java.lang.NullPointerException 异常
java.lang.NullPointerException: imageEngine is null,Please implement ImageEngine
解决方案 需要给PictureSelector .setImageEngine图片引擎,具体参考demo GlideEngine类
三、集成lStar not found.异常,原因是androidx.core:core引入版本时内部使用了.+号;默认会下载最新版本库导致不兼容;
res/values/values.xml:105:5-114:25: AAPT: error: resource android:attr/lStar not found.
解决方案在app/build.gradle添加如下代码:
configurations.all {
resolutionStrategy {
force 'androidx.core:core-ktx:1.6.0'
force 'androidx.core:core:1.6.0'
force 'androidx.appcompat:appcompat:1.3.1'
force "androidx.activity:activity:1.3.1"
force "androidx.fragment:fragment:1.3.1"
}
}
Android 11手机拍照或录像没反应问题;再AndroidManifest.xml下添加如下代码:
<queries package="${applicationId}">
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE">
</action>
</intent>
<intent>
<action android:name="android.media.action.ACTION_VIDEO_CAPTURE">
</action>
</intent>
</queries>
四、Invoke-customs are only supported starting with Android O (--min-api 26) 错误
解决方案在app/build.gradle添加如下代码:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
五、裁剪 java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
1.在主应用的styles文件中添加去掉ActionBar的theme
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
2.修改UCropActivity AndroidManifest.xml中的theme
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:theme="@style/AppTheme.NoActionBar" />
六、LocalMedia对象没有返回宽高或视频宽高相反问题?
这个问题是因为MediaStore查询出来时并未返回宽高,解决方案可以在具体用的时候通过Glide等图片加载库去获取一下