Skip to content Skip to sidebar Skip to footer

Android Custom View Classnotfound

I'm sure this is a stupid question but I just can't find an answer anywhere. I'm trying to create a custom View XML element in Android (using Xamarin, so it's technically C#, alth

Solution 1:

com.example.customviews.charting is the package your custom view lives in, so com.example.customviews.charting.PieChart is the class PieChart in the package com.example.customviews.charting.

If you don't actually have the class PieChart in com.example.customviews.charting you will get your ClassNotFoundException.

In your custom view class file look for this line of code to know what package you are in:

package com.mypackage;

If it's not there you're in the default package and I would suggest adding it to make life easier.

Your class should be something like this

package com.mypackage;
publicclassPieChartextendsView {
    ...Your Implementation of PieChart goes here...
}

Solution 2:

When you use a custom view in an XML layout, you use the fully qualified class name (which includes the package name). Use the package name where your custom View class resides.

Post a Comment for "Android Custom View Classnotfound"