6

我正在尝试使用 ant 构建我的 android 项目(它在 eclipse 中运行良好)。我使用以下构建失败行运行错误:

BUILD FAILED
.../android_sdks/tools/ant/build.xml:680: The following error occurred while executing this line:
.../android_sdks/tools/ant/build.xml:693: Compile failed; see the compiler error output for details.

上面的java编译有很多错误,都是找不到符号的错误。这些符号中的大多数是添加到 R 文件中的变量。有些是项目中的类。

我使用以下方法设置构建环境:

android update project --path .

我的工具和 platform_tools 都是最新的,我在 android-7 上运行。我已经刷新了项目,对项目进行了清理,甚至重新启动了 eclipse。

我对蚂蚁还很陌生,不胜感激。

构建失败输出(根据要求,我为格式问题道歉):

MacBook-Pro:[公司]_Android$ ant clean debugBuildfile:[android_path]/build.xml

-check-env:
[checkenv] Android SDK Tools Revision 20
[checkenv] Installed at [path]/android_sdks

-setup:
 [echo] Project Name: SplashActivity
 [gettype] Project Type: Application
 [echo] Switching between debug and non debug build: Deleting previous compilation output...
 [delete] Deleting directory [android_path]/bin/classes

-pre-clean:

clean:
 [delete] Deleting directory [android_path]/bin
 [delete] Deleting directory [android_path]/gen
 [getlibpath] Library dependencies:
 [getlibpath] No Libraries
 [subant] No sub-builds to iterate on

  ###removed some code#####
 -build-setup:
  [echo] Resolving Build Target for SplashActivity...
  [gettarget] Project Target:   Android 2.1
  [gettarget] API level:        7
  [echo] ----------
  [echo] Creating output directories if needed...
  [mkdir] Created dir: [android_path]/bin
  [mkdir] Created dir: [android_path]/bin/res
  [mkdir] Created dir: [android_path]/gen
  [mkdir] Created dir: [android_path]/bin/classes
  [echo] ----------
  [echo] Resolving Dependencies for SplashActivity...
   [dependency] Ordered libraries:
   [dependency] 
   [dependency] ------------------
   [dependency] API<=15: Adding annotations.jar to the classpath.
   [echo] ----------
   [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

 -pre-build:

 -code-gen:
    [mergemanifest] Merging AndroidManifest files into one.
    [mergemanifest] Manifest merger disabled. Using project manifest only.
    [echo] Handling aidl files...
    [aidl] Found 1 AIDL files.
    [aidl] Compiling 1 AIDL files.
    [echo] ----------
    [echo] Handling RenderScript files...
    [renderscript] No RenderScript files to compile.
    [echo] ----------
    [echo] Handling Resources...
    [aapt] Generating resource IDs...
    [echo] ----------
    [echo] Handling BuildConfig class...
    [buildconfig] Generating BuildConfig class.

-pre-compile:

-compile:
[javac] Compiling 263 source files to [android_path]/bin/classes
[javac] [android_path]/src/com/[company]/firstbase/AbstractFirstBaseActivity.java:447: warning: unmappable character for encoding UTF-8

#####removed a lot of similar warnings######

[javac] [android_path]/src/com/[company]/firstbase/models/[company]Match.java:14: cannot find symbol
[javac] symbol  : class MatchExpiryComparator
[javac] location: package com.[company].firstbase.util
[javac] import com.[company].firstbase.util.MatchExpiryComparator;
[javac]                                  ^
[javac] [android_path]/src/com/[company]/firstbase/models/[company]Match.java:21: cannot find symbol
[javac] symbol  : class MatchExpiryComparator
[javac] location: class com.[company].firstbase.models.[company]Match
[javac]     public static MatchExpiryComparator EXPIRATION_SORT_COMPARATOR = new MatchExpiryComparator();
[javac]                   ^
[javac] [android_path]/src/com/[company]/firstbase/widget/[company]Widget.java:12: cannot find symbol
[javac] symbol  : class DashboardActivity
[javac] location: package com.[company].firstbase
[javac] import com.[company].firstbase.DashboardActivity;
[javac]                             ^
[javac] [android_path]/src/com/[company]/firstbase/FirstBaseApplication.java:178: warning: non-varargs call of varargs method with inexact argument type for last parameter;
[javac] cast to java.lang.Object for a varargs call
[javac] cast to java.lang.Object[] for a non-varargs call and to suppress this warning
[javac]                         facebookData.put(key, Utils.stringJoin(",", entries));
[javac]                                                                     ^
[javac] [android_path]/src/com/[company]/firstbase/misc/Panel.java:189: cannot find symbol
[javac] symbol  : variable panelHandle
[javac] location: class com.[company].firstbase.R.id
[javac]         mHandle = findViewById(R.id.panelHandle);
[javac]                                    ^
[javac] [android_path]/src/com/[company]/firstbase/misc/Panel.java:193: cannot find symbol
[javac] symbol  : variable panelContent
[javac] location: class com.[company].firstbase.R.id
[javac]         mContent = findViewById(R.id.panelContent);
[javac]                                     ^
[javac] [android_path]/src/com/[company]/firstbase/models/[company]Match.java:21: cannot find symbol
[javac] symbol  : class MatchExpiryComparator
[javac] location: class com.[company].firstbase.models.[company]Match
[javac]     public static MatchExpiryComparator EXPIRATION_SORT_COMPARATOR = new MatchExpiryComparator();
[javac]                                                                          ^
[javac] [android_path]/src/com/[company]/firstbase/models/[company]Match.java:56: cannot find symbol
[javac] symbol  : variable USERS_USERID
[javac] location: class com.[company].firstbase.db.DbHelper
[javac]         this.userID = Utils.descryptForDB(c.getString(c.getColumnIndexOrThrow(DbHelper.USERS_USERID)));
[javac]                                                                                       ^
[javac] [android_path]/src/com/[company]/firstbase/models/[company]Match.java:57: cannot find symbol
[javac] symbol  : variable USERS_USERNAME
[javac] location: class com.[company].firstbase.db.DbHelper
[javac]         this.username = c.getString(c.getColumnIndexOrThrow(DbHelper.USERS_USERNAME));
[javac]                                                                     ^
[javac] [android_path]/src/com/[company]/firstbase/models/[company]Match.java:58: cannot find symbol
[javac] symbol  : variable USERS_PHOTO
[javac] location: class com.[company].firstbase.db.DbHelper
[javac]         this.photoURI = c.getString(c.getColumnIndexOrThrow(DbHelper.USERS_PHOTO));
[javac]                                                                     ^

 #######Removed a lot of similar errors ##########


[javac]                                                                            ^
[javac] [android_path]/src/com/[company]/firstbase/widget/[company]Widget.java:21: cannot find symbol
[javac] symbol  : variable widget_layout
[javac] location: class com.[company].firstbase.R.layout
[javac]             RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
[javac]                                                                                   ^
[javac] [android_path]/src/com/[company]/firstbase/widget/[company]Widget.java:23: cannot find symbol
[javac] symbol  : variable DashboardActivity
[javac] location: class com.[company].firstbase.widget.[company]Widget
[javac]             int count = DashboardActivity.mMatchesCalloutCount+DashboardActivity.mConnectionsCalloutCount;
[javac]                         ^
[javac] [android_path]/src/com/[company]/firstbase/widget/[company]Widget.java:23: cannot find symbol
[javac] symbol  : variable DashboardActivity
[javac] location: class com.[company].firstbase.widget.[company]Widget
[javac]             int count = DashboardActivity.mMatchesCalloutCount+DashboardActivity.mConnectionsCalloutCount;
[javac]                                                                ^
[javac] [android_path]/src/com/[company]/firstbase/widget/[company]Widget.java:23: incompatible types
[javac] found   : java.lang.String
[javac] required: int
[javac]             int count = DashboardActivity.mMatchesCalloutCount+DashboardActivity.mConnectionsCalloutCount;
[javac]                                                               ^
[javac] [android_path]/src/com/[company]/firstbase/widget/[company]Widget.java:27: cannot find symbol
[javac] symbol  : variable callout
[javac] location: class com.[company].firstbase.R.id
[javac]                 views.setTextViewText(R.id.callout, count+"");
[javac]                                           ^
[javac] [android_path]/src/com/[company]/firstbase/widget/[company]Widget.java:28: cannot find symbol
[javac] symbol  : variable callout
[javac] location: class com.[company].firstbase.R.id
[javac]                 views.setViewVisibility(R.id.callout, View.VISIBLE);
[javac]                                             ^
[javac] [android_path]/src/com/[company]/firstbase/widget/[company]Widget.java:31: cannot find symbol
[javac] symbol  : variable callout
[javac] location: class com.[company].firstbase.R.id
[javac]                 views.setViewVisibility(R.id.callout, View.GONE);
[javac]                                             ^
[javac] [android_path]/src/com/[company]/firstbase/widget/[company]Widget.java:34: cannot find symbol
[javac] symbol  : class DashboardActivity
[javac] location: class com.[company].firstbase.widget.[company]Widget
[javac]             Intent intent = new Intent(context, DashboardActivity.class);
[javac]                                                 ^
[javac] [android_path]/src/com/[company]/firstbase/widget/[company]Widget.java:37: cannot find symbol
[javac] symbol  : variable widget_heart
[javac] location: class com.[company].firstbase.R.id
[javac]             views.setOnClickPendingIntent(R.id.widget_heart, pendingIntent);
[javac]                                               ^
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 40 errors
[javac] 21 warnings

BUILD FAILED [path]/android_sdks/tools/ant/build.xml:680:执行此行时出现以下错误:[path]/android_sdks/tools/ant/build.xml:693:编译失败;有关详细信息,请参阅编译器错误输出。

总时间:6秒

4

1 回答 1

2

弄清楚了:

我在 Eclipse 上的构建路径中排除了文件。显然,Ant 并非如此。我没有在我的 Ant 文件中添加这么多文件,而是删除了这些文件,事情就解决了。

于 2012-07-24T16:22:43.100 回答