对于想了解HttpResponsecannotberesolvedtoatypeandroid的读者,本文将是一篇不可错过的文章,并且为您提供关于.w.s.m.s.DefaultHandlerExce
对于想了解HttpResponse cannot be resolved to a type android的读者,本文将是一篇不可错过的文章,并且为您提供关于.w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotAcce...、android-import android.support cannot be resolved、android.net.http.HttpResponseCache的实例源码、android.support.v4.view.NestedScrollingChild cannot be resolved的有价值信息。
本文目录一览:- HttpResponse cannot be resolved to a type android
- .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotAcce...
- android-import android.support cannot be resolved
- android.net.http.HttpResponseCache的实例源码
- android.support.v4.view.NestedScrollingChild cannot be resolved
HttpResponse cannot be resolved to a type android
HttpResponse cannot be resolved to a type android
解决方法:
确定导入了httpclient包
将android6.0 改成5.0
.w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotAcce...
当想要返回的是json数据,produces写的"text/plain",会报错
@RequestMapping(value = "/getDynamicByDynamicId1",produces = "text/plain")
@ResponseBody
public Dynamic getDynamicByDynamicId1(){
System.out.println();
return dynamicMapper.getDynamicByAnnotationFromDynamicId(1l);
}
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
@RequestMapping(value = "/getDynamicByDynamicId1",produces = "application/json")
@ResponseBody
public Dynamic getDynamicByDynamicId1(){
System.out.println();
return dynamicMapper.getDynamicByAnnotationFromDynamicId(1l);
}
android-import android.support cannot be resolved
解决方法:
1、右击当前工程,查找Properties
2、选择Java Build Path
3、选择Libraries tab,点击右边面板的Add External JARs按钮
4、选择android-support-v4.jar文件(你安装的Android SDK 目录),这一文件的常见路径为:D:\android-sdks\extras\android\support\v4\android-support-v4.jar
(有可能是缺少别的,同理)
5、完成添加后,选择Order and Export标签,勾选,确认即可。
android.net.http.HttpResponseCache的实例源码
/** * Fetches an entry value from the Httpresponsecache cache * @param connection connection from which we need the cache * @param uri uri to use to get the cache entry * @return cache entry value as String */ private String fetchFromHTTPUrlConnectionCache(HttpURLConnection connection,URI uri) { try { Httpresponsecache responsecache = Httpresponsecache.getInstalled(); if(responsecache != null){ CacheResponse cacheResponse = responsecache.get(uri,"GET",connection.getRequestProperties()); Scanner scanner = new Scanner(cacheResponse.getBody(),"UTF-8"); StringBuilder sb = new StringBuilder(); while (scanner.hasNextLine()){ sb.append(scanner.nextLine()); } return sb.toString(); } } catch (Exception ex) { ex.printstacktrace(); } return null; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_single_pane); Toolbar toolbar = (Toolbar) findViewById(R.id.app_toolbar); setSupportActionBar(toolbar); if (savedInstanceState == null) { FragmentManager.enableDebugLogging(true); getSupportFragmentManager().beginTransaction() .add(R.id.container,SampleListFragment.newInstance(),SampleListFragment.TAG) .commit(); } // http response cache File httpCacheDir = new File(getCacheDir(),"http"); long httpCacheSize = 100 * 1024 * 1024; // 100 MiB try { Httpresponsecache.install(httpCacheDir,httpCacheSize); } catch (IOException e) { Log.i(SampleListActivity.class.getSimpleName(),"HTTP response cache installation Failed:" + e); } }
@Override public void onCreate() { super.onCreate(); // cookie store CookieManager cookieManager = new CookieManager(); cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cookieManager); // init cache for http responses try { File httpCacheDir = new File(getApplicationContext().getCacheDir(),"http"); long httpCacheSize = 10 * 1024 * 1024; // 10 MiB Httpresponsecache.install(httpCacheDir,httpCacheSize); } catch(IOException e){ Log.i(TAG,"HTTP response cache installation Failed:" + e); } }
public static RestAdapter.Builder getRestBuilder(final Context context,final String url) { if (!sresponsecache) { try { final File httpCacheDir = new File(context.getCacheDir(),"http"); final long httpCacheSize = 10 * 1024 * 1024; // 10 MiB Httpresponsecache.install(httpCacheDir,httpCacheSize); } catch (IOException e) { e.printstacktrace(); } sresponsecache = true; } return new RestAdapter.Builder() .setEndpoint(url) .setConverter(JACKSON_CONVERTER) .setRequestInterceptor(new RequestInterceptor() { @Override public void intercept(RequestFacade request) { request.addHeader("Authorization","Basic " + XDAConstants.ENCODED_AUTHORIZATION); } }); }
protected void onStop() { Httpresponsecache cache = Httpresponsecache.getInstalled(); if (cache != null) { cache.flush(); } }
@Override protected void onStop() { super.onStop(); Httpresponsecache cache = Httpresponsecache.getInstalled(); if(cache != null) { //Clearing the cache cache.flush(); } }
public void cacher() { httpCacheDir = getExternalCacheDir(); try { Httpresponsecache.install(httpCacheDir,httpCacheSize); //Setting the cache } catch (Exception e) { e.printstacktrace(); } }
@Override public void onCreate() { super.onCreate(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { try { Httpresponsecache.install(new File(getCacheDir(),"http"),5 * 1024 * 1024); } catch (IOException e) { Log.e(getClass().getSimpleName(),"Could not register cache " + e.getMessage()); } } PreferenceManager.setDefaultValues(this,R.xml.settings,false); Thread.setDefaultUncaughtExceptionHandler(new YalpStoreUncaughtExceptionHandler(getApplicationContext())); registerDownloadReceiver(); registerinstallreceiver(); }
/** * Enable caching for http request : must use HttpUrlConnection ! * see : <a href="http://developer.android.com/reference/android/net/http/Httpresponsecache.html">Httpresponsecache</a> * * @param context */ public static void enableHttpCaching(Context context) { long httpCacheSize = 10 * 1024 * 1024; // 10 MiB try { File httpCacheDir = new File(context.getCacheDir(),"http"); Httpresponsecache.install(httpCacheDir,httpCacheSize); } catch (IOException e) { Log.i("","HTTP response cache Failed:" + e); } }
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { File httpCacheDir = new File(getCacheDir(),"http"); long httpCacheSize = 0; Httpresponsecache.install(httpCacheDir,httpCacheSize); } catch (IOException e) { Log.i(getClass().getName(),"HTTP response cache installation Failed:" + e); } }
protected void onStop() { super.onStop(); Httpresponsecache cache = Httpresponsecache.getInstalled(); if (cache != null) { cache.flush(); } }
@Override public void put(Request key,HttpResponse value) { Httpresponsecache cache = Httpresponsecache.getInstalled(); if (cache != null) { cache.flush(); } }
@Override public void clear() throws IOException { Httpresponsecache cache = Httpresponsecache.getInstalled(); if (cache != null) { cache.delete(); } Httpresponsecache.install(file,size); }
@Override protected void onStop() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { final Httpresponsecache cache = Httpresponsecache.getInstalled(); if (cache != null) { cache.flush(); } } super.onStop(); }
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void enableHttpresponsecache() { final long httpCacheSize = 10 * 1024 * 1024; final File httpCacheDir = new File(getCacheDir(),"http"); try { Httpresponsecache.install(httpCacheDir,httpCacheSize); } catch (final IOException e) { throw new RuntimeException(e); } }
@Override protected void onPause() { Httpresponsecache cache = Httpresponsecache.getInstalled(); if (cache != null) { cache.flush(); } super.onPause(); }
/** * Installs the Httpresponsecache * Note this will only work on Android 4.0+ */ private void enableHttpresponsecache() { try { long httpCacheSize = 10 * 1024 * 1024; // 10 MiB File httpCacheDir = new File(getCacheDir(),httpCacheSize); } catch (Exception httpresponsecacheNotAvailable) { Log.d(TAG,"HTTP response cache is unavailable."); } }
/** * Invalidates both Httpresponsecache and Volley cache * @param view */ public void invalidateCache(View view) { mRequestQueue.getCache().clear(); try { Httpresponsecache cache = Httpresponsecache.getInstalled(); if(cache != null) cache.delete(); } catch (IOException e) { e.printstacktrace(); } Toast.makeText(this,"Cache is Now empty",Toast.LENGTH_SHORT).show(); }
@Override protected void onStop() { super.onStop(); Httpresponsecache cache = Httpresponsecache.getInstalled(); if (cache != null) { cache.flush(); } }
private static void enableHttpresponsecache(Context context) { try { long httpCacheSize = 5 * 1024 * 1024; // 5MB File httpCacheDir = new File(context.getCacheDir(),httpCacheSize); } catch (IOException e) { AppLog.w(T.UTILS,"Failed to enable http response cache"); } }
protected void onStop() { Httpresponsecache cache = Httpresponsecache.getInstalled(); if (cache != null) { cache.flush(); } super.onStop(); }
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private static Httpresponsecache installHttpresponsecache(final File cacheDir) throws IOException { Httpresponsecache cache = Httpresponsecache.getInstalled(); if (cache == null) { final long maxSize = calculatediskCacheSize(cacheDir); cache = Httpresponsecache.install(cacheDir,maxSize); } return cache; }
static Object install(Context context) throws IOException { File cacheDir = Utils.createDefaultCacheDir(context); Httpresponsecache cache = Httpresponsecache.getInstalled(); if (cache == null) { long maxSize = Utils.calculatediskCacheSize(cacheDir); cache = Httpresponsecache.install(cacheDir,maxSize); } return cache; }
@Implementation public static Httpresponsecache install(File directory,long maxSize) { Httpresponsecache cache = newInstanceOf(Httpresponsecache.class); ShadowHttpresponsecache shadowCache = Robolectric.shadowOf(cache); shadowCache.originalObject = cache; shadowCache.directory = directory; shadowCache.maxSize = maxSize; synchronized (LOCK) { installed = shadowCache; return cache; } }
@Test public void installedCacheIsReturned() throws Exception { assertthat(Httpresponsecache.getInstalled()).isNull(); Httpresponsecache cache = Httpresponsecache.install(File.createTempFile("foo","bar"),42); Httpresponsecache installed = Httpresponsecache.getInstalled(); assertthat(installed).isSameAs(cache); assertthat(installed.maxSize()).isEqualTo(42); }
@Test public void countsstartAtZero() throws Exception { Httpresponsecache cache = Httpresponsecache.install(File.createTempFile("foo",42); assertthat(cache.getHitCount()).isZero(); assertthat(cache.getNetworkCount()).isZero(); assertthat(cache.getRequestCount()).isZero(); }
private Api(Context context) { try { File httpCacheDir = new File(context.getCacheDir(),httpCacheSize); } catch (IOException e) { Log.i("Api","HTTP response cache installation Failed:" + e); } }
@Override public void close() throws IOException { Httpresponsecache cache = Httpresponsecache.getInstalled(); if (cache != null) { cache.flush(); } }
static Object install(Context context) throws IOException { File cacheDir = Utils.createDefaultCacheDir(context); Httpresponsecache cache = Httpresponsecache.getInstalled(); if (cache == null) { long maxSize = Utils.calculatediskCacheSize(cacheDir); cache = Httpresponsecache.install(cacheDir,maxSize); } return cache; }
@Override public void onStop() { super.onStop(); mAdapter.changeCursor(null); Httpresponsecache cache = Httpresponsecache.getInstalled(); if (cache != null) { cache.flush(); } }
/** * */ private void initCacheFile() { try { httpCacheDir = new File(getCacheDir(),"http"); httpCacheDir.setReadable(true); Httpresponsecache.install(httpCacheDir,httpCacheSize); cache = new Cache(httpCacheDir,httpCacheSize); } catch (Exception e) { e.printstacktrace(); } }
@Override public void onTerminate() { super.onTerminate(); // Todo clear cookiestore content here // remove cached files Httpresponsecache cache = Httpresponsecache.getInstalled(); if (cache != null) { cache.flush(); } }
@Override public void run() { Process.setThreadPriority(THREAD_PRIORITY_BACKGROUND); final Httpresponsecache cache = Httpresponsecache.getInstalled(); if (cache != null) cache.flush(); }
public DefaultDownloader(Context context) { cacheDir = new File(context.getCacheDir(),"http"); try { Httpresponsecache.install(cacheDir,cacheSize); } catch (IOException e) { Log.i(TAG,"HTTP response cache installation Failed:" + e); } }
@Override public void onCreate() { super.onCreate(); File httpCacheDir = new File(getCacheDir(),HTTP_CACHE_SIZE); } catch (IOException e) { Log.e(TAG,"Failed to create http cache!",e); } }
private void tryInstallresponsecache() { if(Httpresponsecache.getInstalled() == null) { File cacheDir = new File(getCacheDir(),"http"); try { Httpresponsecache.install(cacheDir,10 * 1024 * 1024); } catch (IOException e) { Log.w(TAG,"Creating response cache",e); } } }
@AfterInject @Trace(tag = TAG,level = Log.DEBUG) void init() { // if (BuildConfig.DEBUG) { // aviewPrefs.pref_openedDrawer().put(false); // } // Create a unique id for this install if one doesn't already exist if (!aviewPrefs.ivid().exists()) { if (Log.isLoggable(TAG,Log.DEBUG)) Log.d(TAG,"Creating new ivid"); aviewPrefs.ivid().put(UUID.randomUUID().toString()); } if (Log.isLoggable(TAG,Log.DEBUG)) Log.d(TAG,"ivid=" + aviewPrefs.ivid().get()); // Create a cache for automatically caching HTTP requests try { File httpCacheDir = new File(this.getCacheDir(),httpCacheSize); } catch (IOException e) { if (Log.isLoggable(TAG,Log.INFO)) Log.i(TAG,"HTTP response cache installation Failed:" + e); } }
@Override @Trace public void onTerminate() { super.onTerminate(); aviewVideoService.close(); Httpresponsecache cache = Httpresponsecache.getInstalled(); if (cache != null) { cache.flush(); } }
@Override protected void onStop() { Httpresponsecache cache = Httpresponsecache.getInstalled(); if (cache != null) { cache.flush(); } eventBus.unregister(this); super.onStop(); }
public FileCache(File file,long size) throws IOException { this.file = file; this.size = size; Httpresponsecache.install(file,size); }
android.support.v4.view.NestedScrollingChild cannot be resolved

问题记录:
我用 eclipse 引入了 Sdk 自带的 android-support-v7-recyclerview.jar,然后使用 SwiperefreshLayout+RecyclerView 做下拉刷新,在写适配器的时候出现了一个问题;
最后发现是我 android-support-v4.jar 和 android-support-v7-recyclerview.jar 不一致导致的,最后换了 v4 jar 包就解决的,不然有些方法不能使用的,做个小记录。
小结:
在引入官方 support 库时,务必保证版本一致;在引入第三方库时,务必查看第三方库的依赖库,避免坑。!
关于HttpResponse cannot be resolved to a type android的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于.w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotAcce...、android-import android.support cannot be resolved、android.net.http.HttpResponseCache的实例源码、android.support.v4.view.NestedScrollingChild cannot be resolved的相关知识,请在本站寻找。
本文标签: