Louis
Louis

Reputation: 13

Execution failed for task ':arcore_flutter_plugin:compileDebugKotlin' in Flutter

I want to use Arcore plugin in Flutter but it had this error.

Launching lib\main.dart on Pixel 2 XL in debug mode... lib\main.dart:1 e: C:\src\flutter.pub-cache\hosted\pub.dartlang.org\arcore_flutter_plugin-0.0.11\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:\src\flutter.pub-cache\hosted\pub.dartlang.org\arcore_flutter_plugin-0.0.11\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 17s Exception: Gradle task assembleDebug failed with exit code 1

Can someone help me to solve this please

Upvotes: 0

Views: 1173

Answers (2)

Blaq_2022
Blaq_2022

Reputation: 47

If doing the above still fails and shows CompileDebugKotlin error then this should finish the job

Found a solution, modify two files blow. I don't know kotlin, but basically it is a nullable problem. @giandifra ../arcore_flutter_plugin-master/android/src/main/kotlin/com/difrancescogianmarco/arcore_flutter_plugin/ArCoreViewFactory.kt line 14 from override fun create(context: Context, id: Int, args: Any?): PlatformView {

to

override fun create(context: Context?, id: Int, args: Any?): PlatformView {

line 25 from return ArCoreFaceView(activity, context, messenger, id, debug)

to

return ArCoreFaceView(activity, context!!, messenger, id, debug)

line 28 from return ArCoreAugmentedImagesView(activity, context, messenger, id, useSingleImage, debug)

to return ArCoreAugmentedImagesView(activity, context!!, messenger, id, useSingleImage, debug)

line 30 from return ArCoreAugmentedImagesView(activity, context, messenger, id, useSingleImage, debug)

to return ArCoreAugmentedImagesView(activity, context!!, messenger, id, useSingleImage, debug)

../arcore_flutter_plugin-master/android/src/main/kotlin/com/difrancescogianmarco/arcore_flutter_plugin/ArcoreFlutterPlugin.kt

line 32 from .registerViewFactory(CHANNEL_NAME, ArCoreViewFactory(registrar.activity(), registrar.messenger()))

to

.registerViewFactory(CHANNEL_NAME, ArCoreViewFactory(registrar.activity()!!, registrar.messenger()))

Upvotes: 0

Timur
Timur

Reputation: 1343

Did you add some configurations for arcode package; (By the way, this plugin can be used just in android. if you are testing on ios device, it's not gonna work)

Modify your AndroidManifest.xml to include the following entries:

<uses-permission android:name="android.permission.CAMERA" />

<!-- Limits app visibility in the Google Play Store to ARCore supported devices
     (https://developers.google.com/ar/devices). -->
<uses-feature android:name="android.hardware.camera.ar" />

<application …>
    …

    <!-- "AR Required" app, requires "Google Play Services for AR" (ARCore)
         to be installed, as the app does not include any non-AR features. -->
    <meta-data android:name="com.google.ar.core" android:value="required" />
</application>

Then, ensure that your app has at least the required minSdkVersion in your app's build.gradle:

android {
    defaultConfig {
        …
        minSdkVersion 24
    }
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
}

Add the latest ARCore library as a dependency in your app's build.gradle file:

dependencies {
    implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.8.0'
    implementation 'com.google.ar:core:1.30.0'
}

Upvotes: 1

Related Questions