I am failing to understand why I am not able to compile the following program. Someone please help.
the main.xml look likeCode:import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.net.Socket; import java.net.UnknownHostException; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class AndroidClient extends Activity { EditText textOut; TextView textIn; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); textOut = (EditText)findViewById(R.id.textout); Button buttonSend = (Button)findViewById(R.id.send); textIn = (TextView)findViewById(R.id.textin); buttonSend.setOnClickListener(buttonSendOnClickListener); } Button.OnClickListener buttonSendOnClickListener = new Button.OnClickListener(){ @Override public void onClick(View arg0) { // TODO Auto-generated method stub Socket socket = null; DataOutputStream dataOutputStream = null; DataInputStream dataInputStream = null; try { socket = new Socket("192.168.1.101", 8888); dataOutputStream = new DataOutputStream(socket.getOutputStream()); dataInputStream = new DataInputStream(socket.getInputStream()); dataOutputStream.writeUTF(textOut.getText().toString()); textIn.setText(dataInputStream.readUTF()); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally{ if (socket != null){ try { socket.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (dataOutputStream != null){ try { dataOutputStream.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (dataInputStream != null){ try { dataInputStream.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }}; }
and the string.xml look likeCode:<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@+string/hello" /> <EditText android:id="@+id/textout" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/send" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Send" /> <TextView android:id="@+id/textin" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout>
and the result of the compile isCode:<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">Main</string> </resources>
alf@ThinkPad-T500:~/Development/android/AndroidClient$ ant debug
Buildfile: /home/alf/Development/android/AndroidClient/build.xml
[setup] Android SDK Tools Revision 10
[setup] Project Target: Android 2.1-update1
[setup] API level: 7
[setup]
[setup] ------------------
[setup] Resolving library dependencies:
[setup] No library dependencies.
[setup]
[setup] ------------------
[setup]
[setup] WARNING: No minSdkVersion value set. Application will install on all Android versions.
[setup]
[setup] Importing rules file: tools/ant/main_rules.xml
-debug-obfuscation-check:
-set-debug-mode:
-compile-tested-if-test:
-pre-build:
-dirs:
[echo] Creating output directories if needed...
-aidl:
[echo] Compiling aidl files into Java classes...
-renderscript:
[echo] Compiling RenderScript files into Java classes and RenderScript bytecode...
-resource-src:
[echo] Generating R.java / Manifest.java from the resources...
-pre-compile:
compile:
[javac] /home/alf/Development/android/android-sdk-linux_x86/tools/ant/main_rules.xml:384: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 2 source files to /home/alf/Development/android/AndroidClient/bin/classes
[javac] /home/alf/Development/android/AndroidClient/src/za/co/stockton/AndroidClient/AndroidClient.java:23: package R does not exist
[javac] setContentView(R.layout.main);
[javac] ^
[javac] /home/alf/Development/android/AndroidClient/src/za/co/stockton/AndroidClient/AndroidClient.java:25: package R does not exist
[javac] textOut = (EditText)findViewById(R.id.textout);
[javac] ^
[javac] /home/alf/Development/android/AndroidClient/src/za/co/stockton/AndroidClient/AndroidClient.java:26: package R does not exist
[javac] Button buttonSend = (Button)findViewById(R.id.send);
[javac] ^
[javac] /home/alf/Development/android/AndroidClient/src/za/co/stockton/AndroidClient/AndroidClient.java:27: package R does not exist
[javac] textIn = (TextView)findViewById(R.id.textin);
[javac] ^
[javac] 4 errors
BUILD FAILED
/home/alf/Development/android/android-sdk-linux_x86/tools/ant/main_rules.xml:384: Compile failed; see the compiler error output for details.
Total time: 1 second



Reply With Quote
