我正在尝试使用命令行参数完成Google提供的Android教程系列。我有:
然而,当我转到本教程的第二部分(“构建一个简单的用户界面”)时,当我进入该特定教程的编译阶段时,我遇到了构建问题。我已经完全复制了教程网站(http://developer.android.com/training/basics/firstapp/building-ui.html)中提供的代码,但总是得到以下编译时错误:
Buildfile: /Users/admin/Dropbox/CODING/ANDROID/work/build.xml
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 22.3.0
[checkenv] Installed at /Applications/adt-bundle-mac-x86_64-20131030/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.0.1
[echo] Resolving Build Target for MyFirstApp...
[gettarget] Project Target: Android 4.2.2
[gettarget] API level: 17
[gettarget] WARNING: No minSdkVersion value set. Application will install on all Android versions.
[echo] ----------
[echo] Creating output directories if needed...
[mkdir] Created dir: /Users/admin/Dropbox/CODING/ANDROID/work/bin/rsObj
[mkdir] Created dir: /Users/admin/Dropbox/CODING/ANDROID/work/bin/rsLibs
[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] Generating BuildConfig class.
-pre-compile:
-compile:
[javac] Compiling 4 source files to /Users/admin/Dropbox/CODING/ANDROID/work/bin/classes
[javac] /Users/admin/Dropbox/CODING/ANDROID/work/src/com/example/myfirstapp/DisplayMessageActivity.java:1: cannot find symbol
[javac] symbol: class Activity
[javac] public class DisplayMessageActivity extends Activity {
[javac] ^
[javac] /Users/admin/Dropbox/CODING/ANDROID/work/src/com/example/myfirstapp/DisplayMessageActivity.java:5: cannot find symbol
[javac] symbol : class Bundle
[javac] location: class DisplayMessageActivity
[javac] public void onCreate(Bundle savedInstanceState)
[javac] ^
[javac] /Users/admin/Dropbox/CODING/ANDROID/work/src/com/example/myfirstapp/DisplayMessageActivity.java:23: cannot find symbol
[javac] symbol : class MenuItem
[javac] location: class DisplayMessageActivity
[javac] public boolean onOptionsItemSelected(MenuItem item) {
[javac] ^
[javac] /Users/admin/Dropbox/CODING/ANDROID/work/src/com/example/myfirstapp/DisplayMessageActivity.java:3: cannot find symbol
[javac] symbol : class SuppressLint
[javac] location: class DisplayMessageActivity
[javac] @SuppressLint("NewApi")
[javac] ^
[javac] /Users/admin/Dropbox/CODING/ANDROID/work/src/com/example/myfirstapp/DisplayMessageActivity.java:7: cannot find symbol
[javac] symbol : variable super
[javac] location: class DisplayMessageActivity
[javac] super.onCreate(savedInstanceState);
[javac] ^
[javac] /Users/admin/Dropbox/CODING/ANDROID/work/src/com/example/myfirstapp/DisplayMessageActivity.java:10: cannot find symbol
[javac] symbol : class Intent
[javac] location: class DisplayMessageActivity
[javac] Intent intent = getIntent();
[javac] ^
[javac] /Users/admin/Dropbox/CODING/ANDROID/work/src/com/example/myfirstapp/DisplayMessageActivity.java:10: cannot find symbol
[javac] symbol : method getIntent()
[javac] location: class DisplayMessageActivity
[javac] Intent intent = getIntent();
[javac] ^
[javac] /Users/admin/Dropbox/CODING/ANDROID/work/src/com/example/myfirstapp/DisplayMessageActivity.java:11: cannot find symbol
[javac] symbol : variable MainActivity
[javac] location: class DisplayMessageActivity
[javac] String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
[javac] ^
[javac] /Users/admin/Dropbox/CODING/ANDROID/work/src/com/example/myfirstapp/DisplayMessageActivity.java:14: cannot find symbol
[javac] symbol : class TextView
[javac] location: class DisplayMessageActivity
[javac] TextView textView = new TextView(this);
[javac] ^
[javac] /Users/admin/Dropbox/CODING/ANDROID/work/src/com/example/myfirstapp/DisplayMessageActivity.java:14: cannot find symbol
[javac] symbol : class TextView
[javac] location: class DisplayMessageActivity
[javac] TextView textView = new TextView(this);
[javac] ^
[javac] /Users/admin/Dropbox/CODING/ANDROID/work/src/com/example/myfirstapp/DisplayMessageActivity.java:4: method does not override or implement a method from a supertype
[javac] @Override
[javac] ^
[javac] /Users/admin/Dropbox/CODING/ANDROID/work/src/com/example/myfirstapp/DisplayMessageActivity.java:26: cannot find symbol
[javac] symbol : variable NavUtils
[javac] location: class DisplayMessageActivity
[javac] NavUtils.navigateUpFromSameTask(this);
[javac] ^
[javac] /Users/admin/Dropbox/CODING/ANDROID/work/src/com/example/myfirstapp/DisplayMessageActivity.java:29: cannot find symbol
[javac] symbol : variable super
[javac] location: class DisplayMessageActivity
[javac] return super.onOptionsItemSelected(item);
[javac] ^
[javac] /Users/admin/Dropbox/CODING/ANDROID/work/src/com/example/myfirstapp/DisplayMessageActivity.java:22: method does not override or implement a method from a supertype
[javac] @Override
[javac] ^
[javac] /Users/admin/Dropbox/CODING/ANDROID/work/src/com/example/myfirstapp/MainActivity.java:21: cannot find symbol
[javac] symbol : class Intent
[javac] location: class com.example.myfirstapp.MainActivity
[javac] Intent intent = new Intent(this, DisplayMessageActivity.class);
[javac] ^
[javac] /Users/admin/Dropbox/CODING/ANDROID/work/src/com/example/myfirstapp/MainActivity.java:21: cannot find symbol
[javac] symbol : class Intent
[javac] location: class com.example.myfirstapp.MainActivity
[javac] Intent intent = new Intent(this, DisplayMessageActivity.class);
[javac] ^
[javac] /Users/admin/Dropbox/CODING/ANDROID/work/src/com/example/myfirstapp/DisplayMessageActivity.java:1: duplicate class: DisplayMessageActivity
[javac] public class DisplayMessageActivity extends Activity {
[javac] ^
[javac] /Users/admin/Dropbox/CODING/ANDROID/work/src/com/example/myfirstapp/MainActivity.java:21: cannot access com.example.myfirstapp.DisplayMessageActivity
[javac] bad class file: /Users/admin/Dropbox/CODING/ANDROID/work/src/com/example/myfirstapp/DisplayMessageActivity.java
[javac] file does not contain class com.example.myfirstapp.DisplayMessageActivity
[javac] Please remove or make sure it appears in the correct subdirectory of the classpath.
[javac] Intent intent = new Intent(this, DisplayMessageActivity.class);
[javac] ^
[javac] 18 errors
BUILD FAILED
/Applications/adt-bundle-mac-x86_64-20131030/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/Applications/adt-bundle-mac-x86_64-20131030/sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.
我已经在Stack Overflow上面对这个特定问题的人搜索了高低,但没有找到任何解决方案。我认为这可能仅仅是教程不包含正确的import语句的情况。我尝试了几种不同的导入,但总是会出现某种类型的编译时错误。
如果有人有解决方案必须如何实施本教程才能正常工作,那几乎可以肯定地保留了我理智中最后的临时余烬。
非常感谢提前。