以上就是给各位分享java.io.IOException:Targethostmustnotbenull,orsetinparameters.scheme=null,host=null,...,同时本
以上就是给各位分享java.io.IOException: Target host must not be null, or set in parameters. scheme=null, host=null, ...,同时本文还将给你拓展android – IllegalArgumentException:savedInstanceState指定为Non-Null为Null、android – java.lang.IllegalArgumentException:指定为非null的参数为null:方法kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull、android – 目标主机不能为null或在parameters.scheme = null,host = null中设置、c# – Asp.Net Core 2.0 ArgumentNullException:值不能为null.参数名称:connectionString等相关知识,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:- java.io.IOException: Target host must not be null, or set in parameters. scheme=null, host=null, ...
- android – IllegalArgumentException:savedInstanceState指定为Non-Null为Null
- android – java.lang.IllegalArgumentException:指定为非null的参数为null:方法kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull
- android – 目标主机不能为null或在parameters.scheme = null,host = null中设置
- c# – Asp.Net Core 2.0 ArgumentNullException:值不能为null.参数名称:connectionString
java.io.IOException: Target host must not be null, or set in parameters. scheme=null, host=null, ...
使用的 xutils
出现标题中的错误
原因:没有添加 Cookie
1 params.addHeader("Cookie", CurrentUserSettings.getCookies());
加上之后问题解决
Cookie通过以下方式获取
final HttpUtils httpUtils = new HttpUtils();
params.setPriority(Priority.BG_TOP);
httpUtils.send(HttpRequest.HttpMethod.POST, url, params, new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
DefaultHttpClient defaultHttpClient = (DefaultHttpClient) httpUtils.getHttpClient();
List<Cookie> cookies = defaultHttpClient.getCookieStore().getCookies();
if (cookies.size() > 0) {
CurrentUserSettings.setCookies(cookies.get(0).getName() + "=" + cookies.get(0).getValue());
}
}
}
android – IllegalArgumentException:savedInstanceState指定为Non-Null为Null
当我启动MainActivity时出现一个奇怪的错误:
06-16 16:01:05.193 2083-2083/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.android.example.github, PID: 2083
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.example.github/com.android.example.github.ui.MainActivity}: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter savedInstanceState
at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:2666)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter savedInstanceState
at com.android.example.github.injection.AppInjector$init$1.onActivityCreated(AppInjector.kt)
at android.app.Application.dispatchActivityCreated(Application.java:197)
at android.app.Activity.onCreate(Activity.java:961)
at android.support.v4.app.BaseFragmentActivityGingerbread.onCreate(BaseFragmentActivityGingerbread.java:54)
at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:319)
at com.android.example.github.ui.MainActivity.onCreate(MainActivity.kt:20)
at android.app.Activity.performCreate(Activity.java:6682)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:2619)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
这是我的MainActivity类:
class MainActivity : LifecycleActivity(), HasSupportFragmentInjector {
lateinit var dispatchingAndroidInjector: dispatchingAndroidInjector<Fragment>
@Inject set
lateinit var navigationController: NavigationController
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.main_activity)
if (savedInstanceState == null) {
navigationController.navigatetoSearch()
}
}
override fun supportFragmentInjector(): AndroidInjector<Fragment> {
return dispatchingAndroidInjector
}
}
该错误表明参数savedInstanceState为null,当它被指定为非null时;但它可以为空(savedInstanceState:Bundle?),并且onCreate()方法在源中标记为@Nullable.
我在任何其他Kotlin项目中都没有遇到过这个错误.我正在使用Kotlin版本1.1.2-5;与1.1.2-3有同样的错误.
解决方法:
似乎问题不在onCreate方法中.尝试查看com.android.example.github.injection.AppInjector $init $1.onActivityCreated(AppInjector.kt).我不知道它是否是一个生成的类,但它应该让你知道下一步该做什么.
android – java.lang.IllegalArgumentException:指定为非null的参数为null:方法kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull
java.lang.IllegalArgumentException:指定为非null的参数为null:方法kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull,参数事件
为线
覆盖fun onEditorAction(v:TextView,actionId:Int,event:KeyEvent)
以下是整个代码.这段代码最初是在java中,我使用Android Studio将其转换为Kotlin,但现在我收到了这个错误.我尝试重建和清理项目,但这没有用.
val action = supportActionBar //get the actionbar action!!.setdisplayShowCustomEnabled(true) //enable it to display a custom view in the action bar. action.setCustomView(R.layout.search_bar)//add the custom view action.setdisplayShowTitleEnabled(false) //hide the title edtSearch = action.customView.findViewById(R.id.edtSearch) as EditText //the text editor //this is a listener to do a search when the user clicks on search button edtSearch?.setonEditorActionListener(object : TextView.OnEditorActionListener { override fun onEditorAction(v: TextView,actionId: Int,event: KeyEvent): Boolean { if (actionId == EditorInfo.IME_ACTION_SEARCH) { Log.e("TAG","search button pressed") //doSearch() return true } return false } })
解决方法
KeyEvent
: If triggered by an enter key,this is the event; otherwise,this is null.
所以你需要做的就是让Kotlin类型为空可以解释这个问题,否则注入的null检查会在你的应用程序获得一个带有null值的调用时崩溃,就像你已经看到它一样:
edtSearch?.setonEditorActionListener(object : TextView.OnEditorActionListener { override fun onEditorAction(v: TextView,event: KeyEvent?): Boolean { ... } })
有关this answer平台类型的更多说明.
android – 目标主机不能为null或在parameters.scheme = null,host = null中设置
我得到以下例外:
Target host must not be null or set in parameters.scheme=null,
host=null,path=/webservices/tempconvert.asmx/FahrenheitToCelsius
我的源代码:
public class Paractivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView t=new TextView(this);
String encodedUrl = null;
// setContentView(R.layout.main);
HttpClient client = new DefaultHttpClient();
//String query = "?Fahrenheit=26";
// String host = "www.w3schools.com/webservices/tempconvert.asmx/";
// encodedUrl = host + URLEncoder.encode(query,"utf-8");
// int p=(Integer) null;
// URI uri = URIUtils.createURI("vv", "www.w3schools.com", 50, "/webservices/tempconvert.asmx", "?Fahrenheit=26", null);
try{
String postURL = "/webservices/tempconvert.asmx/FahrenheitToCelsius";
HttpPost post = new HttpPost(postURL);
// post.addHeader("scheme","vv");
// post.setHeader("host", "www.w3schools.com");
String PostData="36";
StringEntity httpPostEntity = new StringEntity(PostData, HTTP.UTF_8);
post.setEntity(httpPostEntity);
post.setHeader("host", "www.w3schools.com");
post.setHeader("Content-Length", new Integer(PostData.length()).toString());
post.setHeader("Content-Type", "application/x-www-form-urlencoded");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
// nameValuePairs.add(new BasicNameValuePair("host", "www.w3schools.com"));
nameValuePairs.add(new BasicNameValuePair("Fahrenheit", "26"));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse responsePOST = null;
// Execute HTTP Post Request
// HttpResponse response = httpclient.execute(post);
client.getConnectionManager();
responsePOST = client.execute(post);
httpentity resEntity = responsePOST.getEntity();
String response=EntityUtils.toString(resEntity);
response=response.trim();
// Log.i("RESPONSE=",response);
t.setText("response"+response);
setContentView(t);
} catch (Exception e) {
// Todo Auto-generated catch block
//e.printstacktrace();
t.setText("ex"+e.getMessage());
setContentView(t);
}
}
}
我想在以下位置调用webservice:
http://www.w3schools.com/webservices/tempconvert.asmx?op=CelsiusToFahrenheit
使用HttpClient.How应该给主机和方案作为输入?
请帮忙…
解决方法:
这是您的主机错误
您在post.setHeader(“主持人”,“www.w3schools.com”)中传递“www.w3schools.com”;而你必须通过“http://www.w3schools.com”
您可以在here中引用相同的问题
c# – Asp.Net Core 2.0 ArgumentNullException:值不能为null.参数名称:connectionString
我是第一次使用数据库,我遇到了以下问题:
unhandled exception occurred while processing the request.
ArgumentNullException: Value cannot be null.
Parameter name: connectionString.
在阅读并尝试每一个可能的建议以及可能的解决方案之后,问
public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddDbContext<VideosContext>(options => options.UsesqlServer(Configuration.GetConnectionString("DefaultConnection"))); } public void Configure(IApplicationBuilder app,IHostingEnvironment env) { if (env.IsDevelopment()) { app.UsebrowserLink(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default",template: "{controller=Home}/{action=Index}/{id?}"); }); } } { "ConnectionString": { "DefaultConnection": "Server =(localdb)\\mssqllocaldb;Database=Videos;Trusted_Connection=True;MultipleActiveResultSets=true" },"Logging": { "IncludeScopes": false,"LogLevel": { "Default": "Warning" } } } public static void Main(string[] args) { BuildWebHost(args).Run(); } public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .Build();
我究竟做错了什么?提前感谢您的任何建议.
解决方法
{ "ConnectionStrings": { "DefaultConnection": "Server =(localdb)\\mssqllocaldb;Database=Videos;Trusted_Connection=True;MultipleActiveResultSets=true" } }
关于java.io.IOException: Target host must not be null, or set in parameters. scheme=null, host=null, ...的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于android – IllegalArgumentException:savedInstanceState指定为Non-Null为Null、android – java.lang.IllegalArgumentException:指定为非null的参数为null:方法kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull、android – 目标主机不能为null或在parameters.scheme = null,host = null中设置、c# – Asp.Net Core 2.0 ArgumentNullException:值不能为null.参数名称:connectionString等相关内容,可以在本站寻找。
本文标签: