Пеша в импорте MainActivity с неразрешенной ссылкой: IO в EmbeddedAndroid

Форум для тех, кто программирует под Android
Ответить Пред. темаСлед. тема
Anonymous
 Пеша в импорте MainActivity с неразрешенной ссылкой: IO в Embedded

Сообщение Anonymous »

Я получаю проблему в файле mainActivity.kt < /p>

Код: Выделить всё

e: file:///Users/ttin/development/Patron%20App/tsg/android/app/src/main/kotlin/net/traceintuitive/patron/vmqa/MainActivity.kt:76:8 Unresolved reference: io
e: file:///Users/ttin/development/Patron%20App/tsg/android/app/src/main/kotlin/net/traceintuitive/patron/vmqa/MainActivity.kt:77:8 Unresolved reference: io
e: file:///Users/ttin/development/Patron%20App/tsg/android/app/src/main/kotlin/net/traceintuitive/patron/vmqa/MainActivity.kt:78:8 Unresolved reference: io
e: file:///Users/ttin/development/Patron%20App/tsg/android/app/src/main/kotlin/net/traceintuitive/patron/vmqa/MainActivity.kt:80:22 Unresolved reference: FlutterActivity
e: file:///Users/ttin/development/Patron%20App/tsg/android/app/src/main/kotlin/net/traceintuitive/patron/vmqa/MainActivity.kt:89:33 Unresolved reference: MethodChannel
e: file:///Users/ttin/development/Patron%20App/tsg/android/app/src/main/kotlin/net/traceintuitive/patron/vmqa/MainActivity.kt:97:5 'configureFlutterEngine' overrides nothing
e: file:///Users/ttin/development/Patron%20App/tsg/android/app/src/main/kotlin/net/traceintuitive/patron/vmqa/MainActivity.kt:97:56 Unresolved reference: FlutterEngine
e: file:///Users/ttin/development/Patron%20App/tsg/android/app/src/main/kotlin/net/traceintuitive/patron/vmqa/MainActivity.kt:99:15 Unresolved reference: configureFlutterEngine
e: file:///Users/ttin/development/Patron%20App/tsg/android/app/src/main/kotlin/net/traceintuitive/patron/vmqa/MainActivity.kt:102:9 Unresolved reference: MethodChannel
e: file:///Users/ttin/development/Patron%20App/tsg/android/app/src/main/kotlin/net/traceintuitive/patron/vmqa/MainActivity.kt:105:34 Cannot infer a type for this parameter. Please specify it explicitly.
e: file:///Users/ttin/development/Patron%20App/tsg/android/app/src/main/kotlin/net/traceintuitive/patron/vmqa/MainActivity.kt:105:40 Cannot infer a type for this parameter. Please specify it explicitly.
e: file:///Users/ttin/development/Patron%20App/tsg/android/app/src/main/kotlin/net/traceintuitive/patron/vmqa/MainActivity.kt:118:30 None of the following functions can be called with the arguments supplied:
public constructor Intent(p0: Context!, p1: Class!) defined in android.content.Intent
public constructor Intent(p0: String!, p1: Uri!) defined in android.content.Intent
e: file:///Users/ttin/development/Patron%20App/tsg/android/app/src/main/kotlin/net/traceintuitive/patron/vmqa/MainActivity.kt:120:21 Unresolved reference: putExtra
e: file:///Users/ttin/development/Patron%20App/tsg/android/app/src/main/kotlin/net/traceintuitive/patron/vmqa/MainActivity.kt:121:21 Unresolved reference: putExtra
e: file:///Users/ttin/development/Patron%20App/tsg/android/app/src/main/kotlin/net/traceintuitive/patron/vmqa/MainActivity.kt:128:17 Unresolved reference: startActivityForResult
e: file:///Users/ttin/development/Patron%20App/tsg/android/app/src/main/kotlin/net/traceintuitive/patron/vmqa/MainActivity.kt:145:5 'onActivityResult' overrides nothing
e: file:///Users/ttin/development/Patron%20App/tsg/android/app/src/main/kotlin/net/traceintuitive/patron/vmqa/MainActivity.kt:147:15 Unresolved reference: onActivityResult
[Incubating] Problems report is available at: file:///Users/ttin/development/Patron%20App/tsg/build/reports/problems/problems-report.html

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Compilation error.  See log for more details
Это мое app/build.gradle file

Код: Выделить всё

plugins {
id "com.android.application"
id "org.jetbrains.kotlin.android"
id "com.google.gms.google-services"
id "com.google.firebase.crashlytics"
id "dev.flutter.flutter-gradle-plugin"
}

android {
namespace = "net.traceintuitive.patron.vmqa"
compileSdk = 35
ndkVersion = flutter.ndkVersion

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
coreLibraryDesugaringEnabled true
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}

buildFeatures {
compose true
}

