为React Native

时间:2018-08-15 20:05:54

标签: java android react-native react-native-android kin

我正在尝试为Kin Android SDK(https://kinecosystem.github.io/kin-ecosystem-sdk-docs/docs/android-guide.html#integrating-with-the-kin-sdk)构建一个react native模块。

我正在努力安排依存关系。在传统的Android(和RN)项目中,有一个build.gradle项目和一个app.gradle应用程序-创建模块时,只有一个可用,以及将要使用该模块的项目中的两个。

我被要求将此行放置在项目模块的build.gradle中:

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

以及应用模块的build.gradle中的这一行:

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

但是将这些行放入build.gradle文件(在模块或应用本身中)的任何组合都会导致错误:

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

任何帮助都将是惊人的-对于Java开发人员来说可能是显而易见的。我还附加了下面的stacktrace:

* 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

2 个答案:

答案 0 :(得分:1)

React Native创建的默认项目使用旧版本的Android工具链(构建工具23,android gradle插件2.2.3和gradle 2),为了编译[HttpPost] public async Task<IActionResult> Upload(IFormFile file) { var uploads = Path.Combine(_environment.ContentRootPath, "Uploads"); if (file.Length > 0) { using (var fileStream = new FileStream(Path.Combine(uploads, file.FileName), FileMode.Create)) { await file.CopyToAsync(fileStream); } } return RedirectToAction("Index"); } ,需要新的工具链版本,因为此SDK依赖于一些较新的android支持库。

我上传了一个示例React Native项目,该项目已成功通过kin-devplatform-android编译:
https://github.com/kincommunity/rn-kindevplaform-sample

在此示例仓库中:
gradle包装器更新为4.1,android gradle工具更新为3.0.0,google maven存储库添加了herehere,编译的sdk版本升至26 together with build tools,支持库更新为26,并且kin-devplatform-android的SDK为included

答案 1 :(得分:0)

版本0.0.12有点“问题”,并且在使用JitPack进行编译时遇到了问题(这是一个JitPack错误)。 在较新的版本0.8.1中,应解决此问题: AddLocalisations = (localisation_id, localisations) => { let url = "http://127.0.0.1:8000/api/localisations/" +localisation_id "/sessions"; let data = {localisations }; axios.post(url, data).then(res => console.log(res)).catch(err => console.log(err))