2015-11-18 136 views
0

我有一個我試圖捆綁的React-Native Android應用程序。我已經複製的主要應用「測試」文件夾中做到這一點,我在這裏的操作說明:錯誤生成簽名APK

Guide to Generate Signed APK

我在哪裏運行點:

$ cd android && ./gradlew assembleRelease

一切似乎順利,直到我得到一個錯誤。與堆棧跟蹤運行給我:

org.gradle.api.GradleException: Could not list contents of '/Users/me/React/myapp/node_modules/.bin/defs'. 
at org.gradle.api.internal.file.collections.DirectoryFileTree.walkDir(DirectoryFileTree.java:147) 
at org.gradle.api.internal.file.collections.DirectoryFileTree.walkDir(DirectoryFileTree.java:172) 
at org.gradle.api.internal.file.collections.DirectoryFileTree.walkDir(DirectoryFileTree.java:172) 
at org.gradle.api.internal.file.collections.DirectoryFileTree.walkDir(DirectoryFileTree.java:172) 
at org.gradle.api.internal.file.collections.DirectoryFileTree.visitFrom(DirectoryFileTree.java:125) 
at org.gradle.api.internal.file.collections.DirectoryFileTree.visit(DirectoryFileTree.java:115) 
at org.gradle.api.internal.file.collections.FileTreeAdapter.visit(FileTreeAdapter.java:96) 
at org.gradle.api.internal.file.AbstractFileTree.getFiles(AbstractFileTree.java:37) 
at org.gradle.api.internal.file.CompositeFileCollection.getFiles(CompositeFileCollection.java:39) 
at org.gradle.api.internal.changedetection.state.DefaultFileCollectionSnapshotter.snapshot(DefaultFileCollectionSnapshotter.java:47) 
at org.gradle.api.internal.changedetection.rules.TaskUpToDateState.<init>(TaskUpToDateState.java:55) 
at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.getStates(DefaultTaskArtifactStateRepository.java:126) 
at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.isUpToDate(DefaultTaskArtifactStateRepository.java:69) 
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:52) 
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) 
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42) 
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.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:310) 
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79) 
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63) 
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51) 
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23) 
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88) 
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37) 
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62) 
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23) 
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68) 
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32) 
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62) 
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55) 
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149) 
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106) 
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86) 
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:90) 
at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28) 
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) 
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41) 
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28) 
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:50) 
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:27) 
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:40) 
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:169) 
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237) 
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210) 
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35) 
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24) 
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206) 
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169) 
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33) 
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22) 
at org.gradle.launcher.Main.doAction(Main.java:33) 
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45) 
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54) 
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35) 
at org.gradle.launcher.GradleMain.main(GradleMain.java:23) 
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30) 
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127) 
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61) 

構建失敗

有沒有人見過這個?任何幫助將不勝感激!

+0

你可以嘗試單獨運行這些命令?即'cd android /'**輸入**'./gradlew assembleRelease' – Felix

+1

@Felix是的,沒有我似乎允許我通過終端編譯APK。 *我認爲*設法通過Android Studio和Terminal進行編譯和簽名......只需上傳並測試即可。我會盡快更新我的發現 – scgough

+0

就像更新一樣,目前爲止我可以創建簽名APK的唯一方法是運行curl http:// localhost:8081/index.android.bundle ?platform = android「-dev = false -o」android/app/src/main/assets/index.android.bundle「命令,然後使用Android Studio創建實際的APK。每當我嘗試通過終端創建APK時,我都會遇到這裏列出的錯誤。 – scgough

回答

0

我還沒有遇到這個問題,但如果curl請求成功,聽起來像你的build.gradle在某種程度上配置錯誤。我使用react.gradle文件與「默認」反應原生項目一起提供。我的build.gradle配置看起來被粘貼在下面(注意:它使用了很多默認設置,但我喜歡明確地說明這些選項)。產生的打包命令如下所示:


    react-native bundle --platform android --dev true --entry-file react/index.android.js --bundle-output mobile/android/app/build/intermediates/assets/debug/index.android.bundle --assets dest mobile/android/app/build/intermediates/res/merged/debug 

如果構建一步到達這個階段,胡扯了,剩下的可能是您的節點的環境是某種錯誤配置。



    // React Native build configuration 
    project.ext.react = [ 
      // the name of the generated asset file containing your JS bundle 
      bundleAssetName : "index.android.bundle", 
      // the entry file for bundle generation 
      entryFile   : "react/index.android.js", 
      // whether to bundle JS and assets in debug mode 

      // When building from Android Studio bundleInDebug evalutes to false while using gradlew 
      // it overrides to true as it should. I don't 100% understand why that is, but luckily this 
      // is the behavior I want to have. 
      bundleInDebug  : true, 
      // whether to bundle JS and assets in release mode 
      bundleInRelease : true, 
      // the root of your project, i.e. where "package.json" lives 
      root    : "../../", 

      // were to put the JS bundle asset in debug mode 
      jsBundleDirDebug : "$buildDir/intermediates/assets/debug", 
      // where to put the JS bundle asset in release mode 
      jsBundleDirRelease : "$buildDir/intermediates/assets/release", 

      // where to put drawable resources/React Native assets, e.g. the ones you use via 
      // require('./image.png')), in debug mode 
      resourcesDirDebug : "$buildDir/intermediates/res/merged/debug", 

      // were to put drawable resources/React Native assets, e.g. the ones you use via 
      // require('./image.png')), in release mode 
      resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 

      // b default the gradle tasks are skipped if none of the JS files or assets change; this means 
      // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 
      // date; if you have any other folders that you want to ignore for performance reasons (gradle 
      // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 
      // for example, you might want to remove it from here. 
      inputExcludes  : [] 
    ] 
    apply from: 'react.gradle' 

1

什麼工作對我來說是的,我刪除了我的node_modules文件夾,並做了

npm install

cd android

./gradlew assembleRelease

+0

你救了我的一天! –