So I am following this tutorial, using Sublime as a text editor and compiling everything from console.
All was working good, but when we came to the part where you are supposed to make second Activity. They used Eclipse to autogenerate it and told me to paste it down, so I did.
Here is my code (I added some imports and package at the beginning, it fixes some problems)
/MyFirstApp/src/pl/qnsi/myfirstapp/DisplayMessageActivity.java
package pl.qnsi.myfirstapp;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.MenuItem;
public class DisplayMessageActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_message);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() { }
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_display_message,
container, false);
return rootView;
}
}
}
And an error log from console
[qnsi@archie MyFirstApp]$ ant debug
Buildfile: /home/qnsi/code/Apps/learning/MyFirstApp/build.xml
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 22.6.4
[checkenv] Installed at /opt/android-sdk
-setup:
[echo] Project Name: MyFirstApp
[gettype] Project Type: Application
-set-debug-mode:
-debug-obfuscation-check:
-pre-build:
-build-setup:
[getbuildtools] Using latest Build Tools: 19.1.0
[echo] Resolving Build Target for MyFirstApp...
[gettarget] Project Target: Android 4.4.2
[gettarget] API level: 19
[echo] ----------
[echo] Creating output directories if needed...
[echo] ----------
[echo] Resolving Dependencies for MyFirstApp...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
[echo] ----------
[echo] Building Libraries with 'debug'...
[subant] No sub-builds to iterate on
-code-gen:
[mergemanifest] No changes in the AndroidManifest files.
[echo] Handling aidl files...
[aidl] No AIDL files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[echo] ----------
[echo] Handling Resources...
[aapt] No changed resources. R.java and Manifest.java untouched.
[echo] ----------
[echo] Handling BuildConfig class...
[buildconfig] No need to generate new BuildConfig.
-pre-compile:
-compile:
[javac] Compiling 3 source files to /home/qnsi/code/Apps/learning/MyFirstApp/bin/classes
[javac] /home/qnsi/code/Apps/learning/MyFirstApp/src/pl/qnsi/myfirstapp/DisplayMessageActivity.java:12: error: cannot find symbol
[javac] public class DisplayMessageActivity extends ActionBarActivity {
[javac] ^
[javac] symbol: class ActionBarActivity
[javac] /home/qnsi/code/Apps/learning/MyFirstApp/src/pl/qnsi/myfirstapp/DisplayMessageActivity.java:40: error: cannot find symbol
[javac] public static class PlaceholderFragment extends Fragment {
[javac] ^
[javac] symbol: class Fragment
[javac] location: class DisplayMessageActivity
[javac] /home/qnsi/code/Apps/learning/MyFirstApp/src/pl/qnsi/myfirstapp/DisplayMessageActivity.java:45: error: cannot find symbol
[javac] public View onCreateView(LayoutInflater inflater, ViewGroup container,
[javac] ^
[javac] symbol: class LayoutInflater
[javac] location: class PlaceholderFragment
[javac] /home/qnsi/code/Apps/learning/MyFirstApp/src/pl/qnsi/myfirstapp/DisplayMessageActivity.java:45: error: cannot find symbol
[javac] public View onCreateView(LayoutInflater inflater, ViewGroup container,
[javac] ^
[javac] symbol: class ViewGroup
[javac] location: class PlaceholderFragment
[javac] /home/qnsi/code/Apps/learning/MyFirstApp/src/pl/qnsi/myfirstapp/DisplayMessageActivity.java:45: error: cannot find symbol
[javac] public View onCreateView(LayoutInflater inflater, ViewGroup container,
[javac] ^
[javac] symbol: class View
[javac] location: class PlaceholderFragment
[javac] /home/qnsi/code/Apps/learning/MyFirstApp/src/pl/qnsi/myfirstapp/DisplayMessageActivity.java:16: error: cannot find symbol
[javac] super.onCreate(savedInstanceState);
[javac] ^
[javac] symbol: variable super
[javac] location: class DisplayMessageActivity
[javac] /home/qnsi/code/Apps/learning/MyFirstApp/src/pl/qnsi/myfirstapp/DisplayMessageActivity.java:17: error: cannot find symbol
[javac] setContentView(R.layout.activity_display_message);
[javac] ^
[javac] symbol: variable activity_display_message
[javac] location: class layout
[javac] /home/qnsi/code/Apps/learning/MyFirstApp/src/pl/qnsi/myfirstapp/DisplayMessageActivity.java:21: error: cannot find symbol
[javac] .add(R.id.container, new PlaceholderFragment()).commit();
[javac] ^
[javac] symbol: variable container
[javac] location: class id
[javac] /home/qnsi/code/Apps/learning/MyFirstApp/src/pl/qnsi/myfirstapp/DisplayMessageActivity.java:20: error: cannot find symbol
[javac] getSupportFragmentManager().beginTransaction()
[javac] ^
[javac] symbol: method getSupportFragmentManager()
[javac] location: class DisplayMessageActivity
[javac] /home/qnsi/code/Apps/learning/MyFirstApp/src/pl/qnsi/myfirstapp/DisplayMessageActivity.java:14: error: method does not override or implement a method from a supertype
[javac] @Override
[javac] ^
[javac] /home/qnsi/code/Apps/learning/MyFirstApp/src/pl/qnsi/myfirstapp/DisplayMessageActivity.java:31: error: cannot find symbol
[javac] if (id == R.id.action_settings) {
[javac] ^
[javac] symbol: variable action_settings
[javac] location: class id
[javac] /home/qnsi/code/Apps/learning/MyFirstApp/src/pl/qnsi/myfirstapp/DisplayMessageActivity.java:34: error: cannot find symbol
[javac] return super.onOptionsItemSelected(item);
[javac] ^
[javac] symbol: variable super
[javac] location: class DisplayMessageActivity
[javac] /home/qnsi/code/Apps/learning/MyFirstApp/src/pl/qnsi/myfirstapp/DisplayMessageActivity.java:25: error: method does not override or implement a method from a supertype
[javac] @Override
[javac] ^
[javac] /home/qnsi/code/Apps/learning/MyFirstApp/src/pl/qnsi/myfirstapp/DisplayMessageActivity.java:47: error: cannot find symbol
[javac] View rootView = inflater.inflate(R.layout.fragment_display_message,
[javac] ^
[javac] symbol: class View
[javac] location: class PlaceholderFragment
[javac] /home/qnsi/code/Apps/learning/MyFirstApp/src/pl/qnsi/myfirstapp/DisplayMessageActivity.java:47: error: cannot find symbol
[javac] View rootView = inflater.inflate(R.layout.fragment_display_message,
[javac] ^
[javac] symbol: variable fragment_display_message
[javac] location: class layout
[javac] /home/qnsi/code/Apps/learning/MyFirstApp/src/pl/qnsi/myfirstapp/DisplayMessageActivity.java:44: error: method does not override or implement a method from a supertype
[javac] @Override
[javac] ^
[javac] 16 errors
BUILD FAILED
/opt/android-sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/opt/android-sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.
Total time: 1 second
I googled for some answers but most of the errors were fixed by importing the libraries I already imported. I never saw a problem with overloading method or not finding super method. I am clueless what to do.