简体   繁体   English

我在日志猫中收到ClassNotFoundException吗? 为什么?

[英]I am getting ClassNotFoundException, in log cat? why?

For my project all my java classes are in one package - com.example.android.bitmapfun - and my manifest is: 对于我的项目,我所有的Java类都放在一个包中com.example.android.bitmapfun我的清单是:

  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.android.bitmapfun"
  android:versionCode="1"
  android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="15"
    android:targetSdkVersion="15" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
    android:description="@string/app_description"
    android:hardwareAccelerated="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >

    <activity
        android:name="com.example.android.bitmapfun.ImageGridActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.android.bitmapfun.ImageDetailActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.FullScreen" >
    </activity>
</application>
</manifest>

and the Activities are: 活动是:

   package com.example.android.bitmapfun;

 import android.os.Bundle;
 import android.support.v4.app.FragmentActivity;
 import android.support.v4.app.FragmentTransaction;


  public class ImageGridActivity extends FragmentActivity {
  private static final String TAG = "ImageGridFragment";

 @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (getSupportFragmentManager().findFragmentByTag(TAG) == null) {
        final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.add(android.R.id.content, new ImageGridFragment(), TAG);
        ft.commit();
    }
  }
  }

ImageDeatilActivity.java: ImageDeatilActivity.java:

  package com.example.android.bitmapfun;

 import android.annotation.SuppressLint;
 import android.app.ActionBar;
 import android.content.Intent;
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentActivity;
 import android.support.v4.app.FragmentManager;
 import android.support.v4.app.FragmentStatePagerAdapter;
 import android.support.v4.view.ViewPager;
 import android.util.DisplayMetrics;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.view.WindowManager.LayoutParams;
 import android.widget.Toast;

 import com.example.android.bitmapfun.R;
 import com.example.android.bitmapfun.Images;
 import com.example.android.bitmapfun.DiskLruCache;
 import com.example.android.bitmapfun.ImageCache;
 import com.example.android.bitmapfun.ImageFetcher;
 import com.example.android.bitmapfun.ImageResizer;
 import com.example.android.bitmapfun.ImageWorker;
 import com.example.android.bitmapfun.Utils;

 public class ImageDetailActivity extends FragmentActivity implements OnClickListener {
private static final String IMAGE_CACHE_DIR = "images";
public static final String EXTRA_IMAGE = "extra_image";

private ImagePagerAdapter mAdapter;
private ImageResizer mImageWorker;
private ViewPager mPager;

@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.image_detail_pager);
 .....
}

LogCat: here LogCat: 此处

Why is the LogCat showing the ClassNotFoundException here? 为什么LogCat在这里显示ClassNotFoundException? I tried but can't clear the error. 我试过但无法清除错误。 Please any ideas to overcome this problem. 请任何想法来克服这个问题。

要使用此FragMentActivity类,您的应用程序必须在其清单中指定API级别“ 11”或更高,并针对支持相同或更高API级别的Android库版本进行编译。

For what it is worth, I couldn't get any of the solutions to work when I imported the BitmapFun project into Eclipse. 出于其价值,当我将BitmapFun项目导入Eclipse时,我无法获得任何解决方案。 It was because of the ClassNotFoundException. 这是因为ClassNotFoundException。 I did notice that the project was missing the libs folder and the support library, but creating the libs folder and dropping the support library into it did not fix the problem. 我确实注意到该项目缺少libs文件夹和支持库,但是创建libs文件夹并将支持库放入其中并不能解决问题。 So, I created a new project in Eclipse, transferred the files over from the original imported project, and it worked on the first try. 因此,我在Eclipse中创建了一个新项目,将文件从原始导入的项目转移过来,并且在第一次尝试时就起作用了。 Victory. 胜利。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM