Android Question AH View Pager layout throwing errors on com.android.support.design 28.0.0

AscySoft

Active Member
Licensed User
Longtime User
EDIT: Jump to the conclusion and partial fix here

I open this thread to ask if someone else has encountered this issue.
Setup everything as in https://www.b4x.com/android/forum/t...nal-material-design-components.58893/#content
Try download FixedTabsExample2_00.zip file, and set everything up for AHViewPager library.
Update any SDK and try to build example above with "FixedTabIcon" from @corwin42 who's work btw is tremendous.
The error is below
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = false **
main_activity_create (java line: 348)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at example.tablayout.fixedtabsicon.main._activity_create(main.java:348)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
at example.tablayout.fixedtabsicon.main.afterFirstLayout(main.java:104)
at example.tablayout.fixedtabsicon.main.access$000(main.java:17)
at example.tablayout.fixedtabsicon.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
... 14 more
Caused by: java.lang.NoSuchMethodError: No virtual method addOnTabSelectedListener(Landroid/support/design/widget/TabLayout$OnTabSelectedListener;)V in class Landroid/support/design/widget/TabLayout; or its super classes (declaration of 'android.support.design.widget.TabLayout' appears in /data/app/example.tablayout.fixedtabsicon-e7CwkjBxWIm3lh3PiI3hrg==/base.apk)
at de.amberhome.objects.TabLayoutWrapper.innerInitialize(TabLayoutWrapper.java:63)
at anywheresoftware.b4a.objects.ViewWrapper.Initialize(ViewWrapper.java:67)
at de.amberhome.objects.TabLayoutWrapper.Initialize(TabLayoutWrapper.java:52)
at de.amberhome.objects.TabLayoutWrapper._initialize(TabLayoutWrapper.java:90)
... 17 more
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
** Receiver (semails) OnReceive **
Cannot start from a receiver in debug mode.
I know my system is wrongly setup, but I don't know what to do, I tryed so many things (in reality I have a huge app who use some layouts file with AHViewPager views that throw this similar error when loaded, but previously it worked just fine until some sdk? update)
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
the limit to upload is 500 kb or so
 
Upvote 0

AscySoft

Active Member
Licensed User
Longtime User
@jimmyF did you update all SDK resources and compile and run succesefully Erel's example FixedTabsExample2_00.zip ?
I belive that @DonManfred 's right that it's an API change from google, so I'm wonderring how could you successfully compile and run apk on a updated sdk machine/device?
But the forum software will not permit me upload it
I was unable to PM you because you limit this functionality. If you want PM me your email so I can contact you, I just need to give you my email, or you culd use an online free upload service and PM the link to me.
 
Upvote 0

jimmyF

Active Member
Licensed User
Longtime User
My SDK is totally up to date. Maybe that is the issue.

@jimmyF did you update all SDK resources and compile and run succesefully Erel's example FixedTabsExample2_00.zip ?
I downloaded it and compiled it but could not run it on any of my phones. Same error as you.

I was unable to PM you because you limit this functionality

Sorry about that. I didn't realize I had done so. I think I have changed it now.
 
Upvote 0

corwin42

Expert
Licensed User
Longtime User
I can confirm the problem.

After upgrading to support library 28.0.0 the error occurs while starting the app.

I just start to understand, where the problem is.

It has something to do with the fact that support library is moving to androidx.xxx packages. I guess Google has done something bad with the tablayout. Maybe it can be fixed with a new dependency but I'm still searching for the solution.
 
Upvote 0

corwin42

Expert
Licensed User
Longtime User
Downgrading to API 27 should be possible by just deleting the 28.0.0 directories under all the support library folders.

I opended a bug in the Android issue tracker: https://issuetracker.google.com/issues/116821445

Unfortunately I was not able to reproduce this problem with Android Studio (I created a simple AS project which just calls addOnTabSelectedListener()). Therefore I guess the problem only happens when the project is built with aapt.

@Erel: Do you know, if the stuff downloded by your SDK Manager is different from that that Android Studio will download? I think they both use the same Maven repository. So don't really have an idea where the problem exactly is. Maybe there is something wrong with dependency handling.
 
Upvote 0

corwin42

Expert
Licensed User
Longtime User
I just inspected the contents of the generated opt.jar under Objects\bin\extra and the addOnSelectedListener() method is in there.
So I guess there is really a problem with the build process. The two possibilities are: the method gets removed somewhere or it can not be found because of a wrong signature or something.
 
Upvote 0

AscySoft

Active Member
Licensed User
Longtime User
I opended a bug in the Android issue tracker
I assumed it was you, you beat me by minutes. Intresting that they mention that <<
Application built with aapt -> java.lang.NoSuchMethodError: No virtual method addOnTabSelectedListener
- Application built with Gradle -> no problem>>
I also will wait for @Erel's answere.
wrong signature
If it was a wrong signature i think the error will not be raise as NoSuchMethod but more likeley WrongSignature.... But I am just guessing.
 
Last edited:
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Android Studio, I think, uses aapt2.exe unlike B4A, which uses aapt.exe.
Probably, replacing deprecated aapt.exe to aapt2.exe will fix a problem.

I would made expriments, but both tools have a lot of parameters (which are not the same).
So, such trick like renaming aapt2.exe to aapt.exe will not work.
 
Last edited:
Upvote 0

AscySoft

Active Member
Licensed User
Longtime User
Someone replyed at google issue tracker link saying that "TabLayout 28.0.0 is not binary compatible with previous versions due to this signature change with addOnTabSelectedListener()"
As I don't know how to check for this I cannot confirm, but if this is so then the problem will be a patch from google.
Downgrading to API 27 should be possible by just deleting the 28.0.0 directories under all the support library folders
Is not so simple, I don't have any old "27" support lib because B4A Sdk Manager will delete all the old ones when it makes an update.
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Guess you need attached file (extract it in <SDK>\extras\b4a_remote\com\android\support\design subdirectory.
Don't forget to change release in <sdk>\extras\b4a_remote\installed-components.txt
 

Attachments

  • SDK extras b4a_remote com android support design 27.1.1.zip
    313.1 KB · Views: 350
Upvote 0

AscySoft

Active Member
Licensed User
Longtime User
Don't forget to change release in <sdk>\extras\b4a_remote\installed-components.txt
That did the trick. In 'installed-components' change this line "com.android.support\:design=28.0.0" to 27.1.1
Thanks for the files also. They were missing from my design resources. Now I compile under sdk 28 and support design 27 and everything works again!
PS. I'm waiting for google's fix for this. For everyone who don't read this thread keep this in minde only this: In API 28 design support library seems to have a bug (wrong signature). DO NOT UPDATE to com.android.support.design 28 if your cod is using AHViewPager ie (nothing's wrong with AH).
 
Last edited:
Upvote 0

jimmyF

Active Member
Licensed User
Longtime User
I don't understand this becuase I am compiling under Android-28, using AHViewPager, in a large project and I have had no issues with it. Once the SDK was properly installed, that is.
I really think the issue is with DSTabLayout. When I tested the BaA Material Design samples before, that is where the problem was.
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
Just as I said. Support.design (28) and API SDK (28) are two complete different things (that could, should work togheter if needed).
I am keeping (support design) to 27 version, even if manager reccomends to install 28. I compile under 28 platform also. So far so good.
View attachment 73023


ok, I proceeded to restore the 27 with B4A 8.50, hoping that everything will be resolved soon.
thank you
 
Upvote 0

corwin42

Expert
Licensed User
Longtime User
Upvote 0
Top