Android Question Data at the root level is invalid. Line 1, position 1

jkhazraji

Active Member
Licensed User
Longtime User
I am trying to run the AppCompat library example found here. I get this error: Data at the root level is invalid. Line 1, position 1. as I load the project or run it. I have my android sdk installed as it was mentioned in the tutorial, i.e,
-Android SDK Build-tools : 25.0.3
-Android Support Repository: 41
-Android support library : 23.2.1
The error is displayed as a message box :
 

Attachments

  • Err.png
    Err.png
    16.6 KB · Views: 282

jkhazraji

Active Member
Licensed User
Longtime User
B4X:
#Region  Project Attributes 
    #ApplicationLabel: AppCompat Basics
    #VersionCode: 2
    #VersionName: 3.20
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

'#Extends: android.support.v7.app.AppCompatActivity

#Region  Activity Attributes 
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private ScrollView1 As ScrollView
    Private ACSwitch1 As ACSwitch
    Private ACActionMenu1 As ACActionMenu
    Private ACSubmenu1 As ACSubMenu
    Private ACButton3 As ACButton
    Private Panel6 As Panel
    Private ACSpinner1 As ACSpinner
    Private ACSpinner2 As ACSpinner

    Private sv As ACSearchView
    Private si As ACMenuItem
End Sub

'Inline Java code to initialize the Menu
#If Java
    public boolean _onCreateOptionsMenu(android.view.Menu menu) {
        if (processBA.subExists("activity_createmenu")) {
            processBA.raiseEvent2(null, true, "activity_createmenu", false, new de.amberhome.objects.appcompat.ACMenuWrapper(menu));
            return true;
        }
        else
            return false;
    }
#End If

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("layout1")
   
    ScrollView1.Panel.LoadLayout("lay_scrollview")
    ScrollView1.Panel.Height = Panel6.Top + Panel6.Height + 8dip
   
    ACSpinner1.AddAll(Array As String ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"))
    ACSpinner2.AddAll(Array As String ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"))

    'Ad some Action Menu items
    ACActionMenu1.Menu.Add(1, 1, "Menu1", Null)
    ACSubmenu1 = ACActionMenu1.Menu.AddSubMenu(1, 2, 2, "Submenu")
    ACSubmenu1.Add(101, 1, "Submenu Item 1", Null)
    ACSubmenu1.Add(102, 2, "Submenu Item 2", Null)
    ACActionMenu1.Menu.Add(3, 3, "MenuItem 2", Null)
   
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

'This is the Sub called by the inline Java code to initialize the Menu
Sub Activity_CreateMenu(Menu As ACMenu)
    sv.Initialize2("Search", sv.THEME_DARK)
    sv.IconifiedByDefault = True

    'Clear the menu
    Menu.Clear
   
    'Add a menu item and assign the SearchView to it
    si = Menu.Add2(1, 1, "Search", Null)
    si.SearchView = sv
End Sub

'If the user submits a search then this event sub is called
Sub Search_QuerySubmitted (Query As String)

    sv.Iconfied = True
    si.ItemCollapsed = True
   
    Log("Search for '" & Query & "'")
End Sub

Sub Search_Closed
    Log("SearchView closed")
End Sub

Sub Search_QueryChanged (Query As String)
    Log("Query changed: " & Query)
End Sub

Sub ACButton1_Click
    Log("Button1 Click event fired")
End Sub

Sub ACCheckBox1_CheckedChange(Checked As Boolean)
    Log("Checkbox changed")
End Sub

Sub ACActionMenu1_MenuItemClick (Item As ACMenuItem)
    Log("Menu Item Clicked: " & Item.Id & " - " & Item.Title)
End Sub

Sub SeekBar1_ValueChanged (Value As Int, UserChanged As Boolean)
    Log("Seekbar Value: " & Value)
End Sub

Sub ACButton3_Click
    'Open a Popup Menu
    Dim Pop As ACPopupMenu
   
    Pop.Initialize("Popup", ACButton3)
    Pop.AddMenuItem(1, "Menu1", Null)
    Pop.AddMenuItem(2, "Menu2", Null)
   
    Pop.Show
End Sub

Sub Popup_ItemClicked (Item As ACMenuItem)
    Log("Popupmenu Item clicked: " & Item.Id & " - " & Item.Title)
End Sub

Sub ACSpinner1_ItemClick (Position As Int, Value As Object)
    Log("Spinner Item selected: " & Position & " - " & Value)
End Sub
 
Upvote 0

jkhazraji

Active Member
Licensed User
Longtime User
The same error appeared in compilation window :Data at the root level is invalid. Line 1, position 1 and it stopped
 
Upvote 0

jkhazraji

Active Member
Licensed User
Longtime User
This is the project..
 

Attachments

  • project.zip
    11 KB · Views: 197
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
This is the project..
It is working here.... No error.

Compiling runs through all steps. Including installing the app on my device.
The App runs and show a AppCompat example-Activity.

I guess you need to search the problem elsewhere.

Let us start with your SDK-Installation:

Make sure you are using a minimum Android.jar Version 23. Better 25 as of today.

- Can you post a Screenshot from the IDE -> Configure Paths?
- Can you post Screenshots of ALL Installed Packages in the SDK Manager?
 
Upvote 0

jkhazraji

Active Member
Licensed User
Longtime User
Here are the SDK screenshots:
 

Attachments

  • sdk1.jpg
    sdk1.jpg
    126.9 KB · Views: 243
  • sdk2.jpg
    sdk2.jpg
    133.7 KB · Views: 221
  • sdk3.jpg
    sdk3.jpg
    128 KB · Views: 219
  • sdk4.jpg
    sdk4.jpg
    133.5 KB · Views: 228
  • sdk5.jpg
    sdk5.jpg
    110.4 KB · Views: 210
  • sdk6.jpg
    sdk6.jpg
    131.4 KB · Views: 228
Upvote 0
Top