Lord Kelvin
Newbie
Hi to all the community. My name is Mario and I am really a newbie of Android. I am trying to move my first steps through it because I need to build an app. Just a simple calculator. From there I would like to learn more and more with the help of the community.
I am using as a "learning" code, from stackoverflow.
I tried it on a win7 computer with the following configuration and no error was given:
Android Studio 3.1.3
Build #AI-173.4819257, built on June 4, 2018
JRE: 1.8.0_152-release-1024-b02 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 7
I am now in need to run it on my computer with win10, same configuration:
Android Studio 3.1.3
Build #AI-173.4819257, built on June 4, 2018
JRE: 1.8.0_152-release-1024-b02 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
I am having the following problem after the build: Unexpected metadata type found.
The error is with every code, even the very first one it appears on Android Studio as soon as you install it.
I guess there is something wrong outside the code itself. I have looked online and I did not find anything to help so I am really asking help guys.
I really need to put my head down and learn how to do a simple Android app, so I would really appreciate any sort of help/advice that I will receive from the community.
Many thanks to everyone that will be able to help.
Mario
I am using as a "learning" code, from stackoverflow.
I tried it on a win7 computer with the following configuration and no error was given:
Android Studio 3.1.3
Build #AI-173.4819257, built on June 4, 2018
JRE: 1.8.0_152-release-1024-b02 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 7
I am now in need to run it on my computer with win10, same configuration:
Android Studio 3.1.3
Build #AI-173.4819257, built on June 4, 2018
JRE: 1.8.0_152-release-1024-b02 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
I am having the following problem after the build: Unexpected metadata type found.
The error is with every code, even the very first one it appears on Android Studio as soon as you install it.
I guess there is something wrong outside the code itself. I have looked online and I did not find anything to help so I am really asking help guys.
Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
tools:context="com.stackoverflow.mario.MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="97dp"
android:text="Ratio"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="@dimen/abc_action_bar_default_height_material" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:layout_marginLeft="20dp"
android:layout_marginTop="43dp"
android:text="Number One"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/txtNumber1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView2"
android:layout_alignRight="@+id/textView1"
android:ems="2"
android:singleLine="true"
android:inputType="numberDecimal" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_below="@+id/textView2"
android:layout_marginTop="47dp"
android:text="Number Two"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/btnAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView3"
android:layout_alignRight="@+id/textView3"
android:layout_below="@+id/textView3"
android:layout_marginTop="46dp"
android:onClick="onClick"
android:text="Divide" />
<EditText
android:id="@+id/txtNumber2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/btnAdd"
android:layout_alignLeft="@+id/txtNumber1"
android:ems="2"
android:singleLine="true"
android:inputType="numberDecimal" />
<TextView
android:id="@+id/txtResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/txtNumber2"
android:layout_alignTop="@+id/btnAdd"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
Code:
package com.stackoverflow.mario;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
EditText firstNumber;
EditText secondNumber;
TextView addResult;
Button btnAdd;
double num1,num2,ratio;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
firstNumber = (EditText)findViewById(R.id.txtNumber1);
secondNumber = (EditText)findViewById(R.id.txtNumber2);
addResult = (TextView)findViewById(R.id.txtResult);
btnAdd = (Button)findViewById(R.id.btnAdd);
btnAdd.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
num1 = Double.parseDouble(firstNumber.getText().toString());
num2 = Double.parseDouble(secondNumber.getText().toString());
ratio = num1 / num2;
addResult.setText(Double.toString(ratio));
}
});
}
}
I really need to put my head down and learn how to do a simple Android app, so I would really appreciate any sort of help/advice that I will receive from the community.
Many thanks to everyone that will be able to help.
Mario



