Java Question Error inflating ContraintLayout

beachner

Member
In my ongoing struggle with the MapFactor sdk I'be hit upon yet another problem. This time it appears that the fragment from the sdk holding the map can't render because it can't load the constraintlayout. I have a reference to androidx.constraintlayout:constraintlayout in main and I'm extending from androidx.appcompat.app.AppCompatActivity. Am I missing something obvious here? It feels like it shouldn't be this difficult.

B4ACode:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    #MultiDex: true
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #AdditionalJar: androidx.constraintlayout-core:constraintlayout-core
    #AdditionalJar: androidx.constraintlayout:constraintlayout
    #AdditionalJar: com.google.android.material:material
    #AdditionalJar: androidx.appcompat:appcompat
    #AdditionalJar: androidx.appcompat:appcompat-resources
'    #AdditionalJar: androidx.fragment:fragment
    #AdditionalJar: kotlin-stdlib-1.6.10.jar
'    #AdditionalJar: androidx.compose.ui:ui-viewbinding
'    #AdditionalJar: androidx.fragment:fragment
'    #AdditionalJar:  androidx.collection:collection-ktx
    #AdditionalJar: androidx.arch.core:core-runtime
    #AdditionalJar: androidx.emoji2:emoji2
    #AdditionalJar: androidx.emoji2:emoji2-views-helper
    #AdditionalJar: androidx.emoji2:emoji2-views
    #AdditionalJar: androidx.emoji2:emoji2-bundled

'    #AdditionalJar: androidx.constraintlayout-solver:constraintlayout-solver
'    #AdditionalJar: androidx.constraintlayout:constraintlayout-compose
'   
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
    #Extends: androidx.appcompat.app.AppCompatActivity
#End Region



Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private xui As XUI
    Public mmpfcEngine As MpfcEngineWrapper
    Public rp As RuntimePermissions
    Private NativeMe As JavaObject
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'Private MapView1 As MapView


    Private Panel1 As Panel
    Private MapFragment As MapFragmentWrapper
End Sub

Sub Activity_Create(FirstTime As Boolean)

    If FirstTime Then
        NativeMe.InitializeContext
    End If

    rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)


    Activity.LoadLayout("Layout")   

    
End Sub

Sub Activity_PermissionResult(Permission As String, Result As Boolean)
    If Permission = rp.PERMISSION_ACCESS_FINE_LOCATION And Result = True Then
        Dim ctxt As JavaObject
        ctxt.InitializeContext
        Dim engine As JavaObject
        engine.InitializeNewInstance("com.company.mapfactorwrapper.MpfcEngineWrapper",Null)
        mmpfcEngine = engine
        Dim path = rp.GetAllSafeDirsExternal("")(0) As String
        mmpfcEngine.InitOSM(ctxt,path,mmpfcEngine.ENGLISH_US)
    End If
    
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub onEngineInitStatusChanged_Fire(result As Int)
    If result = mmpfcEngine.SUCCESS Then
        Log("Eninge successfully initated")
    
    Else
        mmpfcEngine.ActivateDevice("<My API key>")
    End If

End Sub

Sub onLocationPermissionNotGranted_Fire(permissionGranted As Boolean)
    xui.MsgboxAsync("Hello world!", "B4X")
End Sub

Sub onActivationResult_Fire(activationResult As Boolean)
    If activationResult = True Then
        xui.MsgboxAsync("Activation successful", "Success")
    Else
        xui.MsgboxAsync("Failed activation ", "Failed")
        End If
End Sub

Sub onMapReady_Fire(ready As Boolean)
    Log("Map ready")
End Sub

Mapwrapper:
import androidx.fragment.app.FragmentTransaction;
import android.view.ViewGroup;
import anywheresoftware.b4a.BA;

@BA.ShortName("MapFragmentWrapper")
public class MapFragmentWrapper {
    
    private MyMapFragment _myMapFragment;

    
    public MapFragmentWrapper(){
        
    }

    

    public void Initialize(androidx.fragment.app.FragmentManager fragmentManager, String eventName, ViewGroup parent){
        
        
        _myFragment = (MyMapFragment) fragmentManager.findFragmentById(parent.getId());
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        if(_myMapFragment!=null){
            transaction.remove(_myMapFragment);
        }
        _myMapFragment = new MyMapFragment();
        
        transaction.add(_myMapFragment, eventName);
        transaction.commit();

    }
}
MyMapFragment:
import com.mapfactor.sdk.map.MapFragment;

