1
votes

I'm using Xamarin Forms Prism and I can't use my PCL classes in android project.
common example :
here is the Interface in PCL

namespace BlankApp.Helpers
{
   public interface IToast
   {
      void MakeLongToast(string msg);
   }
}

and here is the class in android project

namespace BlankApp2.Droid.DependencyService
{
   public class ToastImp : IToast
   {
   }
}

it can not find IToast Interface reference !

there is a suggest from IDE with this msg : "Reference 'projectname-WebAppMAinModule' and use 'projectname.Helpers.IToast' "
screenshot

which does nothing actually !
I don't have these kind of problems in XamarinForms I face theme while using Prism . Do I forget something in referencing my PCL ?

I'm using
Prism.Forms (7.0.0.396) Xamarin.Forms (2.5.0.122203)
also there are my project dependencies here

1
What Prism Version are you using - Let Us See some Code. you'll learn quick that stack overflow users do not like screen shot code. its a form of laziness - LeRoy
@LeRoy actually there is no code ! I just have problem accessing PCL classes from android project .I also edited the post ;)) - Mehdi Fathi

1 Answers

0
votes

You should be able to implement PCL interfaces and use its classes, etc. in your platform specific code (Android included).

Use the following steps:

  1. Make sure your Android project is referencing your PCL.

  2. Delete your Android obj & bin folders.

  3. Recompile your PCL

  4. After recompiling your PCL, recompile your Android project

See if it recognizes your interface now.

If the above doesn't work, then as one last option is:

  1. Close the solution
  2. Re-open the solution

Both of these typically work when your project won't recognize a newly created Interface.