1

I'm developing an Android Bluetooth plugin for Unity using Kotlin. I included the .aar file of my Kotlin library (which works perfectly in an app running in Android Studio), and since I was getting some dependency errors in runtime, I started using the Android Dependency Resolver plugin.

I started by adding the dependencies that my library had on its .gradle file:

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

To my library's *Dependencies.xml, as instructed here by the Dependency Resolver:

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

The Dependency Resolver works and does it's job, but then when I try to compile the project I get the error:

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.
Facundo Farall
  • 500
  • 6
  • 18

2 Answers2

2

lStar is first defined in android-31, so you can change compileSdkVersion to 31+, or change androidx to a lower version.

shingo
  • 18,436
  • 5
  • 23
  • 42
  • Should I change all of the `.aar` dependencies using androidx to a lower version? And which version should that be? – Facundo Farall Dec 23 '21 at 16:33
  • Yes, but I am not sure which version should be, 1.6 I guess. – shingo Dec 24 '21 at 04:21
  • 1
    I found a workaround. The `androidx.core.core-1.7.0` dependency was causing the problem of the IStar not found, so I manually downloaded the previous version (`androidx.core.core-1.6.0`) from [here](https://mvnrepository.com/artifact/androidx.core/core/1.6.0). Then I run the Dependency Resolver, and manually deleted `androidx.core.core-1.7.0`. The app compiled and run as it was supposed to. I have to say, however, that I did try to specify that I wanted to use `androidx.core.core-1.6.0` in the `*Dependencies.xml` file, but the resolver still adds `androidx.core.core-1.7.0`. – Facundo Farall Dec 24 '21 at 12:59
0

There was a bug with the Dependency Resolver, you can track down the related issue here, as well as a workaround I found in the mean time. Remember to switch off Enable Resolution On Build under Assets -> External Dependency Manager -> Android Resolver -> Settings.

Facundo Farall
  • 500
  • 6
  • 18