Android Question Wear OS Tutorial for B4A 8.50

alwaysbusy

Expert
Licensed User
Longtime User
EDIT: Turned out a tutorial wasn't needed, but DonManfred gave me all the clues needed to continue with the project myself. Got him a couple of beers...

I've been searching to find a way to make a Wear OS app + mobile app for the best part of a week now, but don't seem to find a way to get it working. I've got some pointers from Erel, but it is not easy to puzzle all snippets together to one complete 'tutorial'. Some stuff said in some post may have worked at a certain time, but don't work anymore now.

I admit it has been a couple of years since I've used B4A (I'm fully invested in B4J) and there seems to have changed quite a lot in how stuff works in B4A now. I'm familiar with creating java libraries for B4A but e.g. the whole .aar thing has been very confusing for me.

The closest I got, was trying to use the 'Wearable Datalayer' library from @barx https://www.b4x.com/android/forum/threads/wearable-datalayer.49968/ (he gracefully released the source code of his library and a couple of examples and I went trough his source codes).

However, when I load his library, I get this strange error:
errorb4a.png


From what I understand, with the latest SDKs a lot of old stuff like android-support-v4 and google-play-services doesn't exist anymore so this error may have to do with that. The solution to solve this error may be easy, but as I told, I'm a bit out of touch with the latest developments in B4A.

These are some of the posts I have read and tried to understand and I'm sure each of them is important to succeed:

https://www.b4x.com/android/forum/threads/wearable-datalayer-beta.44859/
https://www.b4x.com/android/forum/threads/wearable-datalayer.49968/page-8#post-457941
https://www.b4x.com/android/forum/t...add-aar-in-eclipse-project.67741/#post-429216
https://www.b4x.com/android/forum/t...to-google-play-services-fused-location.67748/
https://www.b4x.com/android/forum/threads/creating-and-packaging-a-wear-app.44474/
https://www.b4x.com/android/forum/threads/integrating-firebase-services.67692/
https://www.b4x.com/android/forum/t...add-aar-in-eclipse-project.67741/#post-429216
https://www.b4x.com/android/forum/threads/wear-2-0-solved.75253/#content

Looking at some Android Studio examples on the net (which look very simple actually), I find it hard to believe B4A couldn't make it simpler to make Wear OS apps. ;)

I can already give you a million thanks in advance!

Alwaysbusy
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Yes, it goes to up 2016 or so, and B4A 8.50/SDK 27/Wear OS have evolved a lot since then. I noticed some people did make Wear Apps (Share My Creation) up to the end of 2017 so maybe one of them has cracked the secret ;)

I may try to write a new lib myself (but no need to reinvent the water). However, how to include the google-play-services, gms, wearable stuff nowadays with the .aar files is a puzzle for me. I read the posts on that subject carrefully, but must be missing how it all comes together.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
@DonManfred This looks like it could be it! Now the collections error is gone and a couple of more similar errors are coming up which I seem to be able to solve the same way. I'll report back when all these errors are gone. I thought the SDK manager had already downloaded all needed stuff, but I was wrong!
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
it is getting close! Errors gone, just now in compiling the examples from barx something still may be missing:

B4X:
B4A Version: 8.50
Parsing code.    (0.00s)
Building folders structure.    (0.08s)
Compiling code.    (0.06s)
Compiling layouts code.    (0.01s)
Organizing libraries.    (0.00s)
Generating R file.    Error
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontVariationSettings
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:ttcIndex

Could be something in the manifest...
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Hmm, I don't have android-p, just android-28. And although this gets me again a step further, I think barx lib may need an update as the NodeListener is depreciated:

EDIT: Ah, android-p must have been a typo :)

B4X:
B4A Version: 8.50
Parsing code.    (0.00s)
Building folders structure.    (0.09s)
Compiling code.    (0.07s)
Compiling layouts code.    (0.01s)
Organizing libraries.    (2.47s)
Generating R file.    (1.07s)
Compiling debugger engine code.    (1.07s)
Compiling generated Java code.    Error
B4A line: 53
DL.Initialize(\
javac 1.8.0_73
src\barxdroid\wearable_app\main.java:423: error: cannot access NodeListener
mostCurrent._dl.Initialize(processBA,"DL");
               ^
  class file for com.google.android.gms.wearable.NodeApi$NodeListener not found

You don't get any compile errors anymore at all?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You don't get any compile errors anymore at all?
No. But i was not using any Datalayer. I just added
B4X:
#AdditionalJar: com.android.support:collections
to my active Project i am working on and tried to solved the missing Mavens. Using Android 28 SDK i was able to compile.
class file for com.google.android.gms.wearable.NodeApi$NodeListener not found
I think barx lib may need an update as the NodeListener is depreciated
Looks like you are right.

public interface NodeApi
This interface was deprecated.

Use NodeClient.

Google Docs
 
Upvote 0

jimmyF

Active Member
Licensed User
Longtime User
I had the same issue.
You need to search in the sdk manager for the
"Android SDK Platform 28 (Android 28) version: 6"
It does not get installed automatically.
Then you will have the android.jar version-28
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
and a couple of beers will be on your way ;)
I don´t trink alcohol but thanks anyway; i´ll use your donation on my next Cinema-Day and buy me some Popcorn and a Coke Zero :)

THANK YOU! ;-)

Again: It was a pleasure to help.

At least it pointed out that we all need to switch to Android 28 Jar. In the meantime 28 and all the Components are added to the suggested Itemlist and users using the SDK Manager will get Api 28 per default now.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
I give up after more of a week struggling to make this lib. As this is just for a personal project, I'm going to write it in Android Studio. But still, thanks for all the help!

EDIT: I've got a pointer from Erel which may be able for me to continue (#Extends, of which I was unaware this was possible)
 
Last edited:
Upvote 0
Top