The affidavit will help get you a dismissal, but it won't secure it.  The prosecutor is free to accept or not accept the affidavit.  They may look at your history and think that you did have knowledge of the marijuana (assuming you have something on your record).  If the prosecutor rejects the affidavit, then you would have to set the case for trial and have the co-defendant come and testify about what was in his affidavit and see if the jury will believe his testimony.