首先,我知道有很多的問題/關於這個話題的答案,我讀過大部分,但仍然得到錯誤:的NoClassDefFoundError的Android項目
05-17 02:57:06.522: E/AndroidRuntime(17073): java.lang.NoClassDefFoundError: ar.com.package.android.MainActivity
項目工作就好了,直到我更新的Eclipse從21到22.
我試過了我所能做的一切:我檢查了清單;清理項目;檢查了我的構建路徑,嘗試了不同的Android版本的應用程序,將java合規性級別設置爲1.6(庫也是)等。我只是無法弄清楚問題所在。
這裏是我的清單,我找不到什麼毛病:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ar.com.package.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<permission
android:name="ar.com.package.android.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="ar.com.package.android.permission.MAPS_RECEIVE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock.Light.DarkActionBar"
android:hardwareAccelerated="true">
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my key"/>
<activity
android:name="ar.com.package.android.SplashScreen"
android:label="@string/app_name"
android:noHistory="true"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:windowSoftInputMode="stateHidden"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="ar.com.package.android.MainActivity"
android:logo="@drawable/logo"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden"
>
</activity>
<activity
android:name="ar.com.package.android.SearchForm"
android:label="@string/title_activity_search_form"
android:parentActivityName="ar.com.package.android.MainActivity"
>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="ar.com.package.android.MainActivity" />
</activity>
</application>
</manifest>
任何幫助是值得歡迎的。我會繼續研究,如果我得到答案,我會發布它。
編輯
這裏是在MainActivity代碼:
package ar.com.package.android;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Toast;
import com.actionbarsherlock.view.*;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.OnCloseListener;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.OnOpenListener;
import com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity;
@SuppressLint("NewApi")
public class MainActivity extends SlidingFragmentActivity {
private SlidingMenu menu;
private Toast toast;
private long lastBackPressTime = 0;
private GoogleMap map;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// slidemenu
setBehindContentView(R.layout.menu);
setSlidingActionBarEnabled(false);
menu = getSlidingMenu();
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menu.setShadowWidthRes(R.dimen.shadow_width);
menu.setShadowDrawable(R.drawable.shadow);
menu.setBehindOffset(100);
menu.setFadeDegree(0.35f);
menu.setSlidingEnabled(false);
menu.setOnCloseListener(new OnCloseListener() {
@Override
public void onClose() {
menu.setSlidingEnabled(false);
}
});
menu.setOnOpenListener(new OnOpenListener() {
@Override
public void onOpen() {
menu.setSlidingEnabled(true);
}
});
getSupportActionBar().setDisplayShowCustomEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
// ---slide menu
map = ((SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map)).getMap();
// Getting Google Play availability status
int status = GooglePlayServicesUtil
.isGooglePlayServicesAvailable(getBaseContext());
if (status != ConnectionResult.SUCCESS) {
Toast.makeText(this, "Google Maps no esta disponible.",
Toast.LENGTH_LONG).show();
} else {
map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(
-26.8175915814614, -65.22274105834958), 13));
// Enabling MyLocation Layer of Google Map
map.setMyLocationEnabled(true);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getSupportMenuInflater().inflate(R.menu.main, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
toggle();
return true;
case R.id.action_search:
final int RESULT = 1;
startActivityForResult(new Intent(MainActivity.this,
SearchForm.class), RESULT);
return true;
case R.id.action_lineas:
showDialogLineas();
return true;
case R.id.action_acercade:
showDialogAcercaDe();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && !menu.isMenuShowing()) {
if (this.lastBackPressTime < System.currentTimeMillis() - 4000) {
toast = Toast.makeText(this,
"Presione Atrás nuevamente para cerrar",
Toast.LENGTH_LONG);
toast.show();
this.lastBackPressTime = System.currentTimeMillis();
} else {
if (toast != null) {
toast.cancel();
}
super.onBackPressed();
}
return true;
}
return super.onKeyDown(keyCode, event);
}
public void onResultadosClicked(View view) {
showMenu();
}
public void showDialogLineas(){
DialogFragment dialog = new LineasDialog();
dialog.show(getSupportFragmentManager(), "Lineas");
}
public void showDialogAcercaDe(){
DialogFragment dialog = new AcercaDeDialog();
dialog.show(getSupportFragmentManager(), "Acerca");
}
}
你可以發佈MainActivity代碼嗎? –
您是否正確地在您的地圖項目中引用了Google Play服務庫?這是我的猜測,你不是指gogole play服務庫。第二你應該在清單 而不是這個 –
Raghunandan
問題是21 - > 22更新我使用timisus的鏈接解決了它。 感謝您的幫助 – VorteXavier