用 Ant 构建 Android 项目——找不到符号 [英] Building Android project with Ant -- cannot find symbol

查看:49
本文介绍了用 Ant 构建 Android 项目——找不到符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am attempting to build my android project using ant (it runs fine in eclipse). I run an error with the following build failed line:

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 文件中的变量.有些是项目中的类.

The above java compilation has plenty of errors, all of which are cannot find symbol errors. Most of these symbols are variables added to the R file. And some are classes within the project.

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

I set up the build environment using:

android update project --path .

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

My tools and platform_tools are all up-to-date and I'm running on android-7. I've refreshed the project, ran a clean on the project, and even restarted eclipse.

我对 ant 还很陌生,希望得到任何建议.

I'm fairly new to ant and would appreciate any advice.

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

The build failing output (as requested, I apologize for the formatting issues):

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

MacBook-Pro:[company]_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

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

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

总时间:6 秒

推荐答案

想通了:

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

I was excluding files on my buildpath on Eclipse. Obviously, this wasn't the case on Ant. Instead of adding this large number of files on my Ant file, I just deleted these files and things worked out.

这篇关于用 Ant 构建 Android 项目——找不到符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