好吧,現在我真的陷入了這裏。我不知道該做什麼,去哪裏或任何事情!Dex Loader無法執行多個dex文件定義
我一直在試圖卸載,重新安裝SDK和Eclipse版本,試圖谷歌這一點,但Nu-呃...沒有!
我可以運行我的模擬器的應用程序,但我不能將其導出...
[2011-10-07十六時35分三十秒 - 地塞米松裝載機]無法執行DEX:多DEX文件定義LCOM/dreamhawk/kalori/DataBaseHelper;
這是dataBaseHelper
package com.dreamhawk.kalori;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import android.widget.Toast;
public class DataBaseHelper extends SQLiteOpenHelper {
// The Android's default system path of your application database.
private static String DB_PATH = "/data/data/com.dreamhawk.kalori/databases/";
private static String DB_NAME = "livsmedel_db";
private DataBaseHelper myDBHelper;
private SQLiteDatabase myDb;
private final Context myContext;
private static final String DATABASE_TABLE = "Livsmedel";
public static String DB_FILEPATH = "/data/data/com.dreamhawk.kalori/databases/lifemedel_db";
public static final String KEY_TITLE = "Namn";
public static final String KEY_BODY = "Kcal";
public static final String KEY_ROWID = "_id";
private static final int DATABASE_VERSION = 2;
/**
* Constructor Takes and keeps a reference of the passed context in order to
* access to the application assets and resources.
*
* @param context
*/
public DataBaseHelper(Context context) {
super(context, DB_NAME, null, 1);
this.myContext = context;
// checking database and open it if exists
if (checkDataBase()) {
openDataBase();
} else {
try {
this.getReadableDatabase();
createDatabase();
this.close();
openDataBase();
} catch (IOException e) {
throw new Error("Error copying database");
}
Toast.makeText(context, "Livsmedelsdatabasen importerad",
Toast.LENGTH_LONG).show();
}
}
private boolean checkDataBase() {
SQLiteDatabase checkDB = null;
boolean exist = false;
try {
String dbPath = DB_PATH + DB_NAME;
checkDB = SQLiteDatabase.openDatabase(dbPath, null,
SQLiteDatabase.OPEN_READONLY);
} catch (SQLiteException e) {
Log.v("db log", "database does't exist");
}
if (checkDB != null) {
exist = true;
checkDB.close();
}
return exist;
}
@Override
public void onCreate(SQLiteDatabase db) {
// db.execSQL(DATABASE_CREATE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w("Kalori", "Upgrading database from version " + oldVersion + " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS Livsmedel");
onCreate(db);
}
public DataBaseHelper open() throws SQLException {
myDBHelper = new DataBaseHelper(myContext);
myDb = myDBHelper.getWritableDatabase();
return this;
}
public void createDatabase() throws IOException {
InputStream assetsDB = myContext.getAssets().open("livsmedel_db");
// OutputStream dbOut = new FileOutputStream(DB_PATH);
String outFileName = DB_PATH + DB_NAME;
OutputStream dbOut = new FileOutputStream(outFileName);
Log.d("DH", "index=" + assetsDB);
byte[] buffer = new byte[1024];
int length;
while ((length = assetsDB.read(buffer)) > 0) {
dbOut.write(buffer, 0, length);
}
dbOut.flush();
dbOut.close();
assetsDB.close();
}
public Cursor fetchAllNotes() {
return myDb.query(DATABASE_TABLE, new String[] { KEY_ROWID, KEY_TITLE,
KEY_BODY }, null, null, null, null, null);
}
public void openDataBase() throws SQLException {
String dbPath = DB_PATH + DB_NAME;
myDb = SQLiteDatabase.openDatabase(dbPath, null,
SQLiteDatabase.OPEN_READWRITE);
}
}
我懷疑:
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
但我不知道該怎麼辦......請幫助! :'(
您是否嘗試過使用ant直接構建它,而不是通過eclipse來構建它? ?如果是這樣,你可以發佈完整的構建日誌嗎?另外,你是否在項目中包含任何庫項目或jar文件? – JesusFreke
不,我沒有。不,我沒有其他的圖書館項目或.jars,我只使用Android 2.3.3,我有一個存儲在資產文件夾中的數據庫。這一直在工作之前,但自更新ADT和Eclipse以來,這已失敗。我還沒有試過螞蟻,現在我沒有時間去做:/ – DreamHawk
@ user889771相同,我更新了adt,問題開始發生 – Rob