I am using this Kfilter library for adding filters in my code written in JAVA.
I am getting this error java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull
while adding the image to the Imageview.
This is my code:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == 1 && resultCode == Activity.RESULT_OK){
if (data == null) {
showMessage("Failed to open picture!");
return;
}
else
{
resultUri = data.getData();
kfilter.setContentPath(resultUri.toString()); //Error occurs here
kfilter.setFilters(filter);
}
}
}
This is the error:
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://com.google.android.apps.photos.contentprovider/0/1/content://media/external/images/media/120425/ORIGINAL/NONE/916748167 flg=0x1 clip={text/uri-list U:content://com.google.android.apps.photos.contentprovider/0/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F120425/ORIGINAL/NONE/916748167} }} to activity {com.unit.helloworld/com.unit.helloworld.CompetitionPackage.AddNewPhotoAcivity}: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter $this$startsWith
at android.app.ActivityThread.deliverResults(ActivityThread.java:4596)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4638)
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1976)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6912)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:860)
Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter $this$startsWith
at kotlin.text.StringsKt__StringsJVMKt.startsWith(Unknown Source:2)
at kotlin.text.StringsKt__StringsJVMKt.startsWith$default(StringsJVM.kt:332)
at com.isaacudy.kfilter.KfilterMediaFile.<init>(KfilterMediaFile.kt:32)
at com.isaacudy.kfilter.KfilterView.setContentPath(KfilterView.kt:98)
at com.unit.helloworld.CompetitionPackage.AddNewPhotoAcivity.onActivityResult(AddNewPhotoAcivity.java:208)
at android.app.Activity.dispatchActivityResult(Activity.java:7468)
All I can find is to add ?
to the code. But I have written in Java and the library is developed in kotlin. How to solve this?
After closer inspection of the stack trace you'll notice that the error arises in KfilterMediaFile
. The following is the relevant section:
val extension = path.split(".").last()
val mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension)
when {
mimeType.startsWith("video") -> processAsVideo() // the error arises here
mimeType.startsWith("image") -> processAsImage()
else -> error = MediaError.ERROR_INVALID_FILE_TYPE
}
The mimeType
is null if the MimeTypeMap
could not map the file extension to a mime type. Therefore I'd recommend that you check that the type of your file is correct. If it is you could ask the library maintainer about the problem, such that this case is handled more gracefully.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.