Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialWill Schwarz
2,795 PointsRegister ParseObject before instantiating it
I'm getting this error: java.lang.IllegalArgumentException: You must register this ParseObject subclass before instantiating it.
with code
else {
ParseUser newUser = new ParseUser();
newUser.setUsername(username);
newUser.setPassword(password);
newUser.setEmail(email);
newUser.signUpInBackground(new SignUpCallback() {
logcat says the error is on the ParseUser new User line but my imports are as follows
import com.parse.ParseException;
import com.parse.ParseUser;
import com.parse.SignUpCallback;
I have no idea what I did wrong, I thought I followed the tutorial exactly.
2 Answers
Rahsan Boykin
2,067 Pointsthis might be too late but you must register the application class (with the initialization code) into the manifest file.
As an application NOT activity.
Michael Dvorscak
7,003 PointsSorry, I'm a little late in the response (but I had the same issue).
What caused it for me: playing around with git. I tried doing something experimental, then I rolled back, but it was too far!
How I fixed it:
public class RibbitApplication extends Application {
@Override
public void onCreate(){
super.onCreate();
// Enable Local Datastore.
Parse.enableLocalDatastore(this);
//This is what Parse was complaining about
Parse.initialize(this, "eCRiFz7HFXwf1Z7ehwaw0x8VkYrAwZvCEfl3N5v5", "UYtdHfYM4C7Td5m0bqwvmIRCjcTOIHPmcCn4DrdW");
}
}
But more importantly! You need to also update your manifest like Rashan said.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:name=".RibbitApplication">
<!-- name attribute is the important one (just above this line) -->
<!-- rest of the manifest as normal -->
Farouk Charkas
1,957 PointsThe adding the Java Class as Application worked for me
Piara Sandhu
4,626 PointsPiara Sandhu
4,626 PointsThis totally worked!