0

我正在使用 Kotlin 为 Unity 开发一个 Android 蓝牙插件。我包含了.aar我的 Kotlin 库文件(它在 Android Studio 中运行的应用程序中完美运行),由于我在运行时遇到了一些依赖错误,我开始使用Android Dependency Resolver 插件

我首先添加了我的库在其.gradle文件中的依赖项:

dependencies {
    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'com.google.android.material:material:1.4.0'

    // For Kotlin Coroutines
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'
    
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

按照 Dependency Resolver 的*Dependencies.xml指示,我的图书馆:

<dependencies>
  <androidPackages>
    <repositories>
      <repository>https://repo.maven.apache.org/maven2</repository>
    </repositories>

    <androidPackage spec="androidx.appcompat:appcompat:1.4.0">
      <androidSdkPackageIds>
        <androidSdkPackageId>extra-google-m2repository</androidSdkPackageId>
      </androidSdkPackageIds>
      <repositories>
        <repository>https://maven.google.com</repository>
      </repositories>
    </androidPackage>

    <androidPackage spec="androidx.core:core-ktx:1.7.0">
      <androidSdkPackageIds>
        <androidSdkPackageId>extra-google-m2repository</androidSdkPackageId>
      </androidSdkPackageIds>
      <repositories>
        <repository>https://maven.google.com</repository>
      </repositories>
    </androidPackage>

    <androidPackage spec="org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2">
      <androidSdkPackageIds>
        <androidSdkPackageId>extra-google-m2repository</androidSdkPackageId>
      </androidSdkPackageIds>
      <repositories>
        <repository>https://maven.google.com</repository>
      </repositories>
    </androidPackage>

  </androidPackages>
</dependencies>

Dependency Resolver 可以工作并且可以正常工作,但是当我尝试编译项目时出现错误:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':launcher:processReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     /Users/myuser/.gradle/caches/transforms-2/files-2.1/f243f87f287fb4f4052bd069a9b71980/androidx.core.core-1.7.0/res/values/values.xml:105:5-114:25: AAPT: error: resource android:attr/lStar not found.
4

2 回答 2

0

lStar首先定义在android-31,所以你可以把compileSdkVersion改成31+,或者把androidx改成低版本。

于 2021-12-23T09:40:11.940 回答
0

Dependency Resolver 存在错误,您可以在此处查找相关问题,以及我同时发现的解决方法。Enable Resolution On Build记得在下关掉Assets -> External Dependency Manager -> Android Resolver -> Settings

于 2022-01-23T18:11:10.893 回答