gradle 无法运行Flutter插件:AAPT:错误:意外元素< uses-native-library>

snvhrwxg  于 2023-03-30  发布在  Flutter
关注(0)|答案(1)|浏览(248)

我实际上为flutter创建了我的第一个android原生插件。这个插件将用于实现硬件android依赖(使用arcore和camera stream实现虚拟现实的相机套件)。
这个依赖似乎是在测试版,但我成功地创建了一个原生的android应用程序与它.所以我转换我的活动到flutter插件.我成功地创建了我自己的平台视图与viewStub谁将使用由camerakit膨胀他的布局.但当我试图运行我的flutter exemple,我得到以下错误:

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     C:\Users\dupas\Desktop\camerakit\example\build\app\intermediates\packaged_manifests\debug\AndroidManifest.xml:83: AAPT: error: unexpected element <uses-native-library> found in <manifest><application>.

     C:\Users\dupas\Desktop\camerakit\example\build\app\intermediates\packaged_manifests\debug\AndroidManifest.xml:86: AAPT: error: unexpected element <uses-native-library> found in <manifest><application>.

     C:\Users\dupas\Desktop\camerakit\example\build\app\intermediates\packaged_manifests\debug\AndroidManifest.xml:89: AAPT: error: unexpected element <uses-native-library> found in <manifest><application>.

     C:\Users\dupas\Desktop\camerakit\example\build\app\intermediates\packaged_manifests\debug\AndroidManifest.xml:92: AAPT: error: unexpected element <uses-native-library> found in <manifest><application>.

实际上,当我打开其中一个相机库时,我可以在清单中看到这样的行:

<uses-native-library
    android:name="libOpenCL-pixel.so"
    android:required="false" />
<uses-native-library
    android:name="libOpenCL.so"
    android:required="false" />
<uses-native-library
    android:name="libGLES_mali.so"
    android:required="false" />
<uses-native-library
    android:name="libPVROCL.so"
    android:required="false" />

以下是我的android的build.gradle插件内容:

group 'com.example.camerakit'
version '1.0-SNAPSHOT'

ext {
    bundledMavenRepo = rootProject.file('C:\\Users\\dupas\\Desktop\\camerakit\\android\\maven')
}

buildscript {
    ext.kotlin_version = '1.6.10'
    ext.cameraKitVersion = "1.11.0"
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

rootProject.allprojects {
    repositories {
        maven{
            url bundledMavenRepo.toURI()
        }
        google()
        mavenCentral()
    }
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion 31

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

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

    buildFeatures {
        viewBinding true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        minSdkVersion 21
    }
}

android {
    defaultConfig {
        vectorDrawables.useSupportLibrary = true
    }
}
allprojects {
    ext {
        cameraKitVersion = "1.11.0"
        cameraKitApplicationId = "0.0.0"
    }
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    // The main CameraKit artifact that provides all the core functionality.
    // It is not necessary to define it here if support-camera-layout artifact is
    // used as it transitively depends on it, however it is kept for the reference.
    implementation "com.snap.camerakit:camerakit:$cameraKitVersion"
    // Provides convenience Kotlin specific extensions to the public CameraKit API.
    implementation "com.snap.camerakit:camerakit-kotlin:$cameraKitVersion"
    // Provides an opinionated but extensible implementation that wraps
    // camera as well as CameraKit Session management with a View that can be
    // embedded into any Activity or Fragment where CameraKit integration is needed.
    implementation "com.snap.camerakit:support-camera-layout:$cameraKitVersion"
    // Optional dependency that provides location access to certain lenses.
    // Used by the support-camera-layout when creating the Source<LocationProcessor>
    // for the CameraKit Session, if removed, falls back to default, no-op implementation.
    implementation "com.snap.camerakit:support-gms-location:$cameraKitVersion"
    // Optional dependency that provides ArCore backed Source<ImageProcessor> to enable
    // depth and other ArCore specific features in lenses that require them.
    // Used by the support-camera-layout but can be safely removed if not needed.
    implementation "com.snap.camerakit:support-arcore:$cameraKitVersion"
    // Optional dependency that provides customizable lenses carousel view.
    implementation "com.snap.camerakit:support-lenses-carousel:$cameraKitVersion"
    implementation "com.snap.camerakit:lenses-bundle:$cameraKitVersion"

    implementation "androidx.core:core-ktx:1.7.0"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

你有什么建议来解决这个问题吗?有没有可能在flutter应用程序中嵌入这种类型的库?非常感谢!

8ulbf1ek

8ulbf1ek1#

可能是因为您使用的Gradle构建工具版本不支持<uses-native-library>标签,请尝试升级。
例如:

android/build.gradle:

=〉classpath 'com.android.tools.build:gradle:7.1.2'

android/gradle/wrapper/gradle-wrapper.properties:

=〉distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip

相关问题