首先,我知道有很多问题/关于这个话题的答案,我读过大部分,但仍然得到了错误:
二月五号至17日:57:06.522:E / AndroidRuntime(17073):java.lang.NoClassDefFoundError的:ar.com.tucubondi.android.MainActivity
该项目工作就好了,直到我更新了Eclipse的从21到22。
我已经试过各种我能:我检查清单;清理项目;检查了我的构建路径,试图在不同的Android版本的应用程序,设置java的合规性水平1.6(库太),等等。我只是无法弄清楚的问题是什么。
下面是我的表现,我找不到什么毛病:
< XML版本=1.0编码=UTF-8&GT?;
<舱单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=ar.com.tucubondi.android
安卓版code =1
机器人:VERSIONNAME =1.0>
<用途特征
机器人:glEsVersion =0x00020000
机器人:要求=真/>
<用途-SDK
安卓的minSdkVersion =8
机器人:targetSdkVersion =17/>
<使用-权限的Android:名称=android.permission.INTERNET对/>
<使用-权限的Android:名称=android.permission.ACCESS_NETWORK_STATE/>
<使用-权限的Android:名称=android.permission.WRITE_EXTERNAL_STORAGE/>
<使用-权限的Android:名称=com.google.android.providers.gsf.permission.READ_GSERVICES/>
<使用-权限的Android:名称=android.permission.ACCESS_COARSE_LOCATION/>
<使用-权限的Android:名称=android.permission.ACCESS_FINE_LOCATION/>
<许可
机器人:名称=ar.com.tucubondi.android.permission.MAPS_RECEIVE
安卓的ProtectionLevel =签名/>
<使用-权限的Android:名称=ar.com.tucubondi.android.permission.MAPS_RECEIVE/>
<应用
机器人:allowBackup =真
机器人:图标=@可绘制/ ic_launcher
机器人:标签=@字符串/ APP_NAME
机器人:主题=@风格/ Theme.Sherlock.Light.DarkActionBar
机器人:hardwareAccelerated =真正的>
&所述;元数据
机器人:名称=com.google.android.maps.v2.API_KEY
机器人:值=我的钥匙/>
<活动
机器人:名称=ar.com.tucubondi.android.SplashScreen
机器人:标签=@字符串/ APP_NAME
机器人:noHistory =真
机器人:screenOrientation =画像
机器人:主题=@安卓风格/ Theme.Black.NoTitleBar
机器人:windowSoftInputMode =stateHidden
>
<意向滤光器>
<作用机器人:名称=android.intent.action.MAIN/>
<类机器人:名称=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT;
<活动
机器人:名称=ar.com.tucubondi.android.MainActivity
机器人:标志=@可绘制/标志
机器人:screenOrientation =画像
机器人:windowSoftInputMode =stateHidden
>
< /活性GT;
<活动
机器人:名称=ar.com.tucubondi.android.SearchForm
机器人:标签=@字符串/ title_activity_search_form
机器人:parentActivityName =ar.com.tucubondi.android.MainActivity
>
&所述;元数据
机器人:名称=android.support.PARENT_ACTIVITY
机器人:值=ar.com.tucubondi.android.MainActivity/>
< /活性GT;
< /用途>
< /舱单>
任何帮助是值得欢迎的。我会继续研究,如果我得到了答案,我会后。
修改
这里的MainActivity code:
包ar.com.tucubondi.android;
进口android.annotation.Sup pressLint;
进口android.content.Intent;
进口android.os.Bundle;
进口android.support.v4.app.DialogFragment;
进口android.view.KeyEvent;
进口android.view.View;
进口android.widget.Toast;
进口com.actionbarsherlock.view *。
进口com.google.android.gms.common.ConnectionResult;
进口com.google.android.gms.common.GooglePlayServicesUtil;
进口com.google.android.gms.maps.CameraUpdateFactory;
进口com.google.android.gms.maps.GoogleMap;
进口com.google.android.gms.maps.SupportMapFragment;
进口com.google.android.gms.maps.model.LatLng;
进口com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
进口com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.OnCloseListener;
进口com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.OnOpenListener;
进口com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity;
@燮pressLint(NewApi)
公共类MainActivity扩展SlidingFragmentActivity {
私人SlidingMenu菜单;
私人吐司面包;
专用长lastBack pressTime = 0;
私人GoogleMap的地图;
@覆盖
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.activity_main);
// slidemenu
setBehindContentView(R.layout.menu);
setSlidingActionBarEnabled(假);
菜单= 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(假);
menu.setOnCloseListener(新OnCloseListener(){
@覆盖
公共无效的OnClose(){
menu.setSlidingEnabled(假);
}
});
menu.setOnOpenListener(新OnOpenListener(){
@覆盖
公共无效的OnOpen(){
menu.setSlidingEnabled(真正的);
}
});
getSupportActionBar()setDisplayShowCustomEnabled(真)。
getSupportActionBar()setDisplayHomeAsUpEnabled(假)。
// ---滑动菜单
地图=((SupportMapFragment)getSupportFragmentManager()
.findFragmentById(R.id.map))的GetMap()。
//获取谷歌播放可用性状态
INT状态= GooglePlayServicesUtil
.isGooglePlayServicesAvailable(getBaseContext());
如果(状态!= ConnectionResult.SUCCESS){
Toast.makeText(这一点,谷歌地图没有ESTA disponible。
Toast.LENGTH_LONG).show();
} 其他 {
// PARA CENTRAR EL MAPA EN土库曼
map.moveCamera(CameraUpdateFactory.newLatLngZoom(新经纬度(
-26.8175915814614,-65.22274105834958),13));
//启用谷歌地图的MyLocation层
map.setMyLocationEnabled(真正的);
}
}
@覆盖
公共布尔onCreateOptionsMenu(功能菜单){
//充气菜单;这增加了项目操作栏,如果它是present。
。getSupportMenuInflater()膨胀(R.menu.main,菜单);
返回true;
}
公共布尔onOptionsItemSelected(菜单项项){
开关(item.getItemId()){
案例android.R.id.home:
切换();
返回true;
案例R.id.action_search:
最终诠释结果= 1;
startActivityForResult(新意图(MainActivity.this,
SearchForm.class),RESULT);
返回true;
案例R.id.action_lineas:
showDialogLineas();
返回true;
案例R.id.action_acercade:
showDialogAcercaDe();
返回true;
}
返回super.onOptionsItemSelected(项目);
}
@覆盖
公共布尔的onkeydown(INT键code,KeyEvent的事件){
如果(键code == KeyEvent.KEY code_BACK和放大器;&安培;!menu.isMenuShowing()){
如果(this.lastBack pressTime< System.currentTimeMillis的() - 4000){
敬酒= Toast.makeText(这一点,
presione ATRAS nuevamente对cerrar
Toast.LENGTH_LONG);
toast.show();
this.lastBack pressTime = System.currentTimeMillis的();
} 其他 {
如果(干杯!= NULL){
toast.cancel();
}
super.onBack pressed();
}
返回true;
}
返回super.onKeyDown(键code,事件);
}
公共无效onResultadosClicked(查看视图){
showMenu();
}
公共无效showDialogLineas(){
DialogFragment对话框=新LineasDialog();
dialog.show(getSupportFragmentManager(),Lineas);
}
公共无效showDialogAcercaDe(){
DialogFragment对话框=新AcercaDeDialog();
dialog.show(getSupportFragmentManager(),Acerca);
}
}
解决方案
尝试将项目 - >属性 - > Java构建路径 - >在线订单和放大器;导出并确保 Android的私人图书馆被检查的项目和其他所有库项目所使用。
First of all, I know there are plenty of questions/answers about this topic, I've read most of them but still getting the error:
05-17 02:57:06.522: E/AndroidRuntime(17073): java.lang.NoClassDefFoundError: ar.com.tucubondi.android.MainActivity
The project worked just fine until I updated Eclipse from 21 to 22.
I have tried everything I could: I checked the manifest; Cleaned the project; checked my build path, tried the app in different android version, set java compliance level to 1.6 (libraries too), etc. I just can't figure out what the problem is.
Here's my manifest, I couldn't find anything wrong with it:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ar.com.tucubondi.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.tucubondi.android.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="ar.com.tucubondi.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.tucubondi.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.tucubondi.android.MainActivity"
android:logo="@drawable/logo"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden"
>
</activity>
<activity
android:name="ar.com.tucubondi.android.SearchForm"
android:label="@string/title_activity_search_form"
android:parentActivityName="ar.com.tucubondi.android.MainActivity"
>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="ar.com.tucubondi.android.MainActivity" />
</activity>
</application>
</manifest>
Any help is welcome. I'll keep researching, if I get the answer I'll post it.
EDIT
Here's the MainActivity code:
package ar.com.tucubondi.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 {
// PARA CENTRAR EL MAPA EN TUCUMAN
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");
}
}
解决方案
Try going to Project -> Properties -> Java Build Path -> Order & Export and ensure Android Private Libraries are checked for your project and for all other library projects you are using.