javaandroidgradleauto-build

gradle building: class, interface, or enum expected


I need to build apk file by using Gradle. Here's build.gradle code:

buildscript {
repositories {
    mavenCentral()
}

dependencies {
    classpath 'com.android.tools.build:gradle:0.5+'
}
}

apply plugin: 'android'

dependencies {
compile files('libs/android-support-v4.jar')
}

android {
buildToolsVersion "17.0"
compileSdkVersion 10
testBuildType = "debug"

defaultConfig {
    versionCode = 1
    versionName = "0.1"
    minSdkVersion = 9
    targetSdkVersion = 10


    buildConfig "private final static boolean DEFAULT = true;", \
                "private final static String FOO = \"foo\";"
}

buildTypes {
    debug {
        packageNameSuffix = ".debug"

        buildConfig "private final static boolean DEBUG2 = false;"
    }
}

aaptOptions {
    noCompress "txt"
}
sourceSets {
      main {
          manifest {
              srcFile 'AndroidManifest.xml'
          }
          java {
              srcDir 'src'
          }
          res {
              srcDir 'res'
          }
          assets {
              srcDir 'assets'
          }
          resources {
              srcDir 'src'
          }
      }
  }
}

And here's class code:

    final package com.tecomgroup.handifox.bin;

    import java.util.ArrayList;
    import java.util.LinkedList;
    import java.util.List;

    import android.view.ContextMenu;
    import android.view.ContextMenu.ContextMenuInfo;
    import android.view.MenuInflater;
    import android.view.View;
    import android.widget.AdapterView;

    import com.tecomgroup.handifox.ActivityHandifox;
    import com.tecomgroup.handifox.Datastore;
    import com.tecomgroup.handifox.GeneralFunc;
    import com.tecomgroup.handifox.R;

    public abstract class BinEditWindow extends ActivityHandifox {
        public static Datastore idw_items;
        public static Datastore ids_id_changed_items;
        public static Datastore dw_bin;

        protected final List<String> deletedItems = new LinkedList<String>();

        protected void deleteItem(final String idColumnName) {
            if (DS.Rowcount() > 1) {
                if (!GeneralFunc.Empty(DS.get(DS.CurrentRow, "Parent"))) {
                    removeItem(idColumnName);
                } else {
                    removeItem(idColumnName);
                    setParentForItems(chooseNewParentAndGetLineId());
                }
            }
        }

        public abstract String getItemLineId(final int row);

        private String chooseNewParentAndGetLineId() {
            DS.set(0, "Parent", "");
            return getItemLineId(0);
        }

        private void removeItem(final String idColumnName) {
            final String listId = DS.get(DS.CurrentRow, idColumnName);
            deletedItems.add(listId);
            DS.DeleteRow(DS.CurrentRow);
            ib_changed = true;
        }

        private void setParentForItems(final String lineId) {
            final int rowCount = DS.RowCount();
            for (int row = 0; row < rowCount; row++) {
                if (!GeneralFunc.Empty(DS.get(row, "Parent"))) {
                    DS.set(row, "Parent", lineId);
                }
            }
        }

        @Override
        protected boolean onPostCreate() {
            deletedItems.clear();
            return super.onPostCreate();
        }

        @Override
        protected void onPause() {
            super.onPause();
            if (isFinishing()) {
                removeStaticDatastores();
            }
        }

        @Override
        protected void onDestroy() {
            removeStaticDatastores();
            super.onDestroy();
        }

        protected void removeStaticDatastores() {
            idw_items = null;
            ids_id_changed_items = null;
            dw_bin = null;
        }

        @Override
        public void onCreateContextMenu(final ContextMenu menu, final View v,
                final ContextMenuInfo menuInfo) {
            clearFocusEditText();

            final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;

            if (info.position != DS.CurrentRow) {
                DS.isClicked = true;
                DS.ScrolltoRow(info.position);
            }

            final MenuInflater inflater = getMenuInflater();
            inflater.inflate(R.menu.salesreceipt_edit_menu, menu);

            menu.getItem(1).setVisible(DS.RowCount() > 1);

            super.onCreateContextMenu(menu, v, menuInfo);
        }

        protected ArrayList<String> getParentRow() {
            ArrayList<String> result = null;
            final int rowCount = DS.RowCount();
            for (int row = 0; row < rowCount; row++) {
                if (GeneralFunc.Empty(DS.get(DS.CurrentRow, "Parent"))) {
                    result = DS.getRow(row);
                    break;
                }
            }

            return result;
        }

        protected void removeDeletedItems(final Datastore removeItemsFrom,
                final String idColumnName) {
            for (final String deletedItemId : deletedItems) {
                final int deletedRowIndex = removeItemsFrom.Find(idColumnName,
                        deletedItemId, "equal", false);
                if (deletedRowIndex >= 0) {
                    removeItemsFrom.DeleteRow(deletedRowIndex);
                }
            }
        }

    }

While building i get the following error:

...src\com\tecomgroup\handifox\bin\BinEditWindow.java :1: error: class, interface, or enum expected final package com.tecomgroup.handifox.bin;

Where was I wrong?


Solution

  • final is an invalid keyword at this position (before package keyword), please fix it first