• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps an error in my program:main cannot be resolved or is not a field

aylar

Lurker
Dear developers


I am writing to tell you about my program which is about controlling my robot, but when I run my program an error appears which is containing this massage:" main cannot be resolved or is not a field." I read so many programs' errors to fix it but they didn't work.


This error occurs in setContentView line in this code snippet.







import java.io.BufferedReader;


import java.io.IOException;


import java.io.InputStreamReader;


import java.net.InetAddress;


import java.net.NetworkInterface;


import java.net.ServerSocket;


import java.net.Socket;


import java.net.SocketException;


import java.util.Enumeration;




import android.app.Activity;


import android.os.Bundle;


import android.webkit.WebView;


import android.widget.TextView;








public class MainActivity extends Activity {




TextView info, infoip, msg;


String message = "";


ServerSocket serverSocket;


private WebView webView;




@override


protected void onCreate(Bundle savedInstanceState) {


super.onCreate(savedInstanceState);


setContentView(R.layout.main); //this line has error


info = (TextView) findViewById(R.id.info);


infoip = (TextView) findViewById(R.id.infoip);


msg = (TextView) findViewById(R.id.msg);



when I erase this line, the error erase too. But when I run the program in my phone it said:" the application (package name) has stopped unexpectedly. System failed to repair error. Please use other software."


I would appreciate your immediate attention to this matter.
 
Back
Top Bottom