ajakka / react-native-here-explore

HERE Maps in React Native
MIT License
81 stars 6 forks source link

Direct local .aar file dependencies are not supported when building an AAR. #5

Closed habhabsafi closed 2 months ago

habhabsafi commented 2 months ago

I am using the Lib and following the installation instructions of installation.md in a react-native app. environment information:

Gradle 7.6
Kotlin:       1.7.10
Groovy:       3.0.13
Ant:           1.10.11 
JVM:          17.0.10 
OS:           Mac OS X 13.5 x86_64
react-native 0.71.4
AGP         7.2.2

I am getting this Error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-maps-here:bundleReleaseLocalLintAar'.
> Error while evaluating property 'hasLocalAarDeps' of task ':react-native-maps-here:bundleReleaseLocalLintAar'.
   > Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :react-native-maps-here project caused this error: /Users/myuser/REPO/my-installer/android/app/libs/heresdk-explore-android-4.18.5.0.113335.aar
   * Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':react-native-maps-here:bundleReleaseLocalLintAar'.
Caused by: org.gradle.api.internal.tasks.properties.PropertyEvaluationException: Error while evaluating property 'hasLocalAarDeps' of task ':react-native-maps-here:bundleReleaseLocalLintAar'.

looks like setting an .aar file in libs isn't supported, although I am using the same AGP you're using in example.

habhabsafi commented 2 months ago

I am doing this workaround for the same issue that I found here
https://github.com/brim-borium/spotify_sdk/issues/99#issuecomment-878910598 It works because I am no longer getting the error. however, I am now getting this other error

FAILURE: Build failed with an exception.

What went wrong:
Execution failed for task ':react-native-maps-here:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error.
...
 Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':react-native-maps-here:compileDebugKotlin'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:142)
        at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:140)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:128)
...
Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
        at org.gradle.workers.internal.DefaultWorkerExecutor$WorkItemExecution.waitForCompletion(DefaultWorkerExecutor.java:348)
        at org.gradle.internal.work.DefaultAsyncWorkTracker.lambda$waitForItemsAndGatherFailures$2(DefaultAsyncWorkTracker.java:130)
        at org.gradle.internal.Factories$1.create(Factories.java:31)
        ...
                at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:49)
Caused by: org.gradle.api.GradleException: Compilation error.
...

I also upgraded gradle to 8.0.1 because you're using it in example still same problem

habhabsafi commented 2 months ago

i also installed and ran the example directory from your repo, and I am getting the same error as the original error in my repo

Execution failed for task ':react-native-maps-here:bundleDebugAar'.
> Error while evaluating property 'hasLocalAarDeps' of task ':react-native-maps-here:bundleDebugAar'.
   > Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :react-native-maps-here project caused this error: /Users/shabhab/Downloads/react-native-maps-here-main/example/android/app/libs/heresdk-explore-android-4.18.5.0.113335.aar
ajakka commented 2 months ago

Hi @habhabsafi, does this issue occur when your developing or when your trying to make a signed aar/apk ?

If so do you have other libraries installed like react-native-vision-camera or react-native-gesture-handler ?

habhabsafi commented 2 months ago

react-native-vision-camera

well, it's happening when i do ./gradlew buildwhile developing. yes I do have other libraries, for instance I have react-native-camera, reactive-native-qrcode-scanner and many more. On top of that, and as per my last comment, I tried to run ./gradlew build on your example directory and it threw the same error

ajakka commented 2 months ago

Ok I'm exploring it now, the problem seems to be that .aar libraries can't be bundled correctly with the app builds.

ajakka commented 2 months ago

@habhabsafi I published a new version: v1.1.0 that aims to fix this issue, but you will need to make some changes on your part:

  1. change the libs folder name to: heresdk and move it outside of the app folder. Meaning your library should be in android/heresdk/heresdk-explore-android-x.x.x.x.x.aar instead of android/app/libs/heresdk-explore-android-x.x.x.x.x.aar

  2. in your android/app/build.gradle replace the implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar']) with implementation fileTree(dir: file("../heresdk"), include: ['*.aar'])

If all goes well, you should build successfully

habhabsafi commented 2 months ago

the build worked, thanks !