简体   繁体   English

Flutter:由于 android:export 错误而无法运行应用程序

[英]Flutter: Unable to run the app due to android:export error

I am developing a Flutter application.我正在开发一个 Flutter 应用程序。 i just have imlemented the fluter_voip_kit plugin - https://pub.dev/packages/flutter_voip_kit我刚刚实施了fluter_voip_kit插件 - https://pub.dev/packages/flutter_voip_kit

And below is my AndroidManifest下面是我的AndroidManifest

<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.test.calls">
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <application
        android:label="calls"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            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">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <service android:name="com.example.flutter_voip_kit.VoipConnectionService"
                android:label="VoipConnectionService"
                android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE">
            <intent-filter>
                <action android:name="android.telecom.ConnectionService" />
            </intent-filter>
        </service>
        <!-- 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" />
    </application>
</manifest>

When I run my app, I get the below error.当我运行我的应用程序时,出现以下错误。

    android:exported needs to be explicitly specified for element <service#com.example.flutter_voip_kit.VoipConnectionService>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : android:exported needs to be explicitly specified for element <service#com.example.flutter_voip_kit.VoipConnectionService>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for 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 3s
Exception: Gradle task assembleDebug failed with exit code 1
Exited

This is my app level gradle file这是我的app级 gradle 文件

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 flutter.compileSdkVersion
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.test.calls"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
        minSdkVersion 23
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    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"
}

How to fix this issue?如何解决这个问题?

Error says it all:错误说明了一切:

android:exported needs to be explicitly specified for element <service#com.example.flutter_voip_kit.VoipConnectionService>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

Whether or not components of other applications can invoke the service or interact with it — "true" if they can, and "false" if not.其他应用程序的组件是否可以调用服务或与之交互 - 如果可以,则为“true”,否则为“false”。 When the value is "false", only components of the same application or applications with the same user ID can start the service or bind to it.当值为“false”时,只有相同应用程序的组件或具有相同用户ID的应用程序才能启动服务或绑定到服务。

<service android:name="com.example.flutter_voip_kit.VoipConnectionService"
    android:label="VoipConnectionService"
    android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"
    android:exported=["true" | "false"]>
    <intent-filter>
        <action android:name="android.telecom.ConnectionService" />
    </intent-filter>
</service>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 由于gradle已过时,因此无法在真实设备上运行android应用 - Unable to run an android app at a real device due to gradle being outdated 无法运行Flutter应用 - Unable to run flutter app 由于LogCollectManager.getUserType()错误,无法启动android应用 - Unable to start android app due to LogCollectManager.getUserType() error Android Studio:由于 gradle 分发 url 错误而无法构建应用程序 - Android Studio: Unable to build app due to gradle distribution url error 由于Null指针错误,Android蓝牙应用无法运行 - Android Bluetooth app wont run due to Null pointer error Android应用开发错误:无法在Android应用版本上运行错误 - Android app development error: unable to run on android app version error 尝试运行 flutter 运行的 android 应用程序时出错 - Getting error while trying to run android app by flutter run Unable to run flutter app on android emulator as java as Android Gradle plugin requires Java 11 to run - Unable to run flutter app on android emulator as java as Android Gradle plugin requires Java 11 to run 由于 CMake 路径版本,无法运行 Android React-Native 应用程序 - Unable To Run Android React-Native App Due to CMake Path Versions Android 更新后应用无法运行并显示错误 flutter - Android app not run and show error after update flutter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM