Could not execute method for android:onClick - Parsing String to Double
<p>I'm trying to create a Android app but I'm getting an error when clicking a button.</p>

<p>What I'm trying to do is convert a String to a double. I can't use the text field as a number, because I'm working with latitude and longitude, so I need negative numbers, and type="number" doesn't allow that.</p>

<p>This is the function that I execute:</p>

<pre><code>public void insertSite(View view) {
    String type = ((AutoCompleteTextView)findViewById(R.id.type)).getText().toString();
    String address = ((AutoCompleteTextView)findViewById(R.id.address)).getText().toString();
    String city = ((AutoCompleteTextView)findViewById(R.id.city)).getText().toString();
    String district = ((AutoCompleteTextView)findViewById(R.id.district)).getText().toString();
    String cep = ((AutoCompleteTextView)findViewById(R.id.cep)).getText().toString();
    String state = ((AutoCompleteTextView)findViewById(R.id.state)).getText().toString();
    double latitude = Double.parseDouble(((EditText)findViewById(R.id.latitude)).getText().toString());
    double longitude = Double.parseDouble(((AutoCompleteTextView)findViewById(R.id.longitude)).getText().toString());
    double altitude = Double.parseDouble(((AutoCompleteTextView)findViewById(R.id.altitude)).getText().toString());
    try {
        VivoDbDAO dao = new VivoDbDAO(this);
        dao.insertSite(
                type,
                address,
                city,
                district,
                state,
                cep,
                latitude,
                longitude,
                altitude);
        Toast.makeText(this, "Site 1 inserido", Toast.LENGTH_SHORT).show();
        Intent intent = new Intent(this, CadastroImovel2Activity.class);
        startActivity(intent);
        finish();
    } catch (Exception e) {
        Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
    }
}
</code></pre>

<p>And here is the layout:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/cadastroImovel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha=".9"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.thiago.muitogelo.CadastroActivity"
&gt;

&lt;android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay"&gt;

    &lt;android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="65dp"
        android:background="?attr/colorPrimary"
        android:backgroundTint="@color/roxoVivo"
        app:popupTheme="@style/AppTheme.PopupOverlay"
        app:title="Dr. Antena" /&gt;

&lt;/android.support.design.widget.AppBarLayout&gt;

&lt;Space
    android:layout_width="wrap_content"
    android:layout_height="40dp" /&gt;

&lt;ScrollView
    android:layout_width="300dp"
    android:layout_height="350dp"
    android:layout_gravity="center"&gt;

    &lt;LinearLayout
        android:layout_width="300dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:padding="10dp"&gt;

        &lt;AutoCompleteTextView
            android:id="@+id/type"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/text_field"
            android:elevation="5dp"
            android:paddingBottom="10dp"
            android:paddingLeft="20dp"
            android:paddingTop="10dp"
            android:hint="Prédio ou Térreo?"
            android:textColor="@color/roxoEscuro" /&gt;

        &lt;Space
            android:layout_width="match_parent"
            android:layout_height="10dp" /&gt;

        &lt;AutoCompleteTextView
            android:id="@+id/address"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/text_field"
            android:elevation="5dp"
            android:paddingBottom="10dp"
            android:paddingLeft="20dp"
            android:paddingTop="10dp"
            android:hint="Endereço"
            android:textColor="@color/roxoEscuro" /&gt;

        &lt;Space
            android:layout_width="match_parent"
            android:layout_height="10dp" /&gt;

        &lt;AutoCompleteTextView
            android:id="@+id/city"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/text_field"
            android:elevation="5dp"
            android:inputType="phone"
            android:paddingBottom="10dp"
            android:paddingLeft="20dp"
            android:paddingTop="10dp"
            android:hint="Cidade"
            android:textColor="@color/roxoEscuro" /&gt;

        &lt;Space
            android:layout_width="match_parent"
            android:layout_height="10dp" /&gt;

        &lt;AutoCompleteTextView
            android:id="@+id/district"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/text_field"
            android:elevation="5dp"
            android:inputType="text"
            android:paddingBottom="10dp"
            android:paddingLeft="20dp"
            android:paddingTop="10dp"
            android:hint="Bairro"
            android:textColor="@color/roxoEscuro" /&gt;

        &lt;Space
            android:layout_width="match_parent"
            android:layout_height="10dp" /&gt;

        &lt;AutoCompleteTextView
            android:id="@+id/state"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/text_field"
            android:elevation="5dp"
            android:inputType="text"
            android:paddingBottom="10dp"
            android:paddingLeft="20dp"
            android:paddingTop="10dp"
            android:hint="Estado"
            android:textColor="@color/roxoEscuro" /&gt;

        &lt;Space
            android:layout_width="match_parent"
            android:layout_height="10dp" /&gt;

        &lt;AutoCompleteTextView
            android:id="@+id/cep"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/text_field"
            android:elevation="5dp"
            android:inputType="number"
            android:paddingBottom="10dp"
            android:paddingLeft="20dp"
            android:paddingTop="10dp"
            android:hint="CEP"
            android:textColor="@color/roxoEscuro" /&gt;

        &lt;Space
            android:layout_width="match_parent"
            android:layout_height="10dp" /&gt;

        &lt;EditText
            android:id="@+id/latitude"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:background="@drawable/button2"
            android:inputType="text"
            android:paddingBottom="10dp"
            android:paddingLeft="20dp"
            android:paddingTop="10dp"
            android:hint="Latitude"
            android:textColor="@color/roxoEscuro" /&gt;

        &lt;Space
            android:layout_width="match_parent"
            android:layout_height="10dp" /&gt;

        &lt;AutoCompleteTextView
            android:id="@+id/longitude"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:background="@drawable/button2"
            android:inputType="text"
            android:hint="Longitude"
            android:paddingBottom="10dp"
            android:paddingLeft="20dp"
            android:paddingTop="10dp"
            android:textColor="@color/roxoEscuro"
            android:clickable="false" /&gt;

        &lt;Space
            android:layout_width="match_parent"
            android:layout_height="10dp" /&gt;

        &lt;AutoCompleteTextView
            android:id="@+id/altitude"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:background="@drawable/button2"
            android:inputType="text"
            android:paddingBottom="10dp"
            android:paddingLeft="20dp"
            android:paddingTop="10dp"
            android:hint="Altitude"
            android:textColor="@color/roxoEscuro"
            android:clickable="false" /&gt;
    &lt;/LinearLayout&gt;
&lt;/ScrollView&gt;

&lt;Space
    android:layout_width="wrap_content"
    android:layout_height="40dp" /&gt;

&lt;LinearLayout
    android:layout_width="300dp"
    android:layout_height="wrap_content"
    android:weightSum="2"
    android:layout_gravity="center"
    android:padding="10dp"&gt;


    &lt;Button
        android:layout_width="250dp"
        android:layout_height="40dp"
        android:layout_gravity="center"
        android:background="@drawable/button2"
        android:text="Próximo"
        android:textColor="@color/roxoEscuro"
        android:id="@+id/btConcluidoCadastro"
        android:onClick="insertSite"
        android:layout_weight="2"/&gt;
&lt;/LinearLayout&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>And here is the log:</p>

<pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
              Process: com.example.thiago.muitogelo, PID: 334
              java.lang.IllegalStateException: Could not execute method for android:onClick
                  at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
                  at android.view.View.performClick(View.java:5716)
                  at android.widget.TextView.performClick(TextView.java:10926)
                  at android.view.View$PerformClick.run(View.java:22596)
                  at android.os.Handler.handleCallback(Handler.java:739)
                  at android.os.Handler.dispatchMessage(Handler.java:95)
                  at android.os.Looper.loop(Looper.java:148)
                  at android.app.ActivityThread.main(ActivityThread.java:7325)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
               Caused by: java.lang.reflect.InvocationTargetException
                  at java.lang.reflect.Method.invoke(Native Method)
                  at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
                  at android.view.View.performClick(View.java:5716) 
                  at android.widget.TextView.performClick(TextView.java:10926) 
                  at android.view.View$PerformClick.run(View.java:22596) 
                  at android.os.Handler.handleCallback(Handler.java:739) 
                  at android.os.Handler.dispatchMessage(Handler.java:95) 
                  at android.os.Looper.loop(Looper.java:148) 
                  at android.app.ActivityThread.main(ActivityThread.java:7325) 
                  at java.lang.reflect.Method.invoke(Native Method) 
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
               Caused by: java.lang.NumberFormatException: Invalid double: ""
                  at java.lang.StringToReal.invalidReal(StringToReal.java:63)
                  at java.lang.StringToReal.parseDouble(StringToReal.java:267)
                  at java.lang.Double.parseDouble(Double.java:301)
                  at com.example.thiago.muitogelo.CadastroImovel1Activity.insertSite(CadastroImovel1Activity.java:30)
                  at java.lang.reflect.Method.invoke(Native Method) 
                  at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) 
                  at android.view.View.performClick(View.java:5716) 
                  at android.widget.TextView.performClick(TextView.java:10926) 
                  at android.view.View$PerformClick.run(View.java:22596) 
                  at android.os.Handler.handleCallback(Handler.java:739) 
                  at android.os.Handler.dispatchMessage(Handler.java:95) 
                  at android.os.Looper.loop(Looper.java:148) 
                  at android.app.ActivityThread.main(ActivityThread.java:7325) 
                  at java.lang.reflect.Method.invoke(Native Method) 
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
</code></pre>