Android compatibility library error

Has anyone else tried a demo application for the new Android compatibility library. Here

I am trying to build v4 on API 11 and I keep getting this error while trying to support 4Demo and click on the tabs and pager in the fragment demonstration

e07-16 21: 32: 06.890: ERROR / AndroidRuntime (15315): java.lang.NoClassDefFoundError: com.example.android.supportv4.app.LoaderCustomSupport $ AppListFragment 07-16 21: 32: 06.890: ERROR / AndroidRuntime (15315) : at com.example.android.supportv4.app.FragmentTabs.onCreate (FragmentTabs.java:55) 07-16 21: 32: 06.890: ERROR / AndroidRuntime (15315): at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java : 1072) 07-16 21: 32: 06.890: ERROR / AndroidRuntime (15315): at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:1785) 07-16 21: 32: 06.890: ERROR / AndroidRuntime (15315): at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:1842) 07-16 21: 32: 06.890: ERROR / AndroidRuntime (15315): at android.app.ActivityThread.access $ 1500 (ActivityThread.java:132) 07-16 21: 32: 06.890: ERROR / AndroidRuntime (15315): when android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1038) 07-16 21: 32: 06.890: ERROR / AndroidRuntime (15315): at android.os.Handler.dispatchMessage (Handler.java:99) 07-16 21: 32: 06.890: ERROR / AndroidRuntime (15315): with android.os.Looper.loop (Looper.java : 143) 07-16 21: 32: 06.890: ERROR / AndroidRuntime (15315): when android.app.ActivityThread.main (ActivityThread.java:4263) 07-16 21: 32: 06.890: ERROR / AndroidRuntime (15315): when java.lang.reflect.Method.invokeNative (native method) 07-16 21: 32: 06.890: ERROR / AndroidRuntime (15315): when java.lang.reflect.Method.invoke (Method.java:507) 07-16 21: 32: 06.890: ERROR / AndroidRuntime (15315): with com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:839) 07-16 21: 32: 06.890: ERROR / AndroidRuntime (15315): at com.android.internal.os.ZygoteInit.main (ZygoteInit.javaβ–Ί97) 07-16 21: 32: 06.890: ERROR / AndroidRuntime (15315): with dalvik.system.NativeStart.main (native method)

Can someone help me with this?

+6
source share
2 answers

I solved this problem by commenting out the correct lines in FragmentTab.onCreate and FragmentTabPager.onCreate.

//mTabManager.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"), // LoaderCustomSupport.AppListFragment.class, null); 
+6
source

The reason the class cannot be found is because one of the interfaces implemented by AppListFragment (OnQuerytextListener) is defined in SearchView, which is found only in Honeycomb (API 11 +).

 public static class AppListFragment extends ListFragment implements OnQueryTextListener, LoaderManager.LoaderCallbacks<List<AppEntry>> { 

I searched in the compatibility bank, but I can not find anything in common with SearchView, so I assume that this will only work on Honeycomb and up (and compiling with a target lower than Honeycomb will prevent this.

There are also several other crashes for the same reason, for example Loader β†’ Throttle, then click on the menu - the missing method.

On the Compatibility Pack page

Warning. Be sure that you are not confusing the standard android packages with the android.support libraries. Some code completion tools may make a mistake, especially if you build against the latest versions of the platform. To be safe, keep the build target the same version as for your android: minSdkVersion and double-check import statements for classes that also exist in the support library, for example SimpleCursorAdapter

Following their own advice, the whole project cannot compile - half of the example classes seem to depend on something more than API 4.

My answer? Some of the examples are bad and rely on code that is not present. In any case, Google will soon update them to work.

Oh yes, you can temporarily make it work by removing OnQueryTextListener and methods from AppListFragment, but later it will work with another problem.

+10
source

Source: https://habr.com/ru/post/892921/


All Articles