androidflutterdartaugmented-realityvirtual-reality

How can I make the AR Core flutter plugin work?


I'm trying to use AR in my flutter app. I'm using the package arcore_flutter_plugin. After adding the plugin, I'm unable to run the app and I get this error (after having disabled the null safety feature) :

e: C:\Users\LENOVO THINKPAD\OneDrive\Bureau\Hackathon\ar_test\android\src\main\kotlin\com\difrancescogianmarco\arcore_flutter_plugin\ArCoreView.kt: (245, 38): Object is not abstract and does not implement abstract member public abstract fun onActivityCreated(p0: Activity, p1: Bundle?): Unit defined in android.app.Application.ActivityLifecycleCallbacks
e: C:\Users\LENOVO THINKPAD\OneDrive\Bureau\Hackathon\ar_test\android\src\main\kotlin\com\difrancescogianmarco\arcore_flutter_plugin\ArCoreView.kt: (246, 13): 'onActivityCreated' overrides nothing

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':arcore_flutter_plugin:compileDebugKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 57s

Can someone help me make it work ?


Solution

  • This is an error in the arcore_flutter_plugin.

    Navigate into the ArCoreView.kt file:

    C:\Users\LENOVO THINKPAD\OneDrive\Bureau\Hackathon\ar_test\android\src\main \kotlin\com\difrancescogianmarco\arcore_flutter_plugin\ArCoreView.kt

    Remove '?' from the following line:

    override fun onActivityCreated(activity: Activity?, savedInstanceState: Bundle?)
    

    New-line:

    override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?)