尝试将用户信息上传到数据库时,为什么会出现“AndroidRuntime:FATAL EXCEPTION:main”错误

So I've followed an online tutorial on creating a simple android login interface in which user data is uploaded to a MySQL database upon registration using Android Studio. Now, when I run my app using an AVD and I click the registration button the log on Android Studio shows the following error: "FATAL EXCEPTION: main" followed by several "could not find class" errors. I suspect there is some issue in the connection between the device and the database but I cannot figure out where that is. I've included the projects java, xml and php files below. My end goal is to have a registration screen which accepts the user data, stores it to the database then goes back to the login screen. Also not that here I have intentionally left out info regarding the database name and password but these are included in the actual php files.

Thanks in advance


Logcat

08-17 14:07:02.638 2570-2570/com.example.alibasmaci.maral E/AndroidRuntime: FATAL EXCEPTION: main
                                                                            Process: com.example.alibasmaci.maral, PID: 2570
                                                                            java.lang.NumberFormatException: Invalid int: ""
                                                                                at java.lang.Integer.invalidInt(Integer.java:137)
                                                                                at java.lang.Integer.parseInt(Integer.java:358)
                                                                                at java.lang.Integer.parseInt(Integer.java:331)
                                                                                at com.example.alibasmaci.maral.RegisterActivity$2.onClick(RegisterActivity.java:49)
                                                                                at android.view.View.performClick(View.java:4438)
                                                                                at android.view.View$PerformClick.run(View.java:18422)
                                                                                at android.os.Handler.handleCallback(Handler.java:733)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                at android.os.Looper.loop(Looper.java:136)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5017)
                                                                                at java.lang.reflect.Method.invokeNative(Native Method)
                                                                                at java.lang.reflect.Method.invoke(Method.java:515)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                                                                                at dalvik.system.NativeStart.main(Native Method)
08-17 14:07:06.958 4412-4412/com.example.alibasmaci.maral E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.alibasmaci.maral.RegisterActivity.access$super
08-17 14:07:06.968 4412-4412/com.example.alibasmaci.maral E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.alibasmaci.maral.RegisterActivity.access$super
08-17 14:07:06.968 4412-4412/com.example.alibasmaci.maral E/dalvikvm: Could not find class 'android.media.session.MediaController', referenced from method com.example.alibasmaci.maral.RegisterActivity.access$super
08-17 14:07:06.968 4412-4412/com.example.alibasmaci.maral E/dalvikvm: Could not find class 'android.widget.Toolbar', referenced from method com.example.alibasmaci.maral.RegisterActivity.access$super
08-17 14:07:06.968 4412-4412/com.example.alibasmaci.maral E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method com.example.alibasmaci.maral.RegisterActivity.access$super
08-17 14:07:06.968 4412-4412/com.example.alibasmaci.maral E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.example.alibasmaci.maral.RegisterActivity.access$super

RegisterActivity.java

package com.example.alibasmaci.maral;

import android.content.Intent;
import android.media.Image;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;

import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.toolbox.Volley;

import org.json.JSONException;
import org.json.JSONObject;

public class RegisterActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);

        final EditText etAge = (EditText) findViewById(R.id.etAge);
        final EditText etName = (EditText) findViewById(R.id.etName);
        final EditText etUsername = (EditText) findViewById(R.id.etUsername);
        final EditText etPassword = (EditText) findViewById(R.id.etPassword);
        final ImageButton ibRegister = (ImageButton) findViewById(R.id.ibRegister);
        final ImageButton ibBack = (ImageButton) findViewById(R.id.ibBack);

        ibBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent registerIntent = new Intent(RegisterActivity.this,LoginActivity.class);
                RegisterActivity.this.startActivity(registerIntent);
            }
        });



        ibRegister.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                final String name = etName.getText().toString();
                final String username = etUsername.getText().toString();
                final String password = etPassword.getText().toString();
                final int age = Integer.parseInt(etAge.getText().toString());

                Response.Listener<String> responseListener = new Response.Listener<String>(){

                    @Override
                    public void onResponse(String response) {
                        try {
                            JSONObject jsonResponse = new JSONObject(response);
                            boolean success = jsonResponse.getBoolean("success");
                            if (success) {
                                Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
                                RegisterActivity.this.startActivity(intent);
                            }else{
                                AlertDialog.Builder builder = new AlertDialog.Builder(RegisterActivity.this);
                                builder.setMessage("Register Failed")
                                        .setNegativeButton("Rety", null)
                                        .create()
                                        .show();
                            }
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                    }
                };


                RegisterRequest registerRequest = new RegisterRequest(name,username,age,password,responseListener);
                RequestQueue queue = Volley.newRequestQueue(RegisterActivity.this);
                queue.add(registerRequest);
            }
        });

    }
}

