我的项目成功运行,但是当我导出apk时,却在Prograd-project.txt中崩溃了
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-dontwarn twitter4j.internal.logging.**
-dontwarn org.apache.http.**
-dontwarn org.apache.poi.hssf.usermodel.HSSFWorkbook.**
-ignorewarnings
但错误
致命异常:AsyncTask#1 java.lang.RuntimeException:执行doInBackground()时发生错误 在android.os.AsyncTask $ 3.done(AsyncTask.java:299) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352) at java.util.concurrent.FutureTask.setException(FutureTask.java:219) 在java.util.concurrent.FutureTask.run(FutureTask.java:239) 在android.os.AsyncTask $ SerialExecutor $ 1.run(AsyncTask.java:230) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:573) 在java.lang.Thread.run(Thread.java:856) 引起:java.lang.ExceptionInInitializerError 在org.apache.poi.hssf.usermodel.HSSFWorkbook。(未知来源) 在org.apache.poi.hssf.usermodel.HSSFWorkbook。(未知来源) 在org.apache.poi.hssf.usermodel.HSSFWorkbook。(未知来源) 在org.apache.poi.hssf.usermodel.HSSFWorkbook。(未知来源) 在com.student.HTMLCSS.splash_screen.a(未知来源) 在com.student.HTMLCSS.z.a(未知来源) 在com.student.HTMLCSS.z.doInBackground(未知来源) 在android.os.AsyncTask $ 2.call(AsyncTask.java:287) 在java.util.concurrent.FutureTask.run(FutureTask.java:234) 还有4个 引起:org.apache.poi.hssf.b.do:无法确定记录类型 在org.apache.poi.hssf.b.di.a(未知来源) 在org.apache.poi.hssf.b.di。(未知来源)
代码
setContentView(R.layout.splash_screen);
progress = (ImageView) findViewById(R.id.imgprogress);
FontHelper.applyFont(this, findViewById(R.id.RelativeLayout1),
"helveticaneueltstdlt.ttf");
helper = new MyDBHelper(this);
final Integer[] mThumbIds = {
R.drawable.frame1, R.drawable.frame2, R.drawable.frame3,
R.drawable.frame4,
};
if (getLoginPreferences()) {
try {
r = new Runnable() {
public void run() {
progress.setBackgroundResource(mThumbIds[i]);
i++;
if (i >= mThumbIds.length) {
i = 0;
}
progress.postDelayed(r, 300); // set to go off again in
}
};
progress.postDelayed(r, 300);
}
catch (Exception e)
{
}
Handler mHandler = new Handler();
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
setLoginPreferences("1");
startActivity(new Intent(splash_screen.this,
category_screen.class));
finish();
}
}, 2000);
}
else
{
start = true;
try {
r = new Runnable() {
public void run() {
progress.setBackgroundResource(mThumbIds[i]);
i++;
if (i >= mThumbIds.length) {
i = 0;
}
progress.postDelayed(r, 3000); // set to go off again in
// 3 seconds.
}
};
progress.postDelayed(r, 3000);
}
catch (Exception e) {
}
new data().execute();
}
}
void getData() {
if (!getLoginPreferences()) {
try {
InputStream is = getResources().getAssets().open(
"education.xls");
HSSFWorkbook workbook = new HSSFWorkbook(is);
// Get first sheet from the workbook
System.out.println("number of sheet="
+ workbook.getNumberOfSheets());
for (int sheetno = 0; sheetno <= 7; sheetno++) {
HSSFSheet sheet = workbook.getSheetAt(sheetno);
if (sheetno == 0 || sheetno == 2 || sheetno == 4
|| sheetno == 6) {
Row row;
Cell cell;
// Iterate through each rows from first sheet
Iterator<Row> rowIterator = sheet.iterator();
while (rowIterator.hasNext()) {
flag = 1;
row = rowIterator.next();
// For each row, iterate through each columns
Iterator<Cell> cellIterator = row.cellIterator();
while (cellIterator.hasNext()) {
cell = cellIterator.next();
System.out.println("row index="
+ cell.getRowIndex());
if (cell.getRowIndex() > 0) {
flag = 0;
switch (cell.getCellType()) {
case Cell.CELL_TYPE_BOOLEAN:
System.out.println("bool="
+ cell.getBooleanCellValue());
break;
case Cell.CELL_TYPE_NUMERIC:
id = (int) cell.getNumericCellValue();
System.out.println("number="
+ cell.getNumericCellValue());
break;
case Cell.CELL_TYPE_STRING:
System.out.println("col number="
+ cell.getColumnIndex());
System.out.println("string="
+ cell.getStringCellValue());
if (cell.getColumnIndex() == 1) {
name = cell.getStringCellValue();
} else if (cell.getColumnIndex() == 2) {
uses = cell.getStringCellValue();
} else if (cell.getColumnIndex() == 3) {
example = cell.getStringCellValue();
}
break;
case Cell.CELL_TYPE_BLANK:
System.out.println(" ");
break;
default:
System.out.println(cell);
}
}
}
if (flag == 0) {
System.out.println(id + " " + name + " "
+ uses + " " + example);
if (sheetno == 0)
helper.addContact(0, new Contact(id, name,
uses, example));
if (sheetno == 2)
helper.addContact(2, new Contact(id, name,
uses, example));
if (sheetno == 4)
helper.addContact(4, new Contact(id, name,
uses, example));
if (sheetno == 6)
helper.addContact(6, new Contact(id, name,
uses, example));
name = "";
uses = "";
example = "";
}
}
} else {
Row row;
Cell cell;
flag = 1;
// Iterate through each rows from first sheet
Iterator<Row> rowIterator = sheet.iterator();
while (rowIterator.hasNext()) {
flag = 1;
row = rowIterator.next();
// For each row, iterate through each columns
Iterator<Cell> cellIterator = row.cellIterator();
while (cellIterator.hasNext()) {
cell = cellIterator.next();
System.out.println("row index="
+ cell.getRowIndex());
if (cell.getRowIndex() > 0) {
flag = 0;
switch (cell.getCellType()) {
case Cell.CELL_TYPE_BOOLEAN:
System.out.println("bool="
+ cell.getBooleanCellValue());
break;
case Cell.CELL_TYPE_NUMERIC:
if (cell.getColumnIndex() == 0)
ha_id = (int) cell
.getNumericCellValue();
else if (cell.getColumnIndex() == 1)
id = (int) cell
.getNumericCellValue();
System.out.println("number="
+ cell.getNumericCellValue());
break;
case Cell.CELL_TYPE_STRING:
System.out.println("col number="
+ cell.getColumnIndex());
System.out.println("string="
+ cell.getStringCellValue());
if (cell.getColumnIndex() == 2) {
name = cell.getStringCellValue();
} else if (cell.getColumnIndex() == 3) {
uses = cell.getStringCellValue();
} else if (cell.getColumnIndex() == 4) {
example = cell.getStringCellValue();
}
break;
case Cell.CELL_TYPE_BLANK:
System.out.println(" ");
break;
default:
System.out.println(cell);
}
}
}
if (flag == 0) {
System.out.println(id + " " + name + " "
+ uses + " " + example);
if (sheetno == 1)
helper.addAttribute(1, new Contact(ha_id,
id, name, uses, example));
if (sheetno == 3)
helper.addAttribute(3, new Contact(ha_id,
id, name, uses, example));
if (sheetno == 5)
helper.addAttribute(5, new Contact(ha_id,
id, name, uses, example));
if (sheetno == 7)
helper.addAttribute(7, new Contact(ha_id,
id, name, uses, example));
name = "";
uses = "";
example = "";
}
}
}
}
} catch (FileNotFoundException e) {
Toast.makeText(getApplicationContext(), e.getMessage(),
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
catch (IOException e) {
// TODO Auto-generated catch block
Toast.makeText(getApplicationContext(), e.getMessage(),
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
start = false;
}
private boolean getLoginPreferences() {
boolean isLogin = false;
String strUsername = "";
// try {
SharedPreferences preferences = getSharedPreferences("LOGIN",
MODE_WORLD_READABLE);
strUsername = preferences.getString("TABLE_EXITS", "");
if (!strUsername.trim().equals("")) {
isLogin = true;
} else {
isLogin = false;
}
System.out.println("value in " + strUsername);
/*
* } catch (Exception e) { // TODO: handle exception
* System.out.println("Error at Get login : " + e.toString()); }
*/
return isLogin;
}
private void setLoginPreferences(String strUsername) {
try {
SharedPreferences preferences = getSharedPreferences("LOGIN",
MODE_WORLD_WRITEABLE);
SharedPreferences.Editor editor = preferences.edit();
editor.putString("TABLE_EXITS", strUsername.trim());
editor.commit();
System.out.println("sign-up prefrences:" + strUsername);
} catch (Exception e) {
// TODO: handle exception
System.out.println("Error at Set login : " + e.toString());
}
}
public class data extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
}
@Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
getData();
return null;
}
@Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
setLoginPreferences("1");
startActivity(new Intent(splash_screen.this, category_screen.class));
finish();
}
}
请给我解决方案。
答案 0 :(得分:0)
Add in proguard-project.txt
-keep public class java.awt.**
{
public protected *;
}
-keep public class javax.swing.**
{
public protected *;
}
-keep public class javax.imageio.**
{
public protected *;
}
-keep public class org.apache.commons.logging.LogFactory
{
public protected *;
}
-keep public class java.rmi.UnexpectedException
{
public protected *;
}
-dontwarn twitter4j.internal.logging.**
-dontwarn org.apache.http.**
-dontwarn java.awt.**
-dontwarn javax.swing.**
-dontwarn javax.imageio.**
-dontwarn org.apache.commons.logging.LogFactory
-dontwarn java.rmi.UnexpectedException
-libraryjars /libs/GoogleAdMobAdsSdk-6.4.1.jar
-libraryjars /libs/poi-3.7.jar