简体   繁体   中英

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:

  <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:

  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

Why is the LogCat showing the ClassNotFoundException here? 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. It was because of the 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. So, I created a new project in Eclipse, transferred the files over from the original imported project, and it worked on the first try. Victory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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