소개
게시글
질문&답변
2020.03.30
server에서 이미지를 받는데 에러나 나서 업로드가 불가합니다.
client Thread는 다음과 같이 작성되었습니다. var client = OkHttpClient()var request_builder = Request.Builder()var url = request_builder.url("http://172.30.1.18:8080/MobileServer/upload.jsp")var multipart_Builder = MultipartBody.Builder()var file = File(pic_path)multipart_Builder.addFormDataPart("mobile_img",file.name,RequestBody.create(MultipartBody.FORM, file))var body = multipart_Builder.build()var post = url.post(body)var request = post.build()client.newCall(request).execute() server 코드는 다음과 같이 작성되었습니다. request.setCharacterEncoding("utf-8"); String path = getServletContext().getRealPath("upload"); System.out.println(path); int max = 1024 * 1024 * 100; DefaultFileRenamePolicy policy = new DefaultFileRenamePolicy(); System.out.println(request.getContentType()); new MultipartRequest(request, path,max,"multipart/form-data",policy); %>
- 0
- 2
- 517
질문&답변
2020.03.23
okhttp api사용에서 callback함수 오류
다음과 같은 충돌 에러가 뜨네요 Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page. I/zygote64: Rejecting re-init on previously-failed class java.lang.Class: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/conscrypt/ConscryptHostnameVerifier; at okhttp3.internal.platform.android.SocketAdapter okhttp3.internal.platform.android.ConscryptSocketAdapter$Companion.buildIfSupported() (ConscryptSocketAdapter.kt:62) at void okhttp3.internal.platform.AndroidPlatform.() (AndroidPlatform.kt:44) at okhttp3.internal.platform.Platform okhttp3.internal.platform.AndroidPlatform$Companion.buildIfSupported() (AndroidPlatform.kt:212) at okhttp3.internal.platform.Platform okhttp3.internal.platform.Platform$Companion.findPlatform() (Platform.kt:212) at okhttp3.internal.platform.Platform okhttp3.internal.platform.Platform$Companion.access$findPlatform(okhttp3.internal.platform.Platform$Companion) (Platform.kt:169) at void okhttp3.internal.platform.Platform.() (Platform.kt:170) at void okhttp3.OkHttpClient.(okhttp3.OkHttpClient$Builder) (OkHttpClient.kt:224) at void okhttp3.OkHttpClient.() (OkHttpClient.kt:216) I/zygote64: at void com.example.network_project2.MainActivity$NetworkThread.run() (MainActivity.kt:22) Caused by: java.lang.ClassNotFoundException: Didn't find class "org.conscrypt.ConscryptHostnameVerifier" on path: DexPathList[[zip file "/data/app/com.example.network_project2-Mp_L8AN3j6KqUzJuKsCTUw==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.network_project2-Mp_L8AN3j6KqUzJuKsCTUw==/lib/x86_64, /system/lib64, /vendor/lib64]] at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:125) at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379) at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312) at okhttp3.internal.platform.android.SocketAdapter okhttp3.internal.platform.android.ConscryptSocketAdapter$Companion.buildIfSupported() (ConscryptSocketAdapter.kt:62) at void okhttp3.internal.platform.AndroidPlatform.() (AndroidPlatform.kt:44) at okhttp3.internal.platform.Platform okhttp3.internal.platform.AndroidPlatform$Companion.buildIfSupported() (AndroidPlatform.kt:212) at okhttp3.internal.platform.Platform okhttp3.internal.platform.Platform$Companion.findPlatform() (Platform.kt:212) at okhttp3.internal.platform.Platform okhttp3.internal.platform.Platform$Companion.access$findPlatform(okhttp3.internal.platform.Platform$Companion) (Platform.kt:169) at void okhttp3.internal.platform.Platform.() (Platform.kt:170) at void okhttp3.OkHttpClient.(okhttp3.OkHttpClient$Builder) (OkHttpClient.kt:224) I/zygote64: at void okhttp3.OkHttpClient.() (OkHttpClient.kt:216) at void com.example.network_project2.MainActivity$NetworkThread.run() (MainActivity.kt:22) Rejecting re-init on previously-failed class java.lang.Class: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/conscrypt/ConscryptHostnameVerifier; at okhttp3.internal.platform.android.SocketAdapter okhttp3.internal.platform.android.ConscryptSocketAdapter$Companion.buildIfSupported() (ConscryptSocketAdapter.kt:62) at void okhttp3.internal.platform.AndroidPlatform.() (AndroidPlatform.kt:44) at okhttp3.internal.platform.Platform okhttp3.internal.platform.AndroidPlatform$Companion.buildIfSupported() (AndroidPlatform.kt:212) at okhttp3.internal.platform.Platform okhttp3.internal.platform.Platform$Companion.findPlatform() (Platform.kt:212) at okhttp3.internal.platform.Platform okhttp3.internal.platform.Platform$Companion.access$findPlatform(okhttp3.internal.platform.Platform$Companion) (Platform.kt:169) at void okhttp3.internal.platform.Platform.() (Platform.kt:170) at void okhttp3.OkHttpClient.(okhttp3.OkHttpClient$Builder) (OkHttpClient.kt:224) at void okhttp3.OkHttpClient.() (OkHttpClient.kt:216) at void com.example.network_project2.MainActivity$NetworkThread.run() (MainActivity.kt:22) Caused by: java.lang.ClassNotFoundException: Didn't find class "org.conscrypt.ConscryptHostnameVerifier" on path: DexPathList[[zip file "/data/app/com.example.network_project2-Mp_L8AN3j6KqUzJuKsCTUw==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.network_project2-Mp_L8AN3j6KqUzJuKsCTUw==/lib/x86_64, /system/lib64, /vendor/lib64]] at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:125) I/zygote64: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379) at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312) at okhttp3.internal.platform.android.SocketAdapter okhttp3.internal.platform.android.ConscryptSocketAdapter$Companion.buildIfSupported() (ConscryptSocketAdapter.kt:62) at void okhttp3.internal.platform.AndroidPlatform.() (AndroidPlatform.kt:44) at okhttp3.internal.platform.Platform okhttp3.internal.platform.AndroidPlatform$Companion.buildIfSupported() (AndroidPlatform.kt:212) at okhttp3.internal.platform.Platform okhttp3.internal.platform.Platform$Companion.findPlatform() (Platform.kt:212) at okhttp3.internal.platform.Platform okhttp3.internal.platform.Platform$Companion.access$findPlatform(okhttp3.internal.platform.Platform$Companion) (Platform.kt:169) at void okhttp3.internal.platform.Platform.() (Platform.kt:170) at void okhttp3.OkHttpClient.(okhttp3.OkHttpClient$Builder) (OkHttpClient.kt:224) at void okhttp3.OkHttpClient.() (OkHttpClient.kt:216) at void com.example.network_project2.MainActivity$NetworkThread.run() (MainActivity.kt:22) D/NetworkSecurityConfig: No Network Security Config specified, using platform default E/AndroidRuntime: FATAL EXCEPTION: Thread-2 Process: com.example.network_project2, PID: 16577 java.net.SocketException: socket failed: EACCES (Permission denied) at java.net.Socket.createImpl(Socket.java:487) at java.net.Socket.getImpl(Socket.java:547) at java.net.Socket.setSoTimeout(Socket.java:1175) at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:281) at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:195) at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:233) at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:107) at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:75) at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:245) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:82) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:74) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:197) at okhttp3.internal.connection.RealCall.execute(RealCall.kt:148) at com.example.network_project2.MainActivity$NetworkThread.run(MainActivity.kt:27) D/EGL_emulation: eglMakeCurrent: 0x762114e3dfa0: ver 3 1 (tinfo 0x762114e0d4a0) D/OpenGLRenderer: endAllActiveAnimators on 0x7621123ff800 (RippleDrawable) with handle 0x76210776f600
- 0
- 2
- 860