import anywheresoftware.b4a.BA.Hide;

@Hide
public class MyMapFragment extends MapFragment{
    

    
}

Exception:
 E  EXCEPTION:
2023-01-23 11:16:34.184 30114-30114 MPFC                    pid-30114                            E  (JAVA) EXCEPTION:
2023-01-23 11:16:34.184 30114-30114 MpfcSDK null            pid-30114                            E    DESCRIPTION: Binary XML file line #2 in b4a.example:layout/fragment_map: Binary XML file line #2 in b4a.example:layout/fragment_map: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
2023-01-23 11:16:34.184 30114-30114 MPFC                    pid-30114                            E  (JAVA)   DESCRIPTION: Binary XML file line #2 in b4a.example:layout/fragment_map: Binary XML file line #2 in b4a.example:layout/fragment_map: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
2023-01-23 11:16:34.184 30114-30114 MpfcSDK null            pid-30114                            E    STACK: android.view.InflateException: Binary XML file line #2 in b4a.example:layout/fragment_map: Binary XML file line #2 in b4a.example:layout/fragment_map: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
                                                                                                    Caused by: android.view.InflateException: Binary XML file line #2 in b4a.example:layout/fragment_map: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
                                                                                                    Caused by: java.lang.reflect.InvocationTargetException
                                                                                                        at java.lang.reflect.Constructor.newInstance0(Native Method)
                                                                                                        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
                                                                                                        at android.view.LayoutInflater.createView(LayoutInflater.java:876)
                                                                                                        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1028)
                                                                                                        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:983)
                                                                                                        at android.view.LayoutInflater.inflate(LayoutInflater.java:669)
                                                                                                        at android.view.LayoutInflater.inflate(LayoutInflater.java:544)
                                                                                                        at l.c.onCreateView(SourceFile:5)
                                                                                                        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3104)
                                                                                                        at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:524)
                                                                                                        at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
                                                                                                        at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1899)
                                                                                                        at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1817)
                                                                                                        at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1760)
                                                                                                        at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:547)
                                                                                                        at android.os.Handler.handleCallback(Handler.java:942)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                        at android.os.Looper.loopOnce(Looper.java:226)
                                                                                                        at android.os.Looper.loop(Looper.java:313)
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:8741)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
                                                                                                    Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/constraintlayout/core/widgets/ConstraintWidgetContainer;
                                                                                                        at androidx.constraintlayout.widget.ConstraintLayout.<init>(ConstraintLayout.java:504)
                                                                                                        at java.lang.reflect.Constructor.newInstance0(Native Method) 
                                                                                                        at java.lang.reflect.Constructor.newInstance(Constructor.java:343) 
                                                                                                        at android.view.LayoutInflater.createView(LayoutInflater.java:876) 
                                                                                                        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1028) 
                                                                                                        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:983) 
                                                                                                        at android.view.LayoutInflater.inflate(LayoutInflater.java:669) 
                                                                                                        at android.view.LayoutInflater.inflate(LayoutInflater.java:544) 
                                                                                                        at l.c.onCreateView(SourceFile:5) 
                                                                                                        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3104) 
                                                                                                        at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:524) 
                                                                                                        at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261) 
                                                                                                        at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1899) 
                                                                                                        at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1817) 
                                                                                                        at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1760) 
                                                                                                        at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:547) 
                                                                                                        at android.os.Handler.handleCallback(Handler.java:942) 
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                                                                        at android.os.Looper.loopOnce(Looper.java:226) 
                                                                                                        at android.os.Looper.loop(Looper.java:313) 
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:8741) 
                                                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) 
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067) 
                                                                                                    Caused by: java.lang.ClassNotFoundException: androidx.constraintlayout.core.widgets.ConstraintWidgetContainer
                                                                                                        at androidx.constraintlayout.widget.ConstraintLayout.<init>(ConstraintLayout.java:504) 
                                                                                                        at java.lang.reflect.Constructor.newInstance0(Native Method) 
                                                                                                        at java.lang.reflect.Constructor.newInstance(Constructor.java:343) 
                                                                                                        at android.view.LayoutInflater.createView(LayoutInflater.java:876) 
                                                                                                        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1028) 
                                                                                                        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:983) 
                                                                                                        at android.view.LayoutInflater.inflate(LayoutInflater.java:669) 
                                                                                                        at android.view.LayoutInflater.inflate(LayoutInflater.java:544) 
                                                                                                        at l.c.onCreateView(SourceFile:5) 
                                                                                                        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3104) 
                                                                                                        at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:524) 
                                                                                                        at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261) 
                                                                                                        at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1899) 
                                                                                                        at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1817) 
                                                                                                        at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1760) 
                                                                                                        at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:547) 
                                                                                                        at android.os.Handler.handleCallback(Handler.java:942) 
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                                                                        at android.os.Looper.loopOnce(Looper.java:226) 
                                                                                                        at android.os.Looper.loop(Looper.java:313) 
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:8741) 
                                                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) 
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067) 
2023-01-23 11:16:34.184 30114-30114 MPFC                    pid-30114                            E  (JAVA)   STACK: android.view.InflateException: Binary XML file line #2 in b4a.example:layout/fragment_map: Binary XML file line #2 in b4a.example:layout/fragment_map: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
                                                                                                    Caused by: android.view.InflateException: Binary XML file line #2 in b4a.example:layout/fragment_map: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
                                                                                                    Caused by: java.lang.reflect.InvocationTargetException
                                                                                                        at java.lang.reflect.Constructor.newInstance0(Native Method)
                                                                                                        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
                                                                                                        at android.view.LayoutInflater.createView(LayoutInflater.java:876)
                                                                                                        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1028)
                                                                                                        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:983)
                                                                                                        at android.view.LayoutInflater.inflate(LayoutInflater.java:669)
                                                                                                        at android.view.LayoutInflater.inflate(LayoutInflater.java:544)
                                                                                                        at l.c.onCreateView(SourceFile:5)
                                                                                                        at androidx.fragment.app.Fragment.perfor
