2017-01-03 57 views
0

1:獲取推薦的Bazel版本:www.tensorflow.org/versions/master/get_started/os_setup.html#source 我使用pip安裝:$ pip install tensorflow無法通過bazel在張量流中構建APK

2:安裝NDK和SDK,我安裝SDK和NDK由Android工作室 3:EXCUTE如下: $捲曲-L https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip -o /tmp/inception5h.zip $捲曲-L https://storage.googleapis.com/download.tensorflow.org/models/mobile_multibox_v1.zip -o的/ tmp/mobile_multibox_v1.zip

$ unzip /tmp/inception5h.zip -d tensorflow/examples/android/assets/ $ unzip/tmp/mob ile_multibox_v1.zip -d tensorflow/examples/android/assets/

4:$ bazel build // tensorflow/examples/android:tensorflow_demo 這一步之後我得到了這個錯誤。

WARNING: Bazel Android NDK crosstools are based on Android NDK revision 12. The revision of the Android NDK given in android_ndk_repository rule 'androidndk' is '13.1.3345770'. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:avgpooling_op.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:bounds_check.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:cwise_ops.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:cwise_ops_common.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:cwise_ops_gradients.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_activations.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_attention.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_backward_cuboid_convolutions.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_backward_spatial_convolutions.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_cuboid_convolution.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_patch_3d.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_pooling.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_softmax.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_spatial_convolutions.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:fifo_queue.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:maxpooling_op.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:ops_util.cc' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:ops_util.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:padding_fifo_queue.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:pooling_ops_common.cc' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:pooling_ops_common.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:queue_base.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:queue_op.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:typed_queue.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/ctc:ctc_beam_entry.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/ctc:ctc_beam_scorer.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/ctc:ctc_beam_search.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/ctc:ctc_decoder.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/ctc:ctc_loss_util.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/tensor_bundle:naming.cc' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/tensor_bundle:naming.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/tensor_bundle:tensor_bundle.cc' directly. You should either move the file to this package or depend on an appropriate rule there. 
WARNING: /Users/Rauha/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/tensor_bundle:tensor_bundle.h' directly. You should either move the file to this package or depend on an appropriate rule there. 
INFO: Found 1 target... 
INFO: From Compiling external/protobuf/src/google/protobuf/util/time_util.cc [for host]: 
external/protobuf/src/google/protobuf/util/time_util.cc:52:18: warning: unused variable 'kMicrosPerMillisecond' [-Wunused-const-variable] 
static const int kMicrosPerMillisecond = 1000; 
       ^
external/protobuf/src/google/protobuf/util/time_util.cc:56:19: warning: unused variable 'kTimestampFormat' [-Wunused-const-variable] 
static const char kTimestampFormat[] = "%E4Y-%m-%dT%H:%M:%S"; 
       ^
2 warnings generated. 
INFO: From Linking external/protobuf/libprotobuf_lite.a [for host]: 
/Library/Developer/CommandLineTools/usr/bin/libtool: file: bazel-out/host/bin/external/protobuf/_objs/protobuf_lite/external/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.o has no symbols 
/Library/Developer/CommandLineTools/usr/bin/libtool: file: bazel-out/host/bin/external/protobuf/_objs/protobuf_lite/external/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.o has no symbols 
INFO: From Linking external/protobuf/libprotobuf.a [for host]: 
/Library/Developer/CommandLineTools/usr/bin/libtool: file: bazel-out/host/bin/external/protobuf/_objs/protobuf/external/protobuf/src/google/protobuf/io/gzip_stream.o has no symbols 
/Library/Developer/CommandLineTools/usr/bin/libtool: file: bazel-out/host/bin/external/protobuf/_objs/protobuf/external/protobuf/src/google/protobuf/util/internal/error_listener.o has no symbols 
INFO: From ProtoCompile tensorflow/examples/android/proto/box_coder.pb.cc: 
bazel-out/android-arm-linux-androideabi-4.9-v7a-gnu-libstdcpp-fastbuild/genfiles/external/protobuf/src: warning: directory does not exist. 
INFO: From ProtoCompile tensorflow/core/example/example.pb.cc: 
bazel-out/android-arm-linux-androideabi-4.9-v7a-gnu-libstdcpp-fastbuild/genfiles/external/protobuf/src: warning: directory does not exist. 
INFO: From ProtoCompile tensorflow/core/example/example.pb.cc [for host]: 
bazel-out/host/genfiles/external/protobuf/src: warning: directory does not exist. 
INFO: From Processing Android resources for //tensorflow/examples/android:tensorflow_demo: 
Jan 03, 2017 1:56:28 PM com.google.devtools.build.android.AndroidDataMerger doMerge 
WARNING: 
CONFLICT: asset:WORKSPACE is provided with ambiguous priority from: 
    external/mobile_multibox/WORKSPACE 
    external/inception5h/WORKSPACE 
