This means that the Mappls SDK is compiled with Java 8 compatibility. It does not prevent you from using Java 11 in your project.
Using Java 11:
You can use Java 11. The compile options ensure that the generated bytecode is compatible with Java 8, which is the standard for many Android projects. Just make sure that your Gradle and Android Gradle Plugin versions support Java 11.
Adding API Keys in MainActivity.kt
Where to Initialize:
You need to initialize the API keys before you use any Mappls functionality. Placing the initialization in your MainActivity is acceptable.
Implementation Detail:
Make sure you override the onCreate() method in your MainActivity to run the initialization code. For example:
should be added to the layout XML file where you want the map to appear. For example, if your activity uses activity_main.xml as its layout, you can include it there.
Integration in Layout:
If you’re using an Activity or Fragment, add the <MapView> element to the appropriate XML file. Then, in your Kotlin/Java code, you can reference and manage this view as needed.
class MainActivity : FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.base_layout)
mapView = findViewById(R.id.map_view)
mapView.onCreate(savedInstanceState)
MapplsAccountManager.getInstance().restAPIKey = "somekey"
MapplsAccountManager.getInstance().mapSDKKey = "somekey"
MapplsAccountManager.getInstance().atlasClientId = "someId"
MapplsAccountManager.getInstance().atlasClientSecret = "somesec"
Mappls.getInstance(applicationContext)
}
override fun onStart() {
super.onStart()
mapView.onStart()
}
override fun onResume() {
super.onResume()
mapView.onResume()
}
override fun onPause() {
super.onPause()
mapView.onPause()
}
override fun onStop() {
super.onStop()
mapView.onStop()
}
override fun onDestroy() {
super.onDestroy()
mapView.onDestroy()
}
override fun onLowMemory() {
super.onLowMemory()
mapView.onLowMemory()
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
mapView.onSaveInstanceState(outState)
}
}
Also in pubspec.yaml I have added mappls_gl: ^1.1.2
I have under app/res/layout the file called base_layout and map_view.xml
dependencies {
implementation ‘com.mappls.sdk:mappls-android-sdk:8.2.1’
}
in app/build.gradle
I get the below errors
Unresolved reference: mapView
Unresolved reference: MapplsAccountManager