Building Android project with Ant -- cannot find symbol

10,087

Figured it out:

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.

Share:
10,087
jbenowitz
Author by

jbenowitz

Updated on June 09, 2022

Comments

  • jbenowitz
    jbenowitz almost 2 years

    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.
    

    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 .
    

    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.

    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

    -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: 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.

    Total time: 6 seconds