简体   繁体   中英

"Dependency error" while creating native Android module for React Native

I'm trying to build a react native module for the Kin Android SDK ( https://kinecosystem.github.io/kin-ecosystem-sdk-docs/docs/android-guide.html#integrating-with-the-kin-sdk ).

I'm struggling with how to arrange the dependencies. In traditional Android (and RN) projects there's a project build.gradle and an app build.gradle - when creating a module there's just one available, along with the two that the project which is going to be using the module has.

I'm asked to place this line in the project module's build.gradle:

maven {          
    url 'https://jitpack.io'      
}

and this line in the app module's build.gradle:

dependencies {      
    ...      
    implementation 'com.github.kinecosystem:kin-devplatform-android:0.0.12'  
}

But any combination of putting these lines in build.gradle files (in the module or the app itself) results in errors:

Execution failed for task ':react-native-kin:prepareReleaseDependencies'.
> Dependency Error

Any help would be amazing - it may be something obvious to a Java developer. I've also attached the stacktrace below:

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':react-native-kin:prepareReleaseDependencies'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: org.gradle.api.GradleException: Dependency Error. See console for details.
        at com.android.build.gradle.internal.tasks.PrepareDependenciesTask.prepare(PrepareDependenciesTask.java:87)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:228)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:621)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:604)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
        ... 14 more

The default project created by React Native uses old versions of Android toolchain (build tool 23, android gradle plugin 2.2.3, and gradle 2), in order to compile kin-devplatform-android , newer toolchain version are needed, as this SDK depends on some newer android support libraries.

I uploaded a sample React Native project that compiles successfully with kin-devplatform-android :
https://github.com/kincommunity/rn-kindevplaform-sample

In this sample repo:
gradle wrapper updated to 4.1 , android gradle tools updated to 3.0.0 , google maven repository added here and here , compile sdk version bumped to 26 together with build tools , support library updated to 26 , and kin-devplatform-android sdk was included .

Version 0.0.12 is a bit "problematic" and has issues compiling using JitPack (it's a JitPack bug). In the newer version, 0.8.1, this issue should be resolved: com.github.kinecosystem:kin-devplatform-android:0.8.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM