Android Question BoxInsetLayout needed

Peter Simpson

Expert
Licensed User
Longtime User
Google's guidelines say the following.

Important: To ensure a great user experience, apps for wearables must meet specific requirements for usability. Only apps that meet the following quality criteria will qualify as an Android Wear app on Google Play. Qualifying as a Wear app will make it easier for Android Wear users to discover your app on Google Play.

So I have a wear app that is on the wear store but it can only be found if you type in its exact name (or just one key word). I've already read about this and I believe that my app isn't showing up automatically on the main search results because I'm not using a 'BoxInsetLayout' which I previously read about in Android Wear design layouts. I've been on the Android developers forum and it does appears that using 'BoxInsetLayout' greatly improves the chances of an app automatically showing up on wear store searches without using the exact unique name of the watch face design. I'm not sure how this would work in B4A but I just need some feedback and with with it, if possible

I've actually created two watch faces (2 separate apps) for the play store, but I've only uploaded one onto the wear store. If I can get that one to show up in when searching for 'Watch Faces' I'll gladly upload the second app too, but until then the second APK file will stay on my laptop.

I need help with the BoxInsertLayout or THIS LOT which also includes WearableRecyclerView.

Any help would be greatly appreciated.

Enjoy...
 
Last edited:

Peter Simpson

Expert
Licensed User
Longtime User
Hello,
Thank you for the reply @Erel, I've not noticed the layoutbuilder before, then again I've never had to use it before.

Okay I've created a simple xml layout, I've added a panel and made the file read only read only.
B4X:
<android.support.wear.widget.BoxInsetLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/lib-auto"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:padding="15dp">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="5dp"
        app:boxedEdges="all">

        <Panel
            android:id="@+id/PnlMain"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
        </Panel>
    </FrameLayout>
</android.support.wear.widget.BoxInsetLayout>
Please note that I changed the above line from xmlns:app="http://schemas.android.com/apk/res-auto" to
xmlns:app="http://schemas.android.com/apk/lib-auto". I was getting an error and developers onstackoverflow.com said use the latter, no more compilation errors.

In the activity I've added the following lines to Activity_Create.
B4X:
'Builder
    Dim x As XmlLayoutBuilder
    x.LoadXmlLayout(Activity, "settings") 'load the layout

There are more lines but when I try to load the activity it crashes on the LoadXmlLayout line with the following error in the logs.

B4X:
** Activity (configuration) Create, isFirst = true **
Error occurred on line: 35 (Configuration)
android.view.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class android.support.wear.widget.BoxInsetLayout
Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.support.wear.widget.BoxInsetLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.wear.widget.BoxInsetLayout" on path: DexPathList[[zip file "/data/app/com.example.test-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.test-1/lib/x86, /system/lib, /vendor/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at android.view.LayoutInflater.createView(LayoutInflater.java:609)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
    at anywheresoftware.b4a.object.XmlLayoutBuilder.LoadXmlLayout(XmlLayoutBuilder.java:49)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:755)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:345)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at com.simplysoftware.tixwatchface.configuration.afterFirstLayout(configuration.java:102)
    at com.simplysoftware.tixwatchface.configuration.access$000(configuration.java:17)
    at com.simplysoftware.tixwatchface.configuration$WaitForLayout.run(configuration.java:80)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

It obviously relates to Didn't find class "android.support.wear.widget.BoxInsetLayout" but no matter what I do I cant get this to work. I tried referencing to com.android.support:wear but nothing is working for me...

Thank you...
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Okay I've created a simple xml layout, I've added a panel and made the file read only read only.
You can use the relatively new CreateResource method to add this XML directly with the manifest editor:
B4X:
CreateResource(layout, settings.xml, 
layout here............

)

Add this line:
B4X:
#AdditionalJar: com.android.support:wearable
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Thank you for that @Erel.
I'm going to knock this on it's head or now as it's becoming extremely annoying and all I wanted to do was share my faces with others. The app is on the store but it needs the BoxInsertLayout sorting out (apparently), I might get back to it at a later date, might.