CONFLICT: asset:BUILD is provided with ambiguous priority from: 
    tensorflow/examples/android/assets/BUILD 
    external/inception5h/BUILD 
Error: Warning: AndroidManifest.xml already defines debuggable (in http://schemas.android.com/apk/res/android); using existing value in manifest. 
**ERROR:** /Users/Rauha/tensorflow/tensorflow/examples/android/BUILD:58:1: Java compilation in rule '//tensorflow/examples/android:tensorflow_demo' failed: Worker process sent response with exit code: 1. 
tensorflow/examples/android/src/org/tensorflow/demo/CameraActivity.java:120: error: method does not override or implement a method from a supertype 
    @Override 
^
tensorflow/examples/android/src/org/tensorflow/demo/CameraActivity.java:137: error: cannot find symbol 
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 
                ^
    symbol: variable M 
    location: class VERSION_CODES 
tensorflow/examples/android/src/org/tensorflow/demo/CameraActivity.java:138: error: cannot find symbol 
     return checkSelfPermission(PERMISSION_CAMERA) == PackageManager.PERMISSION_GRANTED && checkSelfPermission(PERMISSION_STORAGE) == PackageManager.PERMISSION_GRANTED; 
      ^
    symbol: method checkSelfPermission(String) 
    location: class CameraActivity 
tensorflow/examples/android/src/org/tensorflow/demo/CameraActivity.java:138: error: cannot find symbol 
     return checkSelfPermission(PERMISSION_CAMERA) == PackageManager.PERMISSION_GRANTED && checkSelfPermission(PERMISSION_STORAGE) == PackageManager.PERMISSION_GRANTED; 
                          ^
    symbol: method checkSelfPermission(String) 
    location: class CameraActivity 
tensorflow/examples/android/src/org/tensorflow/demo/CameraActivity.java:145: error: cannot find symbol 
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 
                ^
    symbol: variable M 
    location: class VERSION_CODES 
tensorflow/examples/android/src/org/tensorflow/demo/CameraActivity.java:146: error: cannot find symbol 
     if (shouldShowRequestPermissionRationale(PERMISSION_CAMERA) || shouldShowRequestPermissionRationale(PERMISSION_STORAGE)) { 
     ^
    symbol: method shouldShowRequestPermissionRationale(String) 
    location: class CameraActivity 
tensorflow/examples/android/src/org/tensorflow/demo/CameraActivity.java:146: error: cannot find symbol 
     if (shouldShowRequestPermissionRationale(PERMISSION_CAMERA) || shouldShowRequestPermissionRationale(PERMISSION_STORAGE)) { 
                    ^
    symbol: method shouldShowRequestPermissionRationale(String) 
    location: class CameraActivity 
tensorflow/examples/android/src/org/tensorflow/demo/CameraActivity.java:149: error: cannot find symbol 
     requestPermissions(new String[] {PERMISSION_CAMERA, PERMISSION_STORAGE}, PERMISSIONS_REQUEST); 
    ^
    symbol: method requestPermissions(String[],int) 
    location: class CameraActivity 
8 errors 
Target //tensorflow/examples/android:tensorflow_demo failed to build 
Use --verbose_failures to see the command lines of failed build steps. 
INFO: Elapsed time: 140.112s, Critical Path: 136.48s 
+1

錯誤告訴你這個問題。您的Bazel版本只能與NDK的v12版本一起使用 - 但您擁有v13.x.x.x.您將需要新版本的Bazel或更舊的NDK。 – Tom

+0

我試過android-ndk-r12b並得到同樣的錯誤。 – Rauha

+0

將錯誤輸出格式化爲代碼塊以提高可讀性。 – hotzst

回答

0

您在WORKSPACE文件中爲您的SDK設置了哪個API級別?它需要> = 23,否則您會遇到您遇到的丟失符號錯誤。 AndroidManifest.xml中的目標api級別也需要大於等於23。

請注意,該應用程序仍然可以在api級別大於等於21的設備上運行,您只需使用23級SDK即可構建。