Parameter specified as non null is null method kotlin jvm internal intrinsics checknotnullparameter

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter specified as non-null is null: parameter token #1920

Parameter specified as non-null is null: parameter token #1920

Comments

Please use the Discussion board if you want to get some help. Please use issues to report bugs.

Description
App is crashing when running
await requestPurchase( sku: productId
>);

Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter token

Expected Behavior

302394450_778185016849443_8950993567380914766_n

Screenshots

Environment:

  • react-native-iap: 10.0.3
  • react-native:0.63.4
  • Platforms (iOS, Android, emulator, simulator, device): Android 10

To Reproduce
Steps to reproduce the behavior:

[Optional] Additional Context

The text was updated successfully, but these errors were encountered:

i am with this error, when calling requestSubscription, any sollution ?

Hi — I have this exact same issue. Has anyone else found a solution for this?

Same version of the library? have you tried updating to the latest?

Andres, thanks for your response. Yes – I did a fresh “yarn add react-native-iap” today. And I’m running the latest React Native version as well. Any guidance you might have would be greatly appreciated! Regards, Scott From: Andres Aguilar ***@***.***> Sent: Tuesday, September 27, 2022 3:49 PM To: dooboolab/react-native-iap ***@***.***> Cc: sbulmahn ***@***.***>; Comment ***@***.***> Subject: Re: [dooboolab/react-native-iap] Parameter specified as non-null is null: parameter token (Issue #1920) Same version of the library? have you tried updating to the latest? — Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you commented.Message ID: ***@***.***>

Did you follow the migration guides in the docs?

Hi Andres – Yes, we did follow the implementation details that we found on the Git site. Question: would this issue happen if we don’t yet have our application hosted in the Google Play store? We’re still doing implementation testing and haven’t yet posted it. Thanks again for your help, and please advise Regards, Scott From: Andres Aguilar ***@***.***> Sent: Wednesday, September 28, 2022 10:56 AM To: dooboolab/react-native-iap ***@***.***> Cc: sbulmahn ***@***.***>; Comment ***@***.***> Subject: Re: [dooboolab/react-native-iap] Parameter specified as non-null is null: parameter token (Issue #1920) Did you follow the migration guides in the docs? — Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you commented.Message ID: ***@***.***>

You can only test Android IAP if the app is in the Play Store

I have the same issues. Any Idea?

I used version 8.0.4 a few days ago everything is ok. But today when I run yarn or npm install this error appears.
Change RNIap.requestSubscription(sku) -> to RNIap.requestSubscription() is working for me. Is there any explanation?

You must have updated it to 10.x.x + where that change was made

Thanks @quocbaovu15101996 , it’s working for me.

You can’t perform that action at this time.

Источник

Kotlin NullPointerException: Parameter specified as non-null is null

announcement - icon

As a seasoned developer, you’re likely already familiar with Spring. But Kotlin can take your developer experience with Spring to the next level!

  • Add new functionality to existing classes with Kotlin extension functions.
  • Use Kotlin bean definition DSL.
  • Better configure your application using lateinit.
  • Use sequences and default argument values to write more expressive code.

By the end of this talk, you’ll have a deeper understanding of the advanced Kotlin techniques that are available to you as a Spring developer, and be able to use them effectively in your projects.

1. Overview

Kotlin is a null-safe programming language, in the sense that it differentiates between nullable and non-nullable data types.

In this quick tutorial, we’re going to see what happens when we store a null value into a non-null data type in Kotlin.

2. Storing null Values in Non-Nullable Types

The Kotlin compiler will enforce the null-safety of data types at compile-time. So if we write something like:

Then, the compiler will complain with an error at compile-time:

Kotlin: Null can not be a value of a non-null type String

Even though the Kotlin compiler enforces null-safety at compile-time, sometimes we may need another safety measure at runtime, too. Put simply, sometimes storing a null value into a non-nullable variable isn’t apparent at compile-time. So the compiler needs the runtime help in these cases.

To make matters more concrete, let’s consider a simple data model class:

data class User(val id: Long, val username: String)

If we try to set the username field to null via reflection:

val constructor = User::class.java.constructors[0] val createInstance =

Then Kotlin will throw an exception since the username field is set to null:

val exception = assertThrows < createInstance() >assertThat(exception.cause).isInstanceOf(NullPointerException::class.java) assertThat(exception.cause?.message).startsWith("Parameter specified as non-null is null")

If we don’t assert the exception details, the runtime will print the following stack trace:

java.lang.NullPointerException: Parameter specified as non-null is null: method User., parameter username // truncated

The stack trace is obvious: A non-null property named username from the User class constructor ( is the constructor) is set to null. Before Kotlin 1.4, however, the same error manifested itself as an IllegalArgumentException.

The bottom line is that Kotlin throws this exception with this particular message pattern when we set a non-null property to null at runtime.

3. Conclusion

In this short tutorial, we learned how Kotlin enforces null-safety at both compile-time and runtime.

As usual, all the examples are available over on GitHub.

Источник

Parameter specified as non-null is null : kotlin.jvm.internal.Intrinsics.checkNotNullParameter

Parameter specified as non-null is null : kotlin.jvm.internal.Intrinsics.checkNotNullParameter

I’m trying to upload image to website, It was successful but app shows FETAL error.

issue seems like in AsyncTask as it might get executed to early.

I also upgraded SDK version 30 to 32
& ucrop:2.2.5

package com.myappname.dating.ui.home.profileImageUploading import android.app.Activity import android.content.Intent import android.graphics.Color import android.net.Uri import android.os.AsyncTask import android.os.Bundle import android.view.View import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import com.myappname.dating.R import com.myappname.dating.data.db.CrushDataBase import com.myappname.dating.data.network.ApiHelper import com.myappname.dating.data.network.model.profileRespo.ProfileStatus import com.myappname.dating.data.network.model.user.Mediafile import com.myappname.dating.data.network.model.user.UserResponse import com.myappname.dating.data.pref.AppPreferencesHelper import com.myappname.dating.ui.login.LoginActivity import com.myappname.dating.ui.utils.AppConstants import com.myappname.dating.ui.utils.CommonUtil import com.yalantis.ucrop.UCrop import kotlinx.android.synthetic.main.activity_user_image_crop.* import kotlinx.android.synthetic.main.activity_user_image_crop.pb_load import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MultipartBody import okhttp3.RequestBody import okhttp3.RequestBody.Companion.asRequestBody import okhttp3.RequestBody.Companion.toRequestBody import retrofit2.Call import retrofit2.Callback import retrofit2.Response import java.io.File @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") class UserImageCropActivity : AppCompatActivity(), View.OnClickListener, CropImageView < internal val IMAGE_REQUEST_CODE = 123 internal val CROP_IMAGE_NAME = "cropImage" private lateinit var mImageCropPresenter : ImageCropPresenter lateinit var from : String var imageUriResultCrop: Uri? = null var uriString: String? = null lateinit var mPref: AppPreferencesHelper var mCrushDataBase: CrushDataBase? = null lateinit var userResponse: UserResponse; override fun onCreate(savedInstanceState : Bundle?) < super.onCreate(savedInstanceState) setContentView(R.layout.activity_user_image_crop) mPref = AppPreferencesHelper(applicationContext, AppConstants.PREF_NAME) val view: View = findViewById(R.id.imageCropActivity) mCrushDataBase = CrushDataBase.getDatabase(this) mImageCropPresenter = ImageCropPresenterImpl(this, this, view) if(intent != null)< from = intent.getStringExtra("From").toString() >if(from.equals("Signup")) < //Toast.makeText(applicationContext, "Uploaded", Toast.LENGTH_SHORT).show() >else < userResponse = getDataTask(this).execute().get() >val galleryIntent = Intent(Intent.ACTION_PICK) galleryIntent.type = "image/*" if(galleryIntent.resolveActivity(packageManager) != null) < startActivityForResult( Intent.createChooser(galleryIntent, "Select Picture"), IMAGE_REQUEST_CODE ) >uploadBtn.setOnClickListener(this) > override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) < super.onActivityResult(requestCode, resultCode, data) if (requestCode == IMAGE_REQUEST_CODE && resultCode == Activity.RESULT_OK) < val imageUri = data?.data if (imageUri != null) < startCrop(imageUri) >else < uploadBtn.visibility = View.GONE finish() // if (from == "") < // // >// else if(from == "") // < // // >> > else < imageUriResultCrop = data?.let < UCrop.getOutput(it) >uriString = imageUriResultCrop?.path if (imageUriResultCrop != null) < result_image.setImageURI(imageUriResultCrop) uploadBtn.visibility = View.VISIBLE >else < uploadBtn.visibility = View.GONE finish() >> > private fun startCrop(uri: Uri) < var destinationFileName = CROP_IMAGE_NAME destinationFileName += ".jpg" val uCrop = UCrop.of(uri, Uri.fromFile(File(cacheDir, destinationFileName))) uCrop.withAspectRatio(1F, 1F) uCrop.withMaxResultSize(800, 800) uCrop.withOptions(getCropOptions()) uCrop.start(this) >private fun getCropOptions() : UCrop.Options < val options = UCrop.Options() options.setHideBottomControls(false) options.setFreeStyleCropEnabled(true) options.setStatusBarColor(resources.getColor(R.color.colorPrimaryDark)) options.setToolbarColor(resources.getColor(R.color.colorPrimary)) return options >override fun onClick(v: View?) < when (v?.id) < R.id.uploadBtn -> < if (uriString == null || uriString == "") < Toast.makeText(applicationContext, "please select an image ", Toast.LENGTH_LONG) .show() return >else < val file = File(imageUriResultCrop?.path) val requestFile = file.asRequestBody("multipart/form-data".toMediaTypeOrNull()) val body = MultipartBody.Part.createFormData("avater", file.name, requestFile) val accessToken: String? = mPref.getAccessToken() val requestBody = accessToken?.toRequestBody(MultipartBody.FORM) if (from.equals("Signup"))< updateAvater(requestBody,body) >else if(from.equals("ProfileAct"))< updateAvaterp(requestBody,body) >else if(from.equals("userImage"))< updateAvaterG(requestBody,body) >else if(from.equals("userImageD")) < updateAvaterGal(requestBody,body) >else < mImageCropPresenter.imageCropUploadPresenter(requestBody, body) >> uploadBtn.isClickable = false uploadBtn.setBackgroundColor(Color.parseColor("#e4e6e8")) > > > fun updateAvaterp( access_token: RequestBody?, avater: MultipartBody.Part ) < ApiHelper().updateAvaterImage(access_token, avater) .enqueue(object : Callback< override fun onFailure(call: Call, t: Throwable) < Toast.makeText(applicationContext, "Failed to upload please select another image or check internet", Toast.LENGTH_SHORT) .show() uploadBtn.isClickable = true uploadBtn.setBackgroundColor(Color.parseColor("#2196f3")) >override fun onResponse( call: Call, response: Response ) < if (response.isSuccessful) < val updateCheck = UpdateTaskA( [email protected], response.body(). picurl, userResponse.id ).execute().get() Toast.makeText(applicationContext, "Profile Upload Successfully", Toast.LENGTH_SHORT).show() finish() > > >) > fun updateAvaterG( access_token: RequestBody?, avater: MultipartBody.Part ) < ApiHelper().updateAvaterImage(access_token, avater) .enqueue(object : Callback< override fun onFailure(call: Call, t: Throwable) < Toast.makeText(applicationContext, "Failed to upload please select another image or check internet", Toast.LENGTH_SHORT) .show() >override fun onResponse( call: Call, response: Response ) < if (response.isSuccessful) < val updateCheck = UpdateTaskG([email protected], response.body(). picurl, userResponse. id ).execute().get() Toast.makeText(applicationContext, "Profile Upload Successfully", Toast.LENGTH_SHORT).show() finish() > > >) > fun updateAvaterGal( access_token: RequestBody?, avater: MultipartBody.Part ) < ApiHelper().uploadImage(access_token, avater) .enqueue(object : Callback< override fun onFailure(call: Call, t: Throwable) < Toast.makeText(applicationContext, "Failed to upload please select another image or check internet", Toast.LENGTH_SHORT) .show() >override fun onResponse( call: Call, response: Response ) [email protected], response.body(). picurl, userResponse. id ).execute().get() Toast.makeText(applicationContext, "Image Upload Successfully", Toast.LENGTH_SHORT).show() // finish() // var lnk = response.body(). file_url // response.body().picurl val intent = Intent(applicationContext, UserImageGalleryActivity::class.java) // intent.putExtra("fileurl", lnk) // intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_CLEAR_TASK startActivity(intent) //startActivity(Intent(this, UserImageGalleryActivity::class.java)) > > >) > fun updateAvater( access_token: RequestBody?, avater: MultipartBody.Part ) < ApiHelper().updateAvaterImage(access_token, avater) .enqueue(object : Callback< override fun onFailure(call: Call, t: Throwable) < Toast.makeText(applicationContext, "Failed to upload please select another image or check internet", Toast.LENGTH_SHORT) .show() >override fun onResponse( call: Call, response: Response ) < if (response.isSuccessful) < val intent = Intent(applicationContext, LoginActivity::class.java) intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_CLEAR_TASK startActivity(intent) finish() >> >) > override fun showProgressBar() < pb_load.visibility = View.VISIBLE >override fun hideProgressBar() < pb_load.visibility = View.GONE >override fun onSuccess(id: String) < var value: List// val updateCheck = UpdateTask(this,map).execute().get() Toast.makeText(applicationContext, "Image Upload Successfully$id", Toast.LENGTH_LONG).show() finish() > override fun onFailure(message: String) < Toast.makeText( applicationContext, "Image not upload Something went wrong"+message, Toast.LENGTH_LONG ).show() finish() >override fun backToActivity() < val intent = Intent(applicationContext, UserImageGalleryActivity::class.java) intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK startActivity(intent) finish() >override fun onDestroy() < super.onDestroy() mImageCropPresenter.onDestroy() >private class UpdateTask(var context: UserImageCropActivity, var value: List?) : AsyncTask() < override fun doInBackground(vararg params: Void?): Boolean < context.mCrushDataBase. crushDao().updateMediaFile(value, 1) return true >override fun onPostExecute(bool: Boolean?) < if (bool!!) < >> > class UpdateTaskA(var context: UserImageCropActivity, var avatar: String,var id : Int) : AsyncTask() < override fun doInBackground(vararg params: Void?): Boolean < val imageAvatar = CommonUtil.convertToString64(avatar) context.mCrushDataBase. crushDao().updateAvatar(imageAvatar. id) return true >override fun onPostExecute(bool: Boolean?) < if (bool!!) < >> > class UpdateTaskG(var context: UserImageCropActivity, var avatar: String, var user: Int) : AsyncTask() < override fun doInBackground(vararg params: Void?): Boolean < val imageAvatar = CommonUtil.convertToString64(avatar) context.mCrushDataBase. crushDao().updateAvatar(imageAvatar. user) return true >override fun onPostExecute(bool: Boolean?) < if (bool!!) < >> > class getDataTask(var context: UserImageCropActivity) : AsyncTask() < override fun doInBackground(vararg params: Void?): UserResponse < var listOfdata = context.mCrushDataBase. crushDao().getData() val data = listOfdata[0] return data >override fun onPostExecute(userResponse: UserResponse?) < >> > 

Error was displayed in line

 FATAL EXCEPTION: main Process: com.myappname.dating, PID: 17170 java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter avatar at com.myappname.dating.ui.home.profileImageUploading.UserImageCropActivity$UpdateTaskA.(Unknown Source:7) at com.myappname.dating.ui.home.profileImageUploading.UserImageCropActivity$updateAvaterp$1.onResponse(UserImageCropActivity.kt:190) 

Solution – 1

I suggest not to use non-null assertion operator !! in places where a variable can be null . There is a safe call operator ?. for that purpose:

val pictureUrl = response.body()?.picurl pictureUrl?.let < picurl ->// Execute this block of code only when `pictureUrl` is not null val updateCheck = UpdateTaskA( [email protected], picurl, userResponse.id ).execute().get() > 

Solution – 2

Your stacktrace is saying that you’re passing null for the avatar parameter in the UpdateTaskA constructor, which is being called from the onResponse function inside UpdateAvaterp

// avatar is a String, not a String? so it can't be null class UpdateTaskA(var context: UserImageCropActivity, var avatar: String,var id : Int) 
// inside your on onResponse function UpdateTaskA([email protected], response.body(). picurl, userResponse.id ) 

So you’re passing response.body(). picurl as your avatar parameter, but it’s null. So your response doesn’t have that value. You either need to handle the possibility that it’s null, or if that should never happen (which is a risky assumption when calling an API that could change) then you need to work out what the problem is with the network call and fix it.

Easiest way is probably setting a breakpoint inside onResponse and inspecting the response to see what it contains, and if there’s any info about why you’re not getting the data you want. If you haven’t used the debugger before, here’s an overview – it can save you a lot of time!

Solution – 3

Instead you can use java.util.concurrent.Executors or just Kotlin Coroutines to handle doing stuff asynchronously.

Источник

Читайте также:  Меню блок для html
Оцените статью