composeOptions {
kotlinCompilerExtensionVersion '1.5.3'
}

defaultConfig {
applicationId = "example.test"
minSdk = 24
targetSdk = 35
versionCode = flutter.versionCode
versionName = flutter.versionName
}

buildTypes {
release {
signingConfig = signingConfigs.debug
minifyEnabled true
//            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

packagingOptions {
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
}
}

flutter {
source = "../.."
}

dependencies {
implementation platform("androidx.compose:compose-bom:2023.10.01")
implementation platform("com.google.firebase:firebase-bom:31.2.2")

implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.10")

implementation("com.azure.android:azure-core-http-okhttp:1.0.0-beta.12")
implementation("com.azure.ai:azure-ai-vision-face-ui:1.1.0")

implementation("com.azure.android:azure-core-http-httpurlconnection:1.0.0-beta.10")
implementation("com.facebook.android:facebook-android-sdk:16.3.0")
implementation("com.google.android.gms:play-services-auth:21.3.0")
implementation("com.google.firebase:firebase-analytics-ktx")

// AndroidX & Compose
implementation("androidx.activity:activity-compose:1.7.2")
implementation "androidx.core:core-ktx:1.13.1"
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("androidx.compose.ui:ui:1.7.8")
implementation("androidx.activity:activity-ktx:1.10.1")
implementation("androidx.fragment:fragment-ktx:1.8.6")
implementation("androidx.webkit:webkit:1.14.0")
implementation("androidx.core:core-splashscreen:1.0.1")
implementation "androidx.annotation:annotation:1.7.0"

coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.1.5"
}
Это мой android/build.gradle file

Код: Выделить всё

buildscript {
ext.kotlin_version = '1.9.10' // Ensure this matches your project's Kotlin version
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.6.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.4.2'
classpath 'com.google.firebase:firebase-crashlytics-gradle:3.0.3'
}
}

allprojects {
ext {
mavenUrl = project.hasProperty('mavenUrl') ? project.mavenUrl : ""
mavenUser = project.hasProperty('mavenUser') ? project.mavenUser : ""
mavenPassword = project.hasProperty('mavenPassword') ? project.mavenPassword : ""
}

repositories {
google()
mavenCentral()
maven { url "https://jitpack.io"  }
maven {
url = uri("AzureURL")
credentials {
username = "Azure username"
password = "token"
}
}
}
}

rootProject.buildDir = "../build"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(":app")
}

tasks.register("clean", Delete) {
delete rootProject.buildDir
}
Это my setting.gradle file

Код: Выделить всё

pluginManagement {
def flutterSdkPath = new File(settingsDir, "local.properties").withInputStream {
def props = new Properties()
props.load(it)
return props.getProperty("flutter.sdk")
}

includeBuild("${flutterSdkPath}/packages/flutter_tools/gradle")

repositories {
gradlePluginPortal()
google()
mavenCentral()
}

plugins {
id "dev.flutter.flutter-gradle-plugin" apply false
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.library" version "8.3.2" apply false
id "com.android.application" version "8.6.0" apply false
id "org.jetbrains.kotlin.android" version "1.9.10" apply false
id("com.google.gms.google-services") version "4.4.2"
id("com.google.firebase.crashlytics") version "3.0.3"
}
}

include ":app"
gradlew-wrapper

Код: Выделить всё

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
Вывод wrlutter doctor -v

Код: Выделить всё

[✓] Flutter (Channel stable, 3.29.3, on macOS 15.4.1 24E263 darwin-arm64, locale en-IN) [1,359ms]
• Flutter version 3.29.3 on channel stable at /Users/ttin/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ea121f8859 (9 weeks ago), 2025-04-11 19:10:07 +0000
• Engine revision cf56914b32
• Dart version 3.7.2
• DevTools version 2.42.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1) [2.4s]
• Android SDK at /Users/ttin/Library/Android/sdk
• Platform android-35, build-tools 35.0.1
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2) [1,684ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16C5032a
• CocoaPods version 1.16.2

[✓] Chrome - develop for the web [13ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3) [12ms]
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)

