File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed
core/src/main/kotlin/androidx/build/gradle/core Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2024 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ *
16+ */
17+
18+ package androidx.build.gradle.core
19+
20+ import okhttp3.Interceptor
21+ import okhttp3.Response
22+ import org.gradle.api.GradleException
23+ import java.io.IOException
24+
25+ class NetworkErrorInterceptor : Interceptor {
26+ override fun intercept (chain : Interceptor .Chain ): Response {
27+ val request = chain.request()
28+ return try {
29+ chain.proceed(request)
30+ } catch (ex: IOException ) {
31+ throw GradleException (" There seems to be some issue with the network access. " +
32+ " Please check your internet access or use --offline with your gradle commands to continue working" +
33+ " without accessing network resources." )
34+ }
35+ }
36+ }
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ package androidx.build.gradle.core
1919
2020import com.google.gson.Gson
2121import com.google.gson.GsonBuilder
22+ import okhttp3.OkHttpClient
2223import retrofit2.Call
2324import retrofit2.Retrofit
2425import retrofit2.converter.gson.GsonConverterFactory
@@ -37,9 +38,15 @@ interface TokenInfoService {
3738
3839 companion object {
3940 fun tokenService (): TokenInfoService {
41+ val httpClient = OkHttpClient
42+ .Builder ()
43+ .addInterceptor(NetworkErrorInterceptor ())
44+ .build()
45+
4046 val retrofit = Retrofit .Builder ()
4147 .baseUrl(" https://www.googleapis.com" )
4248 .addConverterFactory(GsonConverterFactory .create(gson()))
49+ .client(httpClient)
4350 .build()
4451
4552 return retrofit.create()
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ gradlePlugin {
5858}
5959
6060group = " androidx.build.gradle.gcpbuildcache"
61- version = " 1.0.0-beta09 "
61+ version = " 1.0.0-beta10 "
6262
6363testing {
6464 suites {
You can’t perform that action at this time.
0 commit comments