Well I've learned about the XmlLayoutBuilder today which I never knew existed. I still might release my second app on the wear store though as it fits perfect on all the AVD that I've set up like the current app does too, I'll have to wait and see what sort of mood I'll be in in the future.

BTW where did you get com.android.support:wearable from, all I found on the net was com.android.support:wear? com.android.support:wearable didn't throw up any errors unlike com.android.support:wear.

No matter what I do, I keep getting the error above, error inflating class............

Thank you anyway...
 
Last edited:
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Do you still get the ClassNotFoundException?

Good morning Erel.

I've just put the code back in again to create the error, as I had taken it out, so thank you again for continuing with this issue.

I keep getting Error inflating class 'android.support.wear.widget.BoxInsetLayout' error and also Didn't find class 'android.support.wear.widget.BoxInsetLayout' error.
Logs
B4X:
** Activity (configuration) Create, isFirst = true **
Error occurred on line: 35 (Configuration)
android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.wear.widget.BoxInsetLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.wear.widget.BoxInsetLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.wear.widget.BoxInsetLayout" on path: DexPathList[[zip file "/data/app/com.simplysoftware.tixwatchface-2/base.apk"],nativeLibraryDirectories=[/data/app/com.simplysoftware.tixwatchface-2/lib/x86, /system/lib, /vendor/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at android.view.LayoutInflater.createView(LayoutInflater.java:609)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
    at anywheresoftware.b4a.object.XmlLayoutBuilder.LoadXmlLayout(XmlLayoutBuilder.java:49)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:755)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:345)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at com.simplysoftware.tixwatchface.configuration.afterFirstLayout(configuration.java:102)
    at com.simplysoftware.tixwatchface.configuration.access$000(configuration.java:17)
    at com.simplysoftware.tixwatchface.configuration$WaitForLayout.run(configuration.java:80)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

There was a small error in the xml file, but I fixed that and the xml file should now be correct.
XML File
B4X:
<?xml version="1.0" encoding="utf-8"?>
<android.support.wear.widget.BoxInsetLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/lib-auto"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:padding="15dp">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="5dp"
        app:boxedEdges="all">

        <Panel
            android:id="@+id/PnlMain"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </FrameLayout>
</android.support.wear.widget.BoxInsetLayout>

The line it crashed on is this 'XLB.LoadXmlLayout'
Activity
B4X:
'This is all I've put in the Activity.
    Dim XLB As XmlLayoutBuilder
    'load the layout
    XLB.LoadXmlLayout(Activity, "settings") 'CRASHES ON THIS LINE
    'get a view based on the id
    PnlMain = XLB.GetView("PnlMain")

Sorry for repeating the code above, but I fixed an error in my xml files and wanted to make sure that everything how I have it currently before creating this post.

I keep finding myself going round and round in circles and getting the exact same errors.

Thank you..
 
Last edited:
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
The correct declaration is:
B4X:
#AdditionalJar: com.android.support:wear

If it doesn't work for you then you will need to wait for the next update of B4A which adds support for accessing Google's online repository (https://www.b4x.com/android/forum/t...r-play-services-and-support-repository.83019/)

Hello @Erel,
That's why I asked you previously where you got #AdditionalJar: com.android.support:wearable from, as #AdditionalJar: com.android.support:wear brings up the following warning Maven artifact not found: com.android.support/wear, I previously tried it.

Well I'm down as a beta tester so that will be the very first thing that I'll be testing.

Thanks again for the support Erel.
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
BoxInsetLayout appears to be working perfect in B4A beta now @Erel,
#AdditionalJar: com.android.support:wear is now working and I'm getting no errors whatsoever. All I did was un-comment the previous code and clicked on Run, it all worked first time of asking :)


Thank you
 
Upvote 0
Top