LoginActivity.java

package com.example.alibasmaci.maral;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;

public class LoginActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        final EditText etUsername = (EditText) findViewById(R.id.etUsername);
        final EditText etPassword = (EditText) findViewById(R.id.etPassword);
        final ImageButton ibLogin = (ImageButton) findViewById(R.id.ibLogin);
        final TextView registerLink = (TextView) findViewById(R.id.tvRegister);

        registerLink.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent registerIntent = new Intent(LoginActivity.this,RegisterActivity.class);
                LoginActivity.this.startActivity(registerIntent);
            }
        });

    }
}

RegisterRequest.java

package com.example.alibasmaci.maral;

import com.android.volley.Request;

import java.util.HashMap;
import java.util.Map;
import com.android.volley.Response;
import com.android.volley.toolbox.StringRequest;

/**
 * Created by Ali Basmaci on 2016-08-17.
 */
public class RegisterRequest extends StringRequest {

    private static final String REGISTER_REQUEST_URL = "[URL]";

    private Map<String, String> params;

    public RegisterRequest(String name, String username, int age, String password, Response.Listener<String> listener){
        super(Request.Method.POST, REGISTER_REQUEST_URL, listener,null);
        params = new HashMap<>();
        params.put("name", name);
        params.put("username", username);
        params.put("password", password);
        params.put("age", age + "");

    }

    @Override
    public Map<String, String> getParams() {
        return params;
    }
}

** Register.php**

 <?php
     require("password.php");

     $connect = mysqli_connect("host", "user", "pass", "db");

    $name = $_POST["name"];
    $age = $_POST["age"];
    $username = $_POST["username"];
    $password = $_POST["password"];


     function registerUser() {
        global $connect, $name, $age, $username, $password;
        $statement = mysqli_prepare($connect, "INSERT INTO user (name, age, username, password) VALUES (?, ?, ?, ?)");
        mysqli_stmt_bind_param($statement, "siss", $name, $age, $username, $passwordHash);
        mysqli_stmt_execute($statement);
        mysqli_stmt_close($statement);     
    }
    function usernameAvailable() {
        global $connect, $username;
        $statement = mysqli_prepare($connect, "SELECT * FROM user WHERE username = ?"); 
        mysqli_stmt_bind_param($statement, "s", $username);
        mysqli_stmt_execute($statement);
        mysqli_stmt_store_result($statement);
        $count = mysqli_stmt_num_rows($statement);
        mysqli_stmt_close($statement); 
        if ($count < 1){
            return true; 
        }else {
            return false; 
        }
    }
    $response = array();
    $response["success"] = false;  
    if (usernameAvailable()){
        registerUser();
        $response["success"] = true;  
    }

    echo json_encode($response);
?>

Login.php

<?php
     $connect = mysqli_connect("hust", "user", "pass", "db");

    $username = $_POST["username"];
    $password = $_POST["password"];

    $statement = mysqli_prepare($con, "SELECT * FROM user WHERE username = ?");
    mysqli_stmt_bind_param($statement, "s", $username);
    mysqli_stmt_execute($statement);
    mysqli_stmt_store_result($statement);
    mysqli_stmt_bind_result($statement, $colUserID, $colName, $colUsername, $colAge, $colPassword);

    $response = array();
    $response["success"] = false;  

    while(mysqli_stmt_fetch($statement)){
        if (password_verify($password, $colPassword)) {
            $response["success"] = true;  
            $response["name"] = $colName;
            $response["age"] = $colAge;
        }
    }
    echo json_encode($response);
?>