title: GoogleApi's API level 8 Platform 2.2 error when i want instantiate a broadcast receiver that call a service
body: <p>I receive the following error when my android app call my receiver after boot. This problem only happens in Android <strong>GoogleApi's API level 8</strong> Platform 2.2 (this work well in api level 8, level 10 and above).</p>
  
  <pre><code>09-18 05:26:10.421: E/AndroidRuntime(261): FATAL EXCEPTION: main
  09-18 05:26:10.421: E/AndroidRuntime(261): java.lang.RuntimeException: Unable to  instantiate receiver com.adduci.BootReceiver: java.lang.ClassNotFoundException: com.adduci.BootReceiver in loader dalvik.system.PathClassLoader[/data/app/com.adduci-2.apk]
  09-18 05:26:10.421: E/AndroidRuntime(261):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2789)
  09-18 05:26:10.421: E/AndroidRuntime(261):  at android.app.ActivityThread.access$3200(ActivityThread.java:125)
  09-18 05:26:10.421: E/AndroidRuntime(261):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
  09-18 05:26:10.421: E/AndroidRuntime(261):  at android.os.Handler.dispatchMessage(Handler.java:99)
  09-18 05:26:10.421: E/AndroidRuntime(261):  at android.os.Looper.loop(Looper.java:123)
  09-18 05:26:10.421: E/AndroidRuntime(261):  at android.app.ActivityThread.main(ActivityThread.java:4627)
  09-18 05:26:10.421: E/AndroidRuntime(261):  at java.lang.reflect.Method.invokeNative(Native Method)
  09-18 05:26:10.421: E/AndroidRuntime(261):  at java.lang.reflect.Method.invoke(Method.java:521)
  09-18 05:26:10.421: E/AndroidRuntime(261):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  09-18 05:26:10.421: E/AndroidRuntime(261):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  09-18 05:26:10.421: E/AndroidRuntime(261):  at dalvik.system.NativeStart.main(Native Method)
  09-18 05:26:10.421: E/AndroidRuntime(261): Caused by: java.lang.ClassNotFoundException: com.adduci.BootReceiver in loader dalvik.system.PathClassLoader[/data/app/com.adduci-2.apk]
  09-18 05:26:10.421: E/AndroidRuntime(261):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
  09-18 05:26:10.421: E/AndroidRuntime(261):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
  09-18 05:26:10.421: E/AndroidRuntime(261):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
  09-18 05:26:10.421: E/AndroidRuntime(261):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2780)
  09-18 05:26:10.421: E/AndroidRuntime(261):  ... 10 more
  </code></pre>
  
  <p>I clarify that the code works fine, because if I run it on an emulator to run 10 or Api Api 16 works perfectly. The error I repeat, I get it only when I run it on an emulator to run 8 or Google Api Api's platform 2.2 API level 8.
  Thanks!!</p>
  
  <p>My <strong>manifest</strong> file is this:
      
      
      
      
      </p>
  
  <pre><code>&lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
      &lt;activity android:name=".ListPro3Activity"
                android:label="@string/app_name"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;receiver android:name=".MyReceiverAlarmItem"/&gt;
      &lt;activity android:name=".AlarmEventActivity"&gt;
      &lt;/activity&gt;
      &lt;activity android:name=".ShowAlarmMessageActivity"&gt;
      &lt;/activity&gt;
  
     &lt;receiver android:name="com.adduci.BootReceiver"&gt;
         &lt;intent-filter&gt;
             &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
             &lt;category android:name="android.intent.category.HOME" /&gt;
             &lt;!--category android:name="android.intent.category.LAUNCHER" /--&gt;
         &lt;/intent-filter&gt;
     &lt;/receiver&gt;
     &lt;service android:enabled="true" android:name="ConfigAlarmService"&gt;
     &lt;intent-filter&gt;
      &lt;action android:name="com.adduci.ConfigAlarmService"&gt;
      &lt;/action&gt;
      &lt;/intent-filter&gt;
      &lt;/service&gt;
  &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>My <strong>BroadCast</strong> file is this:</p>
  
  <pre><code>package com.adduci;
  
  import com.adduci.Utils;
  
  import java.text.ParseException;
  import java.text.SimpleDateFormat;
  import java.util.ArrayList;
  import java.util.Calendar;
  import java.util.Date;
  import java.util.HashMap;
  
  import android.app.Activity;
  import android.content.BroadcastReceiver;
  import android.content.ComponentName;
  import android.content.ContentValues;
  import android.content.Context;
  import android.content.Intent;
  import android.database.sqlite.SQLiteOpenHelper;
  import android.os.Bundle;
  import android.util.Log;
  import android.widget.Toast;
  
  public class BootReceiver extends BroadcastReceiver  {
  
  public void onReceive(Context context, Intent intent) {
      // TODO Auto-generated method stub
      if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
          Log.v("lp","INICIO BROADCAST Y VOY A LLAMAR AL SERVICE");
          Intent i = new Intent();
          i.setAction("com.adduci.ConfigAlarmService");
          i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          ComponentName service = context.startService(i);
  
          //context.stopService(new Intent(context, service.getClass()));
      }
  }
  }
  </code></pre>
  
  <p>and my <strong>Service</strong> file is this:</p>
  
  <pre><code>package com.adduci;
  
  import java.text.SimpleDateFormat;
  import java.util.ArrayList;
  import java.util.Calendar;
  import java.util.Date;
  import java.util.HashMap;
  import java.text.ParseException;
  
  import android.app.Service;
  import android.content.ContentValues;
  import android.content.Intent;
  import android.database.sqlite.SQLiteOpenHelper;
  import android.os.Bundle;
  import android.os.IBinder;
  import android.util.Log;
  
  public class ConfigAlarmService extends Service{
  private MyAlarm alarm;
  private ArrayList&lt;HashMap&lt;String,Object&gt;&gt; columns;
  private ArrayList&lt;Datos&gt; datos;
  
  @Override
  public void onCreate(){
      Log.v("lp","SERVICE ONCREATE!!!");
  }
  
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) 
  {
      // We want this service to continue running until it is explicitly
      // stopped, so return sticky.
      Log.v("lp","StartAtBootService -- onStartCommand()");           
      ....
      ....
      String cols="[" +
                  "{'content':'itemId'," +
                  "'SQLiteType':'Int'}," +
                  "{'content':'itemDescripcion'," +
                  "'SQLiteType':'String'}," +
                  "{'content':'recordatorio'," +
                  "'SQLiteType':'Int'}," +
                  "{'content':'recordatorioFecha'," +
                  "'SQLiteType':'String'}" +
                  "]";
      this.columns = Utils.jsonToArray(cols);
  
      Log.v("lp","OPENHELPER");       
      SQLiteOpenHelper sqLiteOpenHelper=new ListProSQLiteHelper(this, "DBListPro", null, 1);
      Log.v("lp","FIN OPENHELPER!!!");
      this.load("SELECT * FROM items WHERE recordatorio=1", sqLiteOpenHelper);
      this.stopSelf();
      return START_STICKY;
  }
  
  @Override
  public IBinder onBind(Intent intent) {
      // TODO Auto-generated method stub
      return null;
  }
  
  public void onDestroy(){
      super.onDestroy();
      Log.v("lp","CONFIGALARMSERVICE DESTROY!!");
  }
  
  private void load(String sqlCondition, SQLiteOpenHelper sqLiteOpenHelper){
      this.datos = new ArrayList&lt;Datos&gt;();
      Object[]sql={sqlCondition, sqLiteOpenHelper};
      DataFromSqlite dataSqlite=new DataFromSqlite(this, this.getColumns(), sql, DataFromSqlite.ASYNCHRO, DataFromSqlite.DIALOG_WHEEL_OFF){
  
          @Override
          void onPreExecuteEvent() {
              // TODO Auto-generated method stub
          }
  
          @Override
          void onDoInBackGroundEvent() {
              // TODO Auto-generated method stub
          }
  
          @Override
          void onPostExecuteEvent() {
              // TODO Auto-generated method stub
              for(int i=0;i&lt; this.getData().size();i++){
                  ContentValues cv= this.getData().get(i);
                  Datos datoItem=new Datos();
                  for(int j=0; j&lt;this.columns.size();j++){
                      String col=(String)columns.get(j).get("content");
                      datoItem.put(col, cv.get(col));
                  }
                  datos.add(datoItem);
              }
              setAlarms();
          }
      };
  }
  
  private void setAlarms(){
      Log.v("lp","DaToS : "+ this.datos);
      for(int i=0; i&lt; this.datos.size(); i++){
          Datos dat = this.datos.get(i);
          if(Integer.parseInt((String) dat.get("recordatorio")) == 1){
              Bundle bundleReceiver= new Bundle();
              bundleReceiver.putString("NotificationText", (String) dat.get("itemDescripcion"));
              this.alarm= new MyAlarm(this, MyReceiverAlarmItem.class, bundleReceiver);
  
              Date recordatorioFecha= new Date();
              SimpleDateFormat formato= new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
              try {
                  recordatorioFecha= formato.parse((String) dat.get("recordatorioFecha"));
              } catch (ParseException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
              Calendar calendar= Calendar.getInstance();
              calendar.setTime(recordatorioFecha);
  
              if(calendar.getTimeInMillis() &gt; System.currentTimeMillis()){
                  Log.v("lp","DAT:"+dat+"MES:"+String.valueOf(calendar.get(Calendar.MONTH)));
                  this.alarm.setAlarm(Integer.parseInt((String) dat.get("itemId")) , calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE), calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE));
              }
          }   
      }
  }
  
  private ArrayList&lt;HashMap&lt;String,Object&gt;&gt; getColumns(){
      return this.columns;
  }   
  }
  </code></pre>