GVKun编程网logo

HttpResponse cannot be resolved to a type android

11

对于想了解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

HttpResponse cannot be resolved to a type android

HttpResponse cannot be resolved to a type  android

解决方法:

  1. 确定导入了httpclient包

  2. 将android6.0 改成5.0

.w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotAcce...

.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.

Thu Nov 21 15:01:12 CST 2019
There was an unexpected error (type=Not Acceptable, status=406).
Could not find acceptable representation
org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
 
改为
@RequestMapping(value = "/getDynamicByDynamicId1",produces = "application/json")
@ResponseBody
public Dynamic getDynamicByDynamicId1(){
System.out.println();
return dynamicMapper.getDynamicByAnnotationFromDynamicId(1l);
}

android-import android.support cannot be resolved

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的实例源码

android.net.http.HttpResponseCache的实例源码

项目:volley-it    文件:MainActivity.java   
/**
 * 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;

}
项目:StreamAds-Android    文件:SampleListActivity.java   
@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);
    }
}
项目:android-rest-example    文件:MyApplication.java   
@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);
    }
}
项目:XDA-One    文件:RetrofitClient.java   
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);
                }
            });
}
项目:MvpPlus    文件:MyIntentService.java   
protected void onStop() {

        Httpresponsecache cache = Httpresponsecache.getInstalled();
        if (cache != null) {
            cache.flush();
        }
    }
项目:Odyssey2017    文件:FeedActivity.java   
@Override
protected void onStop() {
    super.onStop();
   Httpresponsecache cache = Httpresponsecache.getInstalled();
    if(cache != null) {  //Clearing the cache
        cache.flush();
    }
}
项目:Odyssey2017    文件:FeedActivity.java   
public void cacher()
{
    httpCacheDir = getExternalCacheDir();
    try {
        Httpresponsecache.install(httpCacheDir,httpCacheSize); //Setting the cache
    } catch (Exception e) {
        e.printstacktrace();
    }
}
项目:YalpStore    文件:YalpStoreApplication.java   
@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();
}
项目:pandroid    文件:NetworkUtils.java   
/**
 * 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);
    }
}
项目:Android-High-Performance-Programming    文件:responsecache.java   
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);
    }
}
项目:Android-High-Performance-Programming    文件:responsecache.java   
protected void onStop() {
    super.onStop();
    Httpresponsecache cache = Httpresponsecache.getInstalled();
    if (cache != null) {
        cache.flush();
    }
}
项目:android-restless    文件:FileCache.java   
@Override
public void put(Request key,HttpResponse value) {
    Httpresponsecache cache = Httpresponsecache.getInstalled();
    if (cache != null) {
        cache.flush();
    }
}
项目:android-restless    文件:FileCache.java   
@Override
public void clear() throws IOException {
    Httpresponsecache cache = Httpresponsecache.getInstalled();
    if (cache != null) {
        cache.delete();
    }
    Httpresponsecache.install(file,size);
}
项目:android-lite    文件:MainActivity.java   
@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();
}
项目:android-lite    文件:MainActivity.java   
@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);
    }
}
项目:PowerToggles    文件:ThemePicker.java   
@Override
protected void onPause() {
  Httpresponsecache cache = Httpresponsecache.getInstalled();
  if (cache != null) {
      cache.flush();
  }
  super.onPause();
}
项目:volley-it    文件:MainActivity.java   
/**
 * 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.");
    }
}
项目:volley-it    文件:MainActivity.java   
/**
 * 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();

}
项目:mbira-android-template    文件:LoadingActivity.java   
@Override
protected void onStop() {
    super.onStop();
    Httpresponsecache cache = Httpresponsecache.getInstalled();
    if (cache != null) {
        cache.flush();
    }
}
项目:wordpress_app_android    文件:wordpress.java   
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");
    }
}
项目:sonarflow-android    文件:MainActivity.java   
protected void onStop() {
    Httpresponsecache cache = Httpresponsecache.getInstalled();
    if (cache != null) {
        cache.flush();
    }
    super.onStop();
}
项目:lighthttp    文件:CacheUtil.java   
@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;
}
项目:mc_backup    文件:UrlConnectionDownloader.java   
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;
}
项目:FullRobolectricTestSample    文件:ShadowHttpresponsecache.java   
@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;
  }
}
项目:FullRobolectricTestSample    文件:HttpresponsecacheTest.java   
@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);
}
项目:FullRobolectricTestSample    文件:HttpresponsecacheTest.java   
@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();
}
项目:CampusFeedv2    文件:Api.java   
private Api(Context context) {
    try {
        File httpCacheDir = new File(context.getCacheDir(),httpCacheSize);
    } catch (IOException e) {
        Log.i("Api","HTTP response cache installation Failed:" + e);
    }
}
项目:CampusFeedv2    文件:Api.java   
@Override
public void close() throws IOException {
    Httpresponsecache cache = Httpresponsecache.getInstalled();
    if (cache != null) {
        cache.flush();
    }
}
项目:picasso    文件:UrlConnectionDownloader.java   
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;
}
项目:Qshp    文件:PostContentActivity.java   
@Override
public void onStop() {
    super.onStop();
    mAdapter.changeCursor(null);
    Httpresponsecache cache = Httpresponsecache.getInstalled();
    if (cache != null) {
        cache.flush();
    }
}
项目:UnCafe    文件:CoffeePlacesApplication.java   
/**
 *
 */
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();
    }
}
项目:android-rest-example    文件:MyApplication.java   
@Override
public void onTerminate() {
    super.onTerminate();

    // Todo clear cookiestore content here

    // remove cached files
    Httpresponsecache cache = Httpresponsecache.getInstalled();
    if (cache != null) {
        cache.flush();
    }
}
项目:Podcatcher-Deluxe-Android-Studio    文件:Podcatcher.java   
@Override
public void run() {
    Process.setThreadPriority(THREAD_PRIORITY_BACKGROUND);

    final Httpresponsecache cache = Httpresponsecache.getInstalled();
    if (cache != null)
        cache.flush();
}
项目:PkRSS    文件:DefaultDownloader.java   
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);
    }
}
项目:SadPanda    文件:SadPandaApp.java   
@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);
    }
}
项目:Impeller    文件:ImpellerApplication.java   
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);
        }
    }
}
项目:aview    文件:AviewApplication.java   
@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);
    }
}
项目:aview    文件:AviewApplication.java   
@Override
@Trace
public void onTerminate() {
    super.onTerminate();
    aviewVideoService.close();

    Httpresponsecache cache = Httpresponsecache.getInstalled();
    if (cache != null) {
        cache.flush();
    }

}
项目:xr    文件:HomeActivity.java   
@Override
protected void onStop() {
    Httpresponsecache cache = Httpresponsecache.getInstalled();
    if (cache != null) {
        cache.flush();
    }

    eventBus.unregister(this);
    super.onStop();
}
项目:android-restless    文件:FileCache.java   
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

android.support.v4.view.NestedScrollingChild cannot be resolved

OSC 请你来轰趴啦!1028 苏州源创会,一起寻宝 AI 时代

问题记录:

我用 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的相关知识,请在本站寻找。

本文标签: