Before you start to configure Beagle for your Android system, it’s important to check out if you have installed all the current versions of the following programs:
This tutorial will configure Beagle from the Start.
Add mavenCentral()
into the All projects
block on your Project Gradle file(build.gradle)allprojects {
repositories {
google()
mavenCentral()
}
}
Add the packagingOptions code block to the build.gradle file, as in the example below.
The version numbers listed below may have been updated. Please check the actual versions on the tags above:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
}
dependencies {
implementation "br.com.zup.beagle:android:1.9.0"
implementation "br.com.zup.beagle:beagle-grpc-android:1.0.0"
kapt "br.com.zup.beagle:android-processor:1.9.0"
}
HttpClient
that will be used by Beagle to perform requests.const val BASE_URL = "http://10.0.2.2:8080" // your gRPC host
@BeagleComponent
class AppHttpClientFactory: HttpClientFactory {
override fun create(): HttpClient {
return GrpcClient(BASE_URL, HttpClientDefault())
}
}
Here, we are telling Beagle to use GrpcClient
to perform network requests.
Let’s look to the constructor params of GrpcClient
:
grpcAddress
: Host of your gRPC server. Every request pointing to this host will be performed by GrpcClient
.customHttpClient
: All requests made to another host will be performed by this HttpClient
.Therefore, a request to http://10.0.2.2:8080/foo
will be performed by GrpcClient
and a request to another host, let’s say, http://127.0.1.1:5555/bar
will be performed by HttpClientDefault
.
The HttpClientDefault
implementation can be found at Beagle-Default lib.
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.