Пример проекта AR Flutter - Сбои приложения - Невозможно запустить действие ComponentInfo - PullRequest
0 голосов
/ 12 апреля 2020

Я пробовал четыре урока, включая просмотр видео на YouTube, чтобы убедиться, что я изменяю нужные файлы и продолжаю работать до этой же ошибки. Это просто стандартный код входа для запуска проекта Flutter-AR. https://medium.com/@difrancescogianmarco / arcore-flutter-plugin-add-object-on-the-plane-8b3d7cbde3d3

Приложение сразу же наберет sh ИЛИ приложение запросит разрешения использовать камеру, а затем создать sh.

import 'package:flutter/material.dart';
import 'package:arcore_flutter_plugin/arcore_flutter_plugin.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  ArCoreController arCoreController = ArCoreController();

  void _onArCoreViewCreated(ArCoreController controller) {
    arCoreController = controller;
    arCoreController.onNodeTap = (name) => onTapHandler(name);
  }

  void onTapHandler(String name) {
    showDialog<void>(
      context: context,
      builder: (BuildContext context) =>
          AlertDialog(content: Text('onNodeTap on $name')),
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Test'),
        ),
        body: ArCoreView(
          onArCoreViewCreated: _onArCoreViewCreated,
          enableTapRecognizer: true,
        ),
      ),
    );
  }
}

Ошибки, которые я получаю:

D / AndroidRuntime (5478): завершение работы VM E / AndroidRuntime (5478): FATAL ИСКЛЮЧЕНИЕ: основное E / AndroidRuntime (5478): процесс: com.example.loan_visualizar_3, PID: 5478 E / AndroidRuntime (5478): java .lang.RuntimeException: невозможно запустить действие ComponentInfo {com.example.loan_visualizar_3 / com. google.ar.core.InstallActivity}: java .lang.IllegalArgumentException: параметр, заданный как ненулевой, имеет значение null: метод kotlin .jvm.internal.Intrinsics.checkParameterIsNotNull, параметр saveInstanceState E / AndroidRuntime (5478): в android .app.ActivityThread.performLaunchActivity (ActivityThread. java: 2913)

================================= == Вот мой файл AndroidManifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.loan_visualizar_3">
    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <uses-sdk android:minSdkVersion="24" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature android:name="android.hardware.camera.ar" />

    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="loan_visualizar_3"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
        <meta-data android:name="com.google.ar.core" android:value="required" />
    </application>
</manifest>

============================ Вот моя сборка .gra Файл dle:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.loan_visualizar_3"
        minSdkVersion 24
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.8.0'
    implementation 'com.google.ar.sceneform:core:1.8.0'
    implementation 'com.google.ar:core:1.8.0'
}

Любая помощь будет принята с благодарностью. Спасибо.

1 Ответ

0 голосов
/ 02 мая 2020

Сначала я попробовал ваш код в эмуляторе и получил ошибки. Затем я попробовал на устройстве Pixel 2 и работал. Я считаю, что если вы запускаете свой код в эмуляторе, вам может потребоваться установить «Службы Google Play для AR». Я установил здесь на моем эмуляторе, и ваш код работает

...