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()
}
}
apply plugin: 'kotlin-kapt'
android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
}
dependencies {
implementation "br.com.zup.beagle:android:1.5.1"
kapt "br.com.zup.beagle:android-processor:1.5.1"
implementation "br.com.zup.beagle:beagle-defaults:0.0.4"
}
1. Create an AppBeagleConfig file:
@BeagleComponent
class AppBeagleConfig: BeagleConfig {
override val environment: Environment = Environment.DEBUG
override val baseUrl: String = "https://adopt-beagle.continuousplatform.com/scaffold"
}
2. Create an HttpApp file as listed below. This class extends from an ´HttpClientDefault()´ class at the Beagle-Default lib:
@BeagleComponent
class HttpApp: HttpClientDefault()
3. Create a LoggerApp file as listed below. This class extends from a ´BeagleLoggerDefault()´ class at the Beagle-Default lib:
@BeagleComponent
class LoggerApp: BeagleLoggerDefault()
class AppApplication : Application() {
override fun onCreate() {
super.onCreate()
APPLICATION = this
BeagleSetup().init(this)
}
companion object {
var APPLICATION: Application? = null
}
}
To test it you just need to call a screen from the BFF sample.
To do that you need to start an activity using the configuration below:
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val intent = this.newServerDrivenIntent<ServerDrivenActivity>(RequestData("/components"))
startActivity(intent)
}
}
A sample screen with all Beagle components will show on your emulator screen.
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.