构建Android项目使用Ant

构建Android项目使用Ant

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

问题描述

我试图建立我用蚂蚁的Andr​​oid项目(它运行在日食罚款)。我运行以下构建失败行错误:

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上运行。我已经刷新该项目,跑项目的干净,甚至重新启动的日食。

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.

我是相当新的蚂蚁,并将AP preciate任何意见。

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:[公司] _Android $蚂蚁干净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

构建失败
[路径] /android_sdks/tool​​s/ant/build.xml:680:执行此线出现以下错误:
[路径] /android_sdks/tool​​s/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文件的,我只是删除这些文件和事情的来龙去脉了。

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.

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

08-13 07:38