Nativescript-cli: Exception in thread "main" java.lang.RuntimeException: Class not found android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener

Created on 25 Jul 2019  Â·  12Comments  Â·  Source: NativeScript/nativescript-cli

after migrating from 5.3 to 6.0 i got this Error:
after running tns run android

registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Exception in thread "main" java.lang.RuntimeException: Class not found android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener
        at org.nativescript.staticbindinggenerator.Generator.getClass(Generator.java:549)
        at org.nativescript.staticbindinggenerator.Generator.getInterfacesFromCache(Generator.java:532)
        at org.nativescript.staticbindinggenerator.Generator.writeBinding(Generator.java:283)
        at org.nativescript.staticbindinggenerator.Generator.generateBinding(Generator.java:171)
        at org.nativescript.staticbindinggenerator.Generator.processRows(Generator.java:234)
        at org.nativescript.staticbindinggenerator.Generator.generateBindings(Generator.java:121)
        at org.nativescript.staticbindinggenerator.Generator.writeBindings(Generator.java:97)
        at org.nativescript.staticbindinggenerator.Main.main(Main.java:50)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:runSbg'.
> Process 'command 'C:\Program Files\Java\jdk1.8.0_181\bin\java.exe'' finished with non-zero exit value 1

All NativeScript components versions information
nativescript - 6.0.1
√ Component tns-core-modules has 6.0.1 version and is up to date.
√ Component tns-android has 6.0.0 version and is up to date.

question android

Most helpful comment

@ParthMaisheri, the plugins could be ignored depending on the search functionality you use. Most of the find in files functionalities are automatically excluding node_modules by default. For example, in VSCode one, you have to uncheck this filter.

As far as I see, android.support.v4.widget.SwipeRefreshLayout is used in the nativescript-pulltorefresh plugin. I suggest you double-check your search filters and update the nativescript-pulltorefresh plugin if you use it (as far as I see the plugin is replaced by @nstudio/nativescript-pulltorefresh which is AndroidX compatible)?

All 12 comments

Hi @ParthMaisheri! This error may happen if somewhere in your code you extend a class/interface that is not from AndroidX but from the old Android support libraries. Could you check if this is the case? If you don't find anything suspicious, could you share with us your app, if it's not confidential?

Hi @ParthMaisheri! This error may happen if somewhere in your code you extend a class/interface that is not from AndroidX but from the old Android support libraries. Could you check if this is the case? If you don't find anything suspicious, could you share with us your app, if it's not confidential?

is there any tool to check which library is being used in each plugin?

@ParthMaisheri did you find any solution? I have the same issue after I updated to 6.0.1

@ParthMaisheri did you find any solution? I have the same issue after I updated to 6.0.1

I could not solve this then used tns migrate on this sample project https://github.com/NativeScript/sample-androidx-ng Then I used the newly generated version numbers of package.json in my old project and rebuilt from scratch. Worked perfectly. But took me 3 hours :)

the same problem, then to migrate to nativeScript 6

Exception in thread "main" java.lang.RuntimeException: Class not found android.support.v4.view.ViewPager.OnPageChangeListener
at org.nativescript.staticbindinggenerator.Generator.getClass(Generator.java:549)
at org.nativescript.staticbindinggenerator.Generator.getInterfacesFromCache(Generator.java:532)
at org.nativescript.staticbindinggenerator.Generator.writeBinding(Generator.java:283)
at org.nativescript.staticbindinggenerator.Generator.generateBinding(Generator.java:171)
at org.nativescript.staticbindinggenerator.Generator.processRows(Generator.java:234)
at org.nativescript.staticbindinggenerator.Generator.generateBindings(Generator.java:121)
at org.nativescript.staticbindinggenerator.Generator.writeBindings(Generator.java:97)
at org.nativescript.staticbindinggenerator.Main.main(Main.java:50)

@ParthMaisheri did you find any solution? I have the same issue after I updated to 6.0.1

I could not solve this then used tns migrate on this sample project https://github.com/NativeScript/sample-androidx-ng Then I used the newly generated version numbers of package.json in my old project and rebuilt from scratch. Worked perfectly. But took me 3 hours :)

did the same but din't help me.

Hi guys,

When you get such Class not found error, you could just open the AndroidX migration guide and find the replacement of your problematic class.

For example, @ParthMaisheri , according to the above-mentioned guide, your android.support.v4.widget.SwipeRefreshLayout should be replaced with androidx.swiperefreshlayout.widget.SwipeRefreshLayout.

@edrick27, your android.support.v4.view.ViewPager should be replaced with androidx.viewpager.widget.ViewPager.

Additional info: https://www.nativescript.org/blog/migrating-nativescript-plugins-to-androidx

P.S. If the problematic class is part of a plugin, you should check for a newer plugin version with AndroidX support or open an issue in the plugin repo.

@DimitarTachev when i search this "android.support.v4.widget.SwipeRefreshLayout" i am not getting this in any of the plugins or other files.

@ParthMaisheri, the plugins could be ignored depending on the search functionality you use. Most of the find in files functionalities are automatically excluding node_modules by default. For example, in VSCode one, you have to uncheck this filter.

As far as I see, android.support.v4.widget.SwipeRefreshLayout is used in the nativescript-pulltorefresh plugin. I suggest you double-check your search filters and update the nativescript-pulltorefresh plugin if you use it (as far as I see the plugin is replaced by @nstudio/nativescript-pulltorefresh which is AndroidX compatible)?

Thanks @DimitarTachev it worked form me, pluginsnativescript-pulltorefreshand nativescript-snackbar is replaced by @nstudio.

But i am now getting

Didn't find class "com.tns.NativeScriptActivity" on path: DexPathList.

Hi guys,

When you get such Class not found error, you could just open the AndroidX migration guide and find the replacement of your problematic class.

For example, @ParthMaisheri , according to the above-mentioned guide, your android.support.v4.widget.SwipeRefreshLayout should be replaced with androidx.swiperefreshlayout.widget.SwipeRefreshLayout.

@edrick27, your android.support.v4.view.ViewPager should be replaced with androidx.viewpager.widget.ViewPager.

Additional info: https://www.nativescript.org/blog/migrating-nativescript-plugins-to-androidx

P.S. If the problematic class is part of a plugin, you should check for a newer plugin version with AndroidX support or open an issue in the plugin repo.

I have the same issue just i dont know which plugin is causing it ?
I checked nativescript-carousel and updated it to latest but no luck...

java.lang.RuntimeException: Class not found android.support.v4.view.ViewPager.OnPageChangeListener at org.nativescript.staticbindinggenerator.Generator.getClass(Generator.java:551) at org.nativescript.staticbindinggenerator.Generator.getInterfacesFromCache(Generator.java:534) at org.nativescript.staticbindinggenerator.Generator.writeBinding(Generator.java:283) at org.nativescript.staticbindinggenerator.Generator.generateBinding(Generator.java:171) at org.nativescript.staticbindinggenerator.Generator.processRows(Generator.java:234) at org.nativescript.staticbindinggenerator.Generator.generateBindings(Generator.java:121) at org.nativescript.staticbindinggenerator.Generator.writeBindings(Generator.java:97) at org.nativescript.staticbindinggenerator.Main.main(Main.java:55)

Thanks to your solution ( files include search in vscode) I found my solution. It was nativescript-image-swipe plugin which caused the error

Error executing Static Binding Generator: Class not found android.support.v4.view.ViewPager.OnPageChangeListener

I just upgrade it to latest version and now It's OK !

Was this page helpful?
0 / 5 - 0 ratings