NativeScript: java.lang.NoSuchMethodError after upgrade to 6.5.10

Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project): ✔ Component nativescript has 6.7.8 version and is up to date. ✔ Component @nativescript/core has 6.5.10 version and is up to date. ✔ Component tns-android has 6.5.3 version and is up to date. ✔ Component tns-ios has 6.5.2 version and is up to date.

Describe the bug

After upgrading to 6.5.10, I get exceptions like

JS: Error: java.lang.NoSuchMethodError: no static method "Landroid/view/View;.setPadding(IIII)V"

System.err: StackTrace:
System.err: onBackgroundOrBorderPropertyChanged(file: node_modules/@nativescript/core/ui/styling/background.android.js:86:0)
System.err: 	at push.../node_modules/@nativescript/core/ui/core/view/view.js.View._redrawNativeBackground(file: node_modules/@nativescript/core/ui/core/view/view.android.js:777:0)

and

System.err: Calling js method onAnimationEnd failed
System.err: Error: java.lang.NoSuchMethodError: no static method "Landroid/os/Handler;.postDelayed(Ljava/lang/Runnable;J)Z"
System.err: 
System.err: StackTrace:
System.err: setTimeout(file: node_modules/@nativescript/core/timer/timer.android.js:33:0)
System.err: 	at scheduleTask(file: node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js:1582:0)
Sys

and

JS: ERROR Error: java.lang.NoSuchMethodError: no static method "Landroid/os/Handler;.postDelayed(Ljava/lang/Runnable;J)Z"

and

07-14 17:49:12.370 26823 26823 W System.err: Calling js method onStart failed
07-14 17:49:12.370 26823 26823 W System.err: Error: java.lang.NoSuchMethodError: no static method "Landroid/view/View;.setPadding(IIII)V"
07-14 17:49:12.370 26823 26823 W System.err: 
07-14 17:49:12.370 26823 26823 W System.err: StackTrace:
07-14 17:49:12.370 26823 26823 W System.err: onBackgroundOrBorderPropertyChanged(file:///data/data/de.debeka.fotoapp/files/app/vendor.js:121540:20)
07-14 17:49:12.370 26823 26823 W System.err: 	at push.../node_modules/@nativescript/core/ui/core/view/view.js.View._redrawNativeBackground(file:///data/data/de.debeka.fotoapp/files/app/vendor.js:111656:29)

With Version @nativescript/core 6.5.1 everything runs fine.

To Reproduce

Expected behavior No exceptions 😉

Additional context

  • Tried to set
project.ext {
        androidXRecyclerViewVersion = "1.1.0"
        androidXAppCompatVersion = "1.1.0"
    }
  • --no-hmr does not help, the error also occurs with a production build and is reported from the Google Play Console “Pre-Launch-Report”

  • for some exceptions I see

07-14 18:44:00.278 30019 30019 E JS      : ERROR Error: java.lang.NoSuchMethodError: no static method "Landroid/os/Handler;.postDelayed(Ljava/lang/Runnable;J)Z"
07-14 18:44:00.282 30019 30019 E JS      : ERROR Error: java.lang.NoSuchMethodError: no static method "Landroid/os/Handler;.postDelayed(Ljava/lang/Runnable;J)Z"
07-14 18:44:00.286 30019 30019 E JS      : ERROR CONTEXT [object Object]

while I have no clue where the “ERROR CONTEXT” originates from

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 4
  • Comments: 28 (17 by maintainers)

Most upvoted comments

I have traced down the actual issue in the Android runtime, the next version should have a fix that will allow you to not have to black list any data. 😀

In addition we discovered another metadata issue that was inflating the metadata by about 20k for apps that will be resolved, might be a bit more on full apps but probably not much more.

@NathanaelA, @triniwiz you’re a gods 😃 With latest suggestions I’m not getting any errors. Will test it a bit more in next few days to see if everything is actually resolved. But I was running tns debug Android with hmr for few hours and different scenarios and didn’t receive any postDelayed or setPadding errors.

@triniwiz @NathanaelA thanks a lot for the explanations and of course for the work done here 😃 Our tests were successful to I can confirm that this workarouns is working! thank you 🎉

Experiencing same issue

Uncaught exception: Error: Calling js method onCreateView failed
Error: java.lang.NoSuchMethodError: no static method "Landroid/view/View;.setPadding(IIII)V"
Uncaught exception: Error: Calling js method onStart failed
Error: java.lang.NoSuchMethodError: no static method "Landroid/view/View;.setPadding(IIII)V"

And literally in the same boat as @madmas, most stable version was for project I work with is 6.1.1. Now with upgrade I experience those issues.

@comiguel for you it will be the following

{
    "whitelist": [
    ],
    "blacklist": [
       "androidx.core.view:ViewKt*",
       "androidx.core.os:HandlerKt*",
       "androidx.core.widget:TextViewKt*"
    ]
}

Hi All; ok thanks to @Brysem he narrowed down the actual library causing the issues. After a lot of tests and research, I have figured out what is going on… I have a temporary patch you can apply to your app that should fix the issue. I need to do some more testing to see the best way to fix this for good (for the next NS release); but this patch should allow you to move forward with your apps and has no negative issues that I can think of.

  1. Create a new files in your App_Resource/Android/ called native-api-usage.json so it should be like this: image
  2. Inside this file you want to add this:
{
    "whitelist": [
    ],
    "blacklist": [
       "androidx.core.view:ViewKt*"
    ]
}
  1. tns clean android

  2. Go forward and create awesome non-crashing apps. 😀

Any Android device physical or not. When running tns debug instead of tns run or installing it on device, it’s happening much more often. And yes. Android runtime is 6.1. But can we run in the mean time core 6.5, ios-runtime 6.5 and android-runtime 6.1? Since the biggest problem with those upgrades is that you need ios-runtime 6.5 because of iOS 14.