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()
jcenter()
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-android-extensions'
id 'kotlin-kapt'
}
android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11
}
packagingOptions {
pickFirst 'META-INF/LICENSE.md'
pickFirst 'META-INF/LICENSE-notice.md'
}
}
dependencies {
kapt "br.com.zup.beagle:android-processor:${beagleVersion}"
implementation "br.com.zup.beagle:beagle-grpc:${beagleVersion}"
}
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, you 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, for example 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.