我的 android 应用程序抛出 ClassNotFoundException 异常。
这是我在 MainActivity.java 中的代码:
package pl.advancedsoftware.manga;
public class MainActivity extends FragmentActivity {
ViewPager viewPager;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.activity_main);
Favourites.context= getApplicationContext();
SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
viewPager= (ViewPager)findViewById(R.id.pager);
viewPager.setAdapter(sectionsPagerAdapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
在 AndroidManifest.xml 中:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pl.advancedsoftware.manga"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="pl.advancedsoftware.manga.MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="pl.advancedsoftware.manga.BookActivity"
android:label="Books" />
<activity
android:name="pl.advancedsoftware.manga.EpisodeActivity"
android:label="Epsiode" />
</application>
</manifest>
我的例外是:
> 04-25 12:28:08.868: E/AndroidRuntime(898): FATAL EXCEPTION: main 04-25
> 12:28:08.868: E/AndroidRuntime(898): java.lang.RuntimeException:
> Unable to instantiate activity
> ComponentInfo{pl.advancedsoftware.manga/pl.advancedsoftware.manga.MainActivity}:
> java.lang.ClassNotFoundException: Didn't find class
> "pl.advancedsoftware.manga.MainActivity" on path:
> /data/app/pl.advancedsoftware.manga-1.apk 04-25 12:28:08.868:
> E/AndroidRuntime(898): at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
> 04-25 12:28:08.868: E/AndroidRuntime(898): at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
> 04-25 12:28:08.868: E/AndroidRuntime(898): at
> android.app.ActivityThread.access$600(ActivityThread.java:141) 04-25
> 12:28:08.868: E/AndroidRuntime(898): at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
> 04-25 12:28:08.868: E/AndroidRuntime(898): at
> android.os.Handler.dispatchMessage(Handler.java:99) 04-25
> 12:28:08.868: E/AndroidRuntime(898): at
> android.os.Looper.loop(Looper.java:137) 04-25 12:28:08.868:
> E/AndroidRuntime(898): at
> android.app.ActivityThread.main(ActivityThread.java:5041) 04-25
> 12:28:08.868: E/AndroidRuntime(898): at
> java.lang.reflect.Method.invokeNative(Native Method) 04-25
> 12:28:08.868: E/AndroidRuntime(898): at
> java.lang.reflect.Method.invoke(Method.java:511) 04-25 12:28:08.868:
> E/AndroidRuntime(898): at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
> 04-25 12:28:08.868: E/AndroidRuntime(898): at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 04-25
> 12:28:08.868: E/AndroidRuntime(898): at
> dalvik.system.NativeStart.main(Native Method) 04-25 12:28:08.868:
> E/AndroidRuntime(898): Caused by: java.lang.ClassNotFoundException:
> Didn't find class "pl.advancedsoftware.manga.MainActivity" on path:
> /data/app/pl.advancedsoftware.manga-1.apk 04-25 12:28:08.868:
> E/AndroidRuntime(898): at
> dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
> 04-25 12:28:08.868: E/AndroidRuntime(898): at
> java.lang.ClassLoader.loadClass(ClassLoader.java:501) 04-25
> 12:28:08.868: E/AndroidRuntime(898): at
> java.lang.ClassLoader.loadClass(ClassLoader.java:461) 04-25
> 12:28:08.868: E/AndroidRuntime(898): at
> android.app.Instrumentation.newActivity(Instrumentation.java:1054)
> 04-25 12:28:08.868: E/AndroidRuntime(898): at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
> 04-25 12:28:08.868: E/AndroidRuntime(898): ... 11 more
我看到路径 /data/app/pl.advancedsoftware.manga-1.apk 可能有问题,但我不知道。我想说这个项目在从存储库克隆它们后停止工作。