Note that there are some explanatory texts on larger screens.

plurals
  1. PORuntime error: ClassNotFound exception
    text
    copied!<p>I've been having this runtime error for almost a week and can't find the solution (I'm a new android programmer). Please help me!</p> <p>The log is at the end of this message. I know there are some similar questions to mine but I couldn't find a solution to my problem.</p> <p>I'm trying to call a class from activity using <code>Intent</code> but the runtime error says that this class couldn't be found.</p> <p>This is the log file:</p> <pre><code>07-01 13:22:57.098: E/dalvikvm(1488): Could not find class 'com.XXX.ui.ViewPager', referenced from method com.XXX.ui.MainIWrapper.onCreate 07-01 13:22:57.338: E/AndroidRuntime(1488): FATAL EXCEPTION: main 07-01 13:22:57.338: E/AndroidRuntime(1488): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.XXX/com.XXX.ui.MainIWrapper}: android.view.InflateException: Binary XML file line #43: Error inflating class com.XXX.ui.NavigationBar 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647) 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.os.Handler.dispatchMessage(Handler.java:99) 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.os.Looper.loop(Looper.java:130) 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.app.ActivityThread.main(ActivityThread.java:3683) 07-01 13:22:57.338: E/AndroidRuntime(1488): at java.lang.reflect.Method.invokeNative(Native Method) 07-01 13:22:57.338: E/AndroidRuntime(1488): at java.lang.reflect.Method.invoke(Method.java:507) 07-01 13:22:57.338: E/AndroidRuntime(1488): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 07-01 13:22:57.338: E/AndroidRuntime(1488): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 07-01 13:22:57.338: E/AndroidRuntime(1488): at dalvik.system.NativeStart.main(Native Method) 07-01 13:22:57.338: E/AndroidRuntime(1488): Caused by: android.view.InflateException: Binary XML file line #43: Error inflating class com.XXX.ui.NavigationBar 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581) 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623) 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626) 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626) 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626) 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.view.LayoutInflater.inflate(LayoutInflater.java:408) 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 07-01 13:22:57.338: E/AndroidRuntime(1488): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207) 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.app.Activity.setContentView(Activity.java:1657) 07-01 13:22:57.338: E/AndroidRuntime(1488): at com.XXX.ui.MainIWrapper.onCreate(MainIWrapper.java:69) 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611) 07-01 13:22:57.338: E/AndroidRuntime(1488): ... 11 more 07-01 13:22:57.338: E/AndroidRuntime(1488): Caused by: java.lang.ClassNotFoundException: com.XXX.ui.NavigationBar in loader dalvik.system.PathClassLoader[/data/app/com.XXX- 2.apk] 07-01 13:22:57.338: E/AndroidRuntime(1488): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 07-01 13:22:57.338: E/AndroidRuntime(1488): at java.lang.ClassLoader.loadClass(ClassLoader.java:551) 07-01 13:22:57.338: E/AndroidRuntime(1488): at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.view.LayoutInflater.createView(LayoutInflater.java:471) 07-01 13:22:57.338: E/AndroidRuntime(1488): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570) 07-01 13:22:57.338: E/AndroidRuntime(1488): ... 23 more </code></pre> <p>This is the function that deals with the intent:</p> <pre><code>private Activity from; private Class to; public void open() { Intent intent; intent = new Intent(from, to); if (extras != null) { intent.putExtras(extras); } if (to.equals(MainWrapper.class)) { intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); } if (activityForResultRequestCode == -1) { from.startActivity(intent); } else { from.startActivityForResult(intent, activityForResultRequestCode); } if (pendingAnimation != null &amp;&amp; pendingAnimation.length == 2) { from.overridePendingTransition(pendingAnimation[0], pendingAnimation[1]); } else { from.overridePendingTransition(R.anim.slide_in_right, R.anim.hold); } if (toClosePreviousActivity) { from.finish(); } } </code></pre> <p>This is the call <strong>from</strong> the activity (that needs to be changed), with the class I want to load (it uses the <code>open()</code> function that is doing the intent):</p> <p><code>UiUtils.getOpenActivityBuilder(SplashScreen.this,MainIWrapper.class).toClosePrev(true).open;</code></p> <p>This is a part of my manifest -- it's the main activity that needs to be changed to the class <code>MainIWrapper</code>:</p> <pre><code>&lt;activity android:name=".ui.SplashScreen" android:configChanges="orientation" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; </code></pre> <p>This is the mainWrapper declaration in the manifest file:</p> <pre><code>&lt;activity android:name=".ui.MainIWrapper" android:configChanges="orientation" android:launchMode="singleTask" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar" /&gt; </code></pre> <p>This is the <code>mainWrapper</code> declaration:</p> <pre><code>public class MainIWrapper extends BaseWebSiteScreen implements HasBox {...} </code></pre> <p>And this is the main activity declaration:</p> <pre><code>public class SplashScreen extends Activity {...} </code></pre> <hr> <p>Thank you for the help But i still can't find the problem(I'm really a beginner in android)</p> <p>Those are the lines from my XML(from line 43):</p> <pre><code>&lt;com.XXX.ui.NavigationBar xmlns:vwpgind="http://schemas.android.com/apk/res/com.XXX" android:id="@+id/navigation_bar" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="top" vwpgind:arrowImageSrc="@drawable/common_slider_arrow" vwpgind:hideFirstItem="true" /&gt; </code></pre> <p>the code from MainIWrapper.OnCreate() is:</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_iwrapper); isUserLoggedIn = UserDetails.getInstance(getApplicationContext()).isUserLoggedIn(); //we want to refresh user thumb each time user opens Main iWrapper if (UserDetails.getInstance(getApplicationContext()).isUserLoggedIn()) UserDetails.deleteCachedUserThumb(getApplicationContext()); textBox = (TextBox) findViewById(R.id.text_box); viewPager = (ViewPager) findViewById(R.id.view_pager); pageViewAdapter = new PageViewAdapter(); viewPager.setAdapter(pageViewAdapter); viewPager.setOffscreenPageLimit(NUMBER_OF_PAGES_TO_PRELOAD); navigationBar = (NavigationBar) findViewById(R.id.navigation_bar); topBar = (TopBar) findViewById(R.id.top_bar); progressAnimation = (ImageView) findViewById(R.id.progress_animation); bottomBar = (BottomBar) findViewById(R.id.bottom_bar); } </code></pre> <p>I still can't find the error here. I looked at the build path and the src folder with the com.XXX.ui package in it(this package contains the NavigationBar and the ViewPager classes)</p> <hr> <p>Those are the lines from my XML(from line 43):</p> <pre><code> &lt;com.XXX.ui.NavigationBar xmlns:vwpgind="http://schemas.android.com/apk/res/com.XXX" android:id="@+id/navigation_bar" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="top" vwpgind:arrowImageSrc="@drawable/common_slider_arrow" vwpgind:hideFirstItem="true" /&gt; </code></pre> <p>the code from MainIWrapper.OnCreate() is:</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_iwrapper); isUserLoggedIn = UserDetails.getInstance(getApplicationContext()).isUserLoggedIn(); //we want to refresh user thumb each time user opens Main iWrapper if (UserDetails.getInstance(getApplicationContext()).isUserLoggedIn()) UserDetails.deleteCachedUserThumb(getApplicationContext()); textBox = (TextBox) findViewById(R.id.text_box); viewPager = (ViewPager) findViewById(R.id.view_pager); pageViewAdapter = new PageViewAdapter(); viewPager.setAdapter(pageViewAdapter); viewPager.setOffscreenPageLimit(NUMBER_OF_PAGES_TO_PRELOAD); navigationBar = (NavigationBar) findViewById(R.id.navigation_bar); topBar = (TopBar) findViewById(R.id.top_bar); progressAnimation = (ImageView) findViewById(R.id.progress_animation); bottomBar = (BottomBar) findViewById(R.id.bottom_bar); } </code></pre> <p>I still can't see what is the problem here</p> <pre><code>public class ViewPager extends android.support.v4.view.ViewPager { public ViewPager(Context context) { super(context); } public ViewPager(Context context, AttributeSet attrs) { super(context, attrs); } @Override public Parcelable onSaveInstanceState() { try { return super.onSaveInstanceState(); } catch (Exception e) { return null; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload