The following classes couldn't be found -include(fix build path)

2.1k Views Asked by At

I'm trying to build a widget for my flash light app. I'm using android studio. I right clicked layout and chose widget>app widget and it created required files.

here's light_widget_info.xml which i edited

<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
    android:minWidth="40dp"
    android:minHeight="40dp"
    android:updatePeriodMillis="86400000"
    android:previewImage="@drawable/example_appwidget_preview"
    android:initialLayout="@layout/light_widget"
    android:resizeMode="horizontal|vertical"
    android:widgetCategory="home_screen"
    android:initialKeyguardLayout="@layout/light_widget"></appwidget-provider>

I get

 "The following classes couldn't be found
             -include (fix build path)"  

error.

1

There are 1 best solutions below

0
On BEST ANSWER

Create a new folder named xml in res folder, and put the xml file there...

Widget - XML file should be in xml folder It should point to mainActivity which in layout folder(something like res/layout/activity_main.xml)

android:initialLayout="@layout/activity_main"

Also you should declare AppWidgetProvider class in your manifest file as follows

<receiver android:name="ExampleAppWidgetProvider" >

   <intent-filter>
      <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
   </intent-filter>

   <meta-data android:name="android.appwidget.provider"
      android:resource="@xml/example_appwidget_info" />
</receiver>

Here is a step by step example you can refer