1.Add android-support-v4 error java. lang. ClassNotFoundException: android. support. v4.view. ViewPager in loade
Problem:The following error is prompted after adding a android-support-v4.jar with ViewPager
11-15 21:01:21.725: E/AndroidRuntime(32431): Caused by: java.lang.ClassNotFoundException: android.support.v4.view.ViewPager in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/mnt/asec/com.trinea.android.demo-2/pkg.apk]
Complete error:
I added the android-support-v4.jar package through project-> properties-> Java Build Path-> Add External JARs, to solve this problem, you only need to go to project-> properties-> Java Build Path-> Remove the jar and copy the jar package directly to the libs directory of the project. Because the jar package under the project libs will be automatically imported into the project, you do not need to manually import it. The automatically imported package exists in the Android Private folder.
15 21:01:21.725: E/AndroidRuntime(32431): FATAL EXCEPTION: main-15 21:01:21.725: E/AndroidRuntime(32431): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.trinea.android.demo/com.trinea.android.demo.ViewPagerDemo}: android.view.InflateException: Binary XML file line #7: Error inflating class android.support.v4.view.ViewPager-15 21:01:21.725: E/AndroidRuntime(32431): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1664)-15 21:01:21.725: E/AndroidRuntime(32431): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1680)-15 21:01:21.725: E/AndroidRuntime(32431): at android.app.ActivityThread.access$1500(ActivityThread.java:117)-15 21:01:21.725: E/AndroidRuntime(32431): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)-15 21:01:21.725: E/AndroidRuntime(32431): at android.os.Handler.dispatchMessage(Handler.java:99)-15 21:01:21.725: E/AndroidRuntime(32431): at android.os.Looper.loop(Looper.java:130)-15 21:01:21.725: E/AndroidRuntime(32431): at android.app.ActivityThread.main(ActivityThread.java:3703)-15 21:01:21.725: E/AndroidRuntime(32431): at java.lang.reflect.Method.invokeNative(Native Method)-15 21:01:21.725: E/AndroidRuntime(32431): at java.lang.reflect.Method.invoke(Method.java:507)-15 21:01:21.725: E/AndroidRuntime(32431): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)-15 21:01:21.725: E/AndroidRuntime(32431): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)-15 21:01:21.725: E/AndroidRuntime(32431): at dalvik.system.NativeStart.main(Native Method)-15 21:01:21.725: E/AndroidRuntime(32431): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class android.support.v4.view.ViewPager-15 21:01:21.725: E/AndroidRuntime(32431): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)-15 21:01:21.725: E/AndroidRuntime(32431): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)-15 21:01:21.725: E/AndroidRuntime(32431): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)-15 21:01:21.725: E/AndroidRuntime(32431): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)-15 21:01:21.725: E/AndroidRuntime(32431): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)-15 21:01:21.725: E/AndroidRuntime(32431): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:212)-15 21:01:21.725: E/AndroidRuntime(32431): at android.app.Activity.setContentView(Activity.java:1681)-15 21:01:21.725: E/AndroidRuntime(32431): at com.trinea.android.demo.ViewPagerDemo.onCreate(ViewPagerDemo.java:28)-15 21:01:21.725: E/AndroidRuntime(32431): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)-15 21:01:21.725: E/AndroidRuntime(32431): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1628)-15 21:01:21.725: E/AndroidRuntime(32431): ... 11 more-15 21:01:21.725: E/AndroidRuntime(32431): Caused by: java.lang.ClassNotFoundException: android.support.v4.view.ViewPager in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/mnt/asec/com.trinea.android.demo-2/pkg.apk]-15 21:01:21.725: E/AndroidRuntime(32431): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)-15 21:01:21.725: E/AndroidRuntime(32431): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)-15 21:01:21.725: E/AndroidRuntime(32431): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)-15 21:01:21.725: E/AndroidRuntime(32431): at android.view.LayoutInflater.createView(LayoutInflater.java:471)-15 21:01:21.725: E/AndroidRuntime(32431): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
2. java. lang. ClassNotFoundException: Didn't find class "android. support. v4.view. ViewPager" on path:/data/app/XXX.apk
Solution:Put the third-party package (android-support-v4.jar) in the libs under the project directory, right-click the project and choose: Build Path-> use as source folder, then OK. Then Add jar to Add the android-support-v4.jar.
Summary:In this case, the solution is to import the jar package to the project directory, which can be placed in Android private. This is automatically loaded by the adt when the add-on is intended, you can also Add the jar directly by yourself. Pay attention to the duplicate problem of the package. It is not easy to make it clear and solve it as needed.
Supplement: other available methods
1. Check the android-support-v4.jar in Order and Export in Java Build Path in properties of the project.
2. Right-click the Project and choose "Android Tools"> "FIx Project Properties.