[SOLVED] Android - Create an user IllegalArgumentException => key.length == 0

0 votes

Hi there !

I got an error when I try to create an user, here is my code :

public boolean touchDown(InputEvent event, float x, float y, int pointer, int button)
userService.createUser(name.getText(), pwd.getText(), mail.getText(), new App42CallBack() {  
public void onSuccess(Object response)   
   User user = (User)response;  
   System.out.println("userName is " + user.getUserName());  
   System.out.println("emailId is " + user.getEmail());  
   game.setScreen(new Menu(game));
public void onException(Exception ex)   
   System.out.println("Exception Message"+ex.getMessage());  
return false;
and it returns my this error : 
I did use
App42API.initialize(MyGame.context, apiKey, secretKey);
I want to specify that I also use appwarp cloud API & also libgdx. AppWarp was working perfectly with match making and so on. Can somebody help me ?
EDIT : I didn't mention it but when I enter a random word into the mail adress field & push the button I get the message "not a valid mail adress" (or something like this), so all my code is doing well.
Thanks a lot :)
asked Nov 6, 2014 in App42 Cloud API-BaaS by Hugo Lpb (10 points)
edited Nov 8, 2014 by Hugo Lpb

1 Answer

0 votes
Hi ,
This exception occurs when you call the method first and initilize the API Key and Secret Key later. So make sure before called  the method you initilize the App42 service first.
Let us know if it helps.
answered Nov 7, 2014 by naresh (350 points)
I initialized it before :/ Let me show you :
I work with libgdx & I got a Menu Screen. In its constructor the API is intialized. Then by pressing a register button the game switch screen & go to the Register Screen. In this register screen I use the method createUser which cause the problem.
So the API is obviously initialized before...
Thanks for the reply,  If you are using following method, it works fine, in case of user creation on next screen.
App42API.initialize("Application context","apiKey","secretKey");

Adding on it if you are using older structure for initialization
ServiceAPI serviceAPI= new ServiceAPI("apikey","secretKey");

Please let me know the which structure you are currently using in your project.
I solved my problem my Intializing the API in the create function of my main method :) It seems like I was initializing 2 times the API (first when the menu appears at start, then after registering when the menu come back)
Can you please provide the code snippet.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com