[✓] VS Code (version 1.100.3) [11ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.112.0

[✓] Connected device (4 available) [9.1s]
• SM M127G (mobile)               • 192.168.1.61:5555     • android-arm64  • Android 13 (API 33)
• macOS (desktop)                 • macos                 • darwin-arm64   • macOS 15.4.1 24E263 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 15.4.1 24E263 darwin-arm64
• Chrome (web)                    • chrome                • web-javascript • Google Chrome 137.0.7151.69
! Error: Browsing on the local area network for TOUCHTiER TECHNOLOGY’s iPhone.  Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly.  (code -27)

[✓] Network resources [497ms]
• All expected network resources are available.

• No issues found!
И, наконец, это мой mainactivity.kt code

Код: Выделить всё

package net.traceintuitive.patron.vmqa

import android.content.Intent // Import for Intent
import android.os.Bundle // Import for Bundle
import androidx.annotation.NonNull // Import for Nullable annotations, though @NonNull is often implied for params in Kotlin
import io.flutter.embedding.android.FlutterActivity // Essential import for FlutterActivity
import io.flutter.embedding.engine.FlutterEngine // Essential import for FlutterEngine
import io.flutter.plugin.common.MethodChannel // Essential import for MethodChannel

class MainActivity : FlutterActivity() {
// Define the MethodChannel name, ensuring it matches your Flutter Dart code.
private val CHANNEL = "azure_face_liveness_channel"

// Define a unique request code for the LivenessActivity.
private val LIVENESS_REQUEST_CODE = 1001

// A nullable variable to hold the MethodChannel.Result, which will be used
// to send the result back to Flutter once the native activity completes.
private var resultCallback: MethodChannel.Result? = null

/**
* Configures the Flutter engine and sets up the MethodChannel to handle
* calls from the Flutter side.
*
* @param flutterEngine The FlutterEngine instance.
*/
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
// Call the super method to ensure the default Flutter engine configuration is applied.
super.configureFlutterEngine(flutterEngine)

// Initialize the MethodChannel with the specified name and set its call handler.
MethodChannel(
flutterEngine.dartExecutor.binaryMessenger,
CHANNEL
).setMethodCallHandler { call, result ->  // 'call' represents the method call from Flutter, 'result' is for sending a response back.
if (call.method == "startLiveness") {
// Extract arguments from the Flutter method call.
// 'sessionToken' is retrieved, defaulting to an empty string if null.
val sessionToken = call.argument("sessionToken") ?: ""
// 'verifyImageFileContent' is retrieved as a ByteArray.
// NOTE: Be cautious with large byte arrays as passing them directly via Intent
// can lead to TransactionTooLargeException (Binder transaction buffer limit is around 1MB).
// For very large images, consider saving to a temporary file and passing its URI,
// or using a shared memory mechanism.
val verifyImageFileContent = call.argument("verifyImageFileContent")

// Create an Intent to start the LivenessActivity.
val intent = Intent(this, LivenessActivity::class.java).apply {
// Pass the session token and image content as extras to the LivenessActivity.
putExtra("sessionToken", sessionToken)
putExtra("verifyImageFileContent", verifyImageFileContent)
}

// Store the 'result' object to be used later in onActivityResult
// to send the native activity's outcome back to Flutter.
resultCallback = result
// Start the LivenessActivity, expecting a result back.
startActivityForResult(intent, LIVENESS_REQUEST_CODE)
} else {
// If an unknown method is called, notify Flutter that it's not implemented.
result.notImplemented()
}
}
}

/**
* Called when an activity started with startActivityForResult returns.
* This is where the result from LivenessActivity is processed.
*
* @param requestCode The integer request code originally supplied to startActivityForResult(),
* allowing you to identify who this result came from.
* @param resultCode The integer result code returned by the child activity through its setResult().
* @param data An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
*/
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
// Call the super method to ensure Flutter handles its own activity results.
super.onActivityResult(requestCode, resultCode, data)

// Check if the result is for our LivenessActivity and if we have a callback waiting.
if (requestCode == LIVENESS_REQUEST_CODE && resultCallback != null) {
// Retrieve the "status" string from the returned Intent.
val status = data?.getStringExtra("status")

if (status == "success") {
// If the status is "success", create a map with success details
// and send it back to Flutter using the stored resultCallback.
val resultMap = hashMapOf(
"status" to "success",
"resultId" to data.getStringExtra("resultId"),
"digest" to data.getStringExtra("digest"),
"data" to data.getStringExtra("data") // Generic data field
)
resultCallback?.success(resultMap)
} else if (status == "error") {
// If the status is "error", create a map with error details
// and send it back to Flutter.
val errorMap = hashMapOf(
"status" to "error",
"livenessError" to data.getStringExtra("livenessError"), // Specific liveness error message
"recognitionError" to data.getStringExtra("recognitionError"), // Specific recognition error message
"data"  to data.getStringExtra("data") // Generic data field, potentially for more error details
)
resultCallback?.success(errorMap)
} else {
// Handle unexpected or missing results from LivenessActivity.
resultCallback?.error(
"UNEXPECTED_RESULT",
"No valid result returned or status is unknown.",
null
)
}
// Clear the resultCallback to prevent memory leaks and ensure it's not reused.
resultCallback = null
}
}
}
Я попытался реализовать эту двух строку в приложении/build.gradle, но это выбрасывала ошибка

Код: Выделить всё

implementation("io.flutter:flutter_embedding_debug:1.0.0")
implementation("io.flutter:flutter_embedding_release:1.0.0")
Пожалуйста, предоставьте мне какое -то решение.

Подробнее здесь: https://stackoverflow.com/questions/796 ... n-embedded
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Android»