2023-01-23 11:16:34.184 30114-30114 MpfcSDK ERR             pid-30114                            E  Message: Binary XML file line #2 in b4a.example:layout/fragment_map: Binary XML file line #2 in b4a.example:layout/fragment_map: Error inflating class androidx.constraintlayout.widget.ConstraintLayout, Exception: android.view.InflateException: Binary XML file line #2 in b4a.example:layout/fragment_map: Binary XML file line #2 in b4a.example:layout/fragment_map: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
                                                                                                    Caused by:
                                                                                                    
                                                                                                    android.view.InflateException: Binary XML file line #2 in b4a.example:layout/fragment_map: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
                                                                                                    Caused by:
                                                                                                    
                                                                                                    java.lang.reflect.InvocationTargetException
                                                                                                        at java.lang.reflect.Constructor.newInstance0(Native Method)
                                                                                                    Caused by:
                                                                                                    
                                                                                                    java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/constraintlayout/core/widgets/ConstraintWidgetContainer;
                                                                                                        at androidx.constraintlayout.widget.ConstraintLayout.<init>(ConstraintLayout.java:504)
                                                                                                    Caused by:
                                                                                                    
                                                                                                    java.lang.ClassNotFoundException: androidx.constraintlayout.core.widgets.ConstraintWidgetContainer
                                                                                                        at androidx.constraintlayout.widget.ConstraintLayout.<init>(ConstraintLayout.java:504)
2023-01-23 11:16:34.184 30114-30114 MPFC                    pid-30114                            E  (JAVA ERR) Message: Binary XML file line #2 in b4a.example:layout/fragment_map: Binary XML file line #2 in b4a.example:layout/fragment_map: Error inflating class androidx.constraintlayout.widget.ConstraintLayout, Exception: android.view.InflateException: Binary XML file line #2 in b4a.example:layout/fragment_map: Binary XML file line #2 in b4a.example:layout/fragment_map: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
                                                                                                    Caused by:
                                                                                                    
                                                                                                    android.view.InflateException: Binary XML file line #2 in b4a.example:layout/fragment_map: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
                                                                                                    Caused by:
                                                                                                    
                                                                                                    java.lang.reflect.InvocationTargetException
                                                                                                        at java.lang.reflect.Constructor.newInstance0(Native Method)
                                                                                                    Caused by:
                                                                                                    
                                                                                                    java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/constraintlayout/core/widgets/ConstraintWidgetContainer;
                                                                                                        at androidx.constraintlayout.widget.ConstraintLayout.<init>(ConstraintLayout.java:504)
                                                                                                    Caused by:
                                                                                                    
                                                                                                    java.lang.ClassNotFoundException: androidx.con

Any hints or guidance on how I can solve this would be greatly appreciated
 
Top