1

我需要使用 Gradle 构建 apk 文件。这是 build.gradle 代码:

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'
          }
      }
  }
}

这是课程代码:

    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);
                }
            }
        }

    }

构建时出现以下错误:

...src\com\tecomgroup\handifox\bin\BinEditWindow.java :1: 错误:类、接口或枚举预期最终包 com.tecomgroup.handifox.bin;

我哪里错了?

4

1 回答 1

0

final在这个位置(在package关键字之前)是一个无效的关键字,请先修复它

于 2013-08-22T15:53:26.190 回答