Ruby错误地解释了类命名空间

时间:2016-09-08 21:17:13

标签: ruby

我的代码类似于以下代码段:

require_relative 'class/foo'
require_relative 'class/bar'
require_relative 'class/baz'

class MyClass
  def initialize(arg)
    ...

    %w(wordone wordtwo).each do |word|
      Foo.public_send(word.to_sym, arg)
      Bar.public_send(word.to_sym, arg)
      Baz.public_send(word.to_sym, arg)
    end
  end
end

在这三个要求中的每个要求都是像这个模板的代码:

class Foo
  def self.wordone(arg)
    # do stuff
  end

  def self.wordtwo(arg)
    # do stuff
  end
end

这适用于FooBar,但一旦达到Baz

NameError: uninitialized constant MyClass::Baz
Did you mean?  Baz

我明确指出Baz而非MyClass::Baz。为什么Ruby随机地误解了第三个对象方法调用的命名空间而不是前两个?

我还应该提一下,如果我改变:

Baz.public_send(word.to_sym, arg)

为:

Baz.wordone(arg)

然后它适用于那个方法调用,但我显然需要为该类循环多个方法调用。所以Ruby的命名空间误解似乎与在对象方法上使用public_send有关。

这发生在Ruby 2.3.1p112上。

2 个答案:

答案 0 :(得分:1)

似乎有些字符在传递给块的字符串中被转义

经检查,

$('wordone wordtwo').each {|word| p word}

给出

"\"wordone\"""\"wordtwo\""

删除额外的转义字符串引号和正斜杠会让它对我有效。

class MyClass
  def initialize(arg)
    ...

    %w(wordone wordtwo).each do |word|
      word = word.tr('\"', '');
      Foo.public_send(word.to_sym, arg)
      Bar.public_send(word.to_sym, arg)
      Baz.public_send(word.to_sym, arg)
    end
  end
end

你可以检查一下,让我们看看它是怎么回事

答案 1 :(得分:1)

从OP中编纂我的(显然有帮助的)评论:

基本上这里发生的事情是Ruby无法在顶级找到课程MyClass,所以它在MyClass下查看(它实际上是在寻找首先09-08 19:48:48.996 5535-5535/com.leskoenterprises.buddybelt D/ResourcesManager: For user 0 new overlays fetched Null 09-08 19:48:49.006 5535-5535/com.leskoenterprises.buddybelt I/DynamiteModule: Considering local module com.google.android.gms.firebase_database:3 and remote module com.google.android.gms.firebase_database:3 09-08 19:48:49.006 5535-5535/com.leskoenterprises.buddybelt I/DynamiteModule: Selected remote version of com.google.android.gms.firebase_database, version >= 3 09-08 19:48:49.036 5535-5535/com.leskoenterprises.buddybelt W/ResourcesManager: getTopLevelResources: /data/app/com.google.android.gms-2/base.apk / 1.0 running in com.leskoenterprises.buddybelt rsrc of package com.google.android.gms 09-08 19:48:49.056 5535-5535/com.leskoenterprises.buddybelt I/InjectionManager: Inside getClassLibPath caller 09-08 19:48:49.086 5535-5535/com.leskoenterprises.buddybelt W/System: ClassLoader referenced unknown path: /data/user/0/com.google.android.gms/app_chimera/m/00000008/n/arm64-v8a 09-08 19:48:49.096 5535-5535/com.leskoenterprises.buddybelt D/ChimeraFileApk: Primary ABI of requesting process is arm64-v8a 09-08 19:48:49.096 5535-5535/com.leskoenterprises.buddybelt D/ChimeraFileApk: Classloading successful. Optimized code found. 09-08 19:48:49.136 5535-5535/com.leskoenterprises.buddybelt W/ResourcesManager: getTopLevelResources: /data/app/com.leskoenterprises.buddybelt-2/base.apk / 1.0 running in com.leskoenterprises.buddybelt rsrc of package com.leskoenterprises.buddybelt 09-08 19:48:49.286 5535-5535/com.leskoenterprises.buddybelt I/zzai: Making Creator dynamically 09-08 19:48:49.306 5535-5535/com.leskoenterprises.buddybelt W/System: ClassLoader referenced unknown path: /data/user/0/com.google.android.gms/app_chimera/m/00000007/n/arm64-v8a 09-08 19:48:49.316 5535-5535/com.leskoenterprises.buddybelt D/ChimeraFileApk: Primary ABI of requesting process is arm64-v8a 09-08 19:48:49.316 5535-5535/com.leskoenterprises.buddybelt D/ChimeraFileApk: Classloading successful. Optimized code found. 09-08 19:48:49.386 5535-5535/com.leskoenterprises.buddybelt I/Google Maps Android API: Google Play services client version: 9452000 09-08 19:48:49.396 5535-5535/com.leskoenterprises.buddybelt I/Google Maps Android API: Google Play services package version: 9452440 09-08 19:48:49.676 5535-5535/com.leskoenterprises.buddybelt I/c: Token loaded from file. Expires in: 347134577 ms. 09-08 19:48:49.676 5535-5535/com.leskoenterprises.buddybelt I/c: Scheduling next attempt in 346834 seconds. 09-08 19:48:49.756 5535-5535/com.leskoenterprises.buddybelt D/AbsListView: Get MotionRecognitionManager 09-08 19:48:49.766 5535-5535/com.leskoenterprises.buddybelt E/MotionRecognitionManager: mSContextService = android.hardware.scontext.ISContextService$Stub$Proxy@c781c09 09-08 19:48:49.766 5535-5535/com.leskoenterprises.buddybelt E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@fa4de0e 09-08 19:48:49.766 5535-5535/com.leskoenterprises.buddybelt E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@fa4de0e 09-08 19:48:49.796 5535-5535/com.leskoenterprises.buddybelt W/System.err: mkdir failed: EEXIST (File exists) : /storage/emulated/0/Android/data/com.leskoenterprises.buddybelt/cache/debug 09-08 19:48:49.796 5535-5535/com.leskoenterprises.buddybelt W/System.err: mkdir failed: EEXIST (File exists) : /storage/emulated/0/Android/data/com.leskoenterprises.buddybelt/cache 09-08 19:48:49.806 5535-6225/com.leskoenterprises.buddybelt I/System.out: (HTTPLog)-Static: isSBSettingEnabled false 09-08 19:48:49.806 5535-6225/com.leskoenterprises.buddybelt I/System.out: (HTTPLog)-Static: isSBSettingEnabled false 09-08 19:48:49.866 5535-6225/com.leskoenterprises.buddybelt I/qtaguid: Tagging socket 77 with tag 3000110100000000{805310721,0} uid -1, pid: 5535, getuid(): 10414 09-08 19:48:49.866 5535-6225/com.leskoenterprises.buddybelt I/qtaguid: Untagging socket 77 09-08 19:48:49.866 5535-6225/com.leskoenterprises.buddybelt I/System.out: (HTTPLog)-Static: isSBSettingEnabled false 09-08 19:48:49.866 5535-6225/com.leskoenterprises.buddybelt I/System.out: (HTTPLog)-Static: isSBSettingEnabled false 09-08 19:48:49.866 5535-6225/com.leskoenterprises.buddybelt I/qtaguid: Tagging socket 77 with tag 3000110100000000{805310721,0} uid -1, pid: 5535, getuid(): 10414 09-08 19:48:49.886 5535-5535/com.leskoenterprises.buddybelt D/Activity: performCreate Call Injection manager 09-08 19:48:49.926 5535-5535/com.leskoenterprises.buddybelt I/InjectionManager: dispatchOnViewCreated > Target : com.leskoenterprises.buddybelt.MapsActivity isFragment :false 09-08 19:48:49.936 5535-5535/com.leskoenterprises.buddybelt D/SecWifiDisplayUtil: Metadata value : SecSettings2 09-08 19:48:49.936 5535-5535/com.leskoenterprises.buddybelt D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{d79e00b I.E...... R.....ID 0,0-0,0} 09-08 19:48:49.996 5535-6225/com.leskoenterprises.buddybelt I/qtaguid: Tagging socket 84 with tag 3000110100000000{805310721,0} uid -1, pid: 5535, getuid(): 10414 09-08 19:48:50.006 5535-5535/com.leskoenterprises.buddybelt I/System.out: MAPSonAuthStateChanged:signed_in:r3j0QrNzWHQ0U3Cdjz5Py110X6y2 09-08 19:48:50.066 5535-5800/com.leskoenterprises.buddybelt D/mali_winsys: new_window_surface returns 0x3000, [1440x2560]-format:1 09-08 19:48:50.116 5535-5535/com.leskoenterprises.buddybelt W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView) 09-08 19:48:50.126 5535-6275/com.leskoenterprises.buddybelt D/libEGL: eglInitialize EGLDisplay = 0x7f5c90dea8 09-08 19:48:50.136 5535-6225/com.leskoenterprises.buddybelt I/qtaguid: Untagging socket 77 09-08 19:48:50.146 5535-6275/com.leskoenterprises.buddybelt D/mali_winsys: new_window_surface returns 0x3000, [1440x2040]-format:2 09-08 19:48:50.206 5535-5535/com.leskoenterprises.buddybelt I/InjectionManager: dispatchCreateOptionsMenu :com.leskoenterprises.buddybelt.MapsActivity 09-08 19:48:50.206 5535-5535/com.leskoenterprises.buddybelt I/InjectionManager: dispatchPrepareOptionsMenu :com.leskoenterprises.buddybelt.MapsActivity 09-08 19:48:50.206 5535-5535/com.leskoenterprises.buddybelt D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1 09-08 19:48:50.266 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; getDrawOrder(): no-op, return DrawOrder.HEADS_UP_DISPLAY 09-08 19:48:50.266 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; getDrawOrder(): no-op, return DrawOrder.HEADS_UP_DISPLAY 09-08 19:48:50.266 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; getDrawOrder(): no-op, return DrawOrder.HEADS_UP_DISPLAY 09-08 19:48:50.266 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; getDrawOrder(): no-op, return DrawOrder.HEADS_UP_DISPLAY 09-08 19:48:50.266 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; getDrawOrder(): no-op, return DrawOrder.HEADS_UP_DISPLAY 09-08 19:48:50.266 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; getDrawOrder(): no-op, return DrawOrder.HEADS_UP_DISPLAY 09-08 19:48:50.266 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; getDrawOrder(): no-op, return DrawOrder.HEADS_UP_DISPLAY 09-08 19:48:50.286 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.376 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.416 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.446 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.476 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.486 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.526 5535-5546/com.leskoenterprises.buddybelt I/art: Background sticky concurrent mark sweep GC freed 23351(693KB) AllocSpace objects, 7(4MB) LOS objects, 0% free, 192MB/192MB, paused 25.943ms total 104.066ms 09-08 19:48:50.526 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.536 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.566 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.586 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.606 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.686 5535-5541/com.leskoenterprises.buddybelt W/art: Suspending all threads took: 76.794ms 09-08 19:48:50.686 5535-5546/com.leskoenterprises.buddybelt I/art: Background partial concurrent mark sweep GC freed 15513(565KB) AllocSpace objects, 24(6MB) LOS objects, 7% free, 189MB/205MB, paused 46.811ms total 161.788ms 09-08 19:48:50.716 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.736 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.746 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.756 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.776 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.786 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.806 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.826 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.836 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.856 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.876 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.886 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:50.906 5535-6275/com.leskoenterprises.buddybelt W/Google Maps Android API: GLHudOverlay deprecated; draw(): no-op 09-08 19:48:51.106 5535-5535/com.leskoenterprises.buddybelt D/AndroidRuntime: Shutting down VM 09-08 19:48:51.146 5535-5541/com.leskoenterprises.buddybelt W/art: Suspending all threads took: 36.104ms 09-08 19:48:51.576 5535-5546/com.leskoenterprises.buddybelt I/art: Background sticky concurrent mark sweep GC freed 278200(13MB) AllocSpace objects, 12(6MB) LOS objects, 0% free, 230MB/230MB, paused 38.106ms total 428.917ms 09-08 19:48:51.656 5535-5541/com.leskoenterprises.buddybelt W/art: Suspending all threads took: 42.349ms 09-08 19:48:51.906 5535-6277/com.leskoenterprises.buddybelt W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found. 09-08 19:48:51.946 5535-6277/com.leskoenterprises.buddybelt W/ResourcesManager: getTopLevelResources: /data/app/com.google.android.gms-2/base.apk / 1.0 running in com.leskoenterprises.buddybelt rsrc of package com.google.android.gms 09-08 19:48:51.966 5535-6277/com.leskoenterprises.buddybelt I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:1 09-08 19:48:51.966 5535-6277/com.leskoenterprises.buddybelt I/DynamiteModule: Selected remote version of com.google.android.gms.googlecertificates, version >= 1 09-08 19:48:51.976 5535-5535/com.leskoenterprises.buddybelt I/art: Waiting for a blocking GC Alloc 09-08 19:48:51.996 5535-5546/com.leskoenterprises.buddybelt I/art: Background partial concurrent mark sweep GC freed 70069(7MB) AllocSpace objects, 11(22MB) LOS objects, 6% free, 225MB/241MB, paused 14.201ms total 94.583ms 09-08 19:48:51.996 5535-5535/com.leskoenterprises.buddybelt I/art: WaitForGcToComplete blocked for 11.582ms for cause Alloc 09-08 19:48:51.996 5535-5535/com.leskoenterprises.buddybelt I/art: Starting a blocking GC Alloc 09-08 19:48:52.016 5535-6277/com.leskoenterprises.buddybelt D/ChimeraFileApk: Primary ABI of requesting process is arm64-v8a 09-08 19:48:52.016 5535-6277/com.leskoenterprises.buddybelt D/ChimeraFileApk: Classloading successful. Optimized code found. 09-08 19:48:52.016 5535-6277/com.leskoenterprises.buddybelt D/GoogleCertificates: com.google.android.gms.googlecertificates module is loaded 09-08 19:48:52.076 5535-5546/com.leskoenterprises.buddybelt I/art: Background sticky concurrent mark sweep GC freed 50945(5MB) AllocSpace objects, 0(0B) LOS objects, 0% free, 249MB/249MB, paused 5.239ms total 47.605ms 09-08 19:48:52.156 5535-5541/com.leskoenterprises.buddybelt W/art: Suspending all threads took: 39.823ms 09-08 19:48:52.156 5535-5546/com.leskoenterprises.buddybelt W/art: Suspending all threads took: 5.245ms 09-08 19:48:52.166 5535-5546/com.leskoenterprises.buddybelt I/art: Background partial concurrent mark sweep GC freed 33547(3MB) AllocSpace objects, 1(15MB) LOS objects, 6% free, 234MB/250MB, paused 6.064ms total 73.149ms 09-08 19:48:52.196 5535-6277/com.leskoenterprises.buddybelt D/GoogleCertificatesImpl: Fetched 163 Google release certificates 09-08 19:48:52.196 5535-5535/com.leskoenterprises.buddybelt I/art: Starting a blocking GC Alloc 09-08 19:48:52.196 5535-5535/com.leskoenterprises.buddybelt I/art: Starting a blocking GC Alloc 09-08 19:48:52.196 5535-6277/com.leskoenterprises.buddybelt D/GoogleCertificatesImpl: Fetched 318 Google certificates 09-08 19:48:52.206 5535-5535/com.leskoenterprises.buddybelt I/art: Alloc sticky concurrent mark sweep GC freed 33137(3MB) AllocSpace objects, 0(0B) LOS objects, 6% free, 233MB/249MB, paused 2.273ms total 15.101ms 09-08 19:48:52.246 5535-5535/com.leskoenterprises.buddybelt I/art: Waiting for a blocking GC Alloc 09-08 19:48:52.256 5535-5535/com.leskoenterprises.buddybelt I/art: WaitForGcToComplete blocked for 13.671ms for cause Alloc 09-08 19:48:52.256 5535-5535/com.leskoenterprises.buddybelt I/art: Starting a blocking GC Alloc 09-08 19:48:52.266 5535-5535/com.leskoenterprises.buddybelt I/art: Starting a blocking GC Alloc 09-08 19:48:52.326 5535-5535/com.leskoenterprises.buddybelt I/art: Alloc partial concurrent mark sweep GC freed 183(18KB) AllocSpace objects, 1(23MB) LOS objects, 6% free, 228MB/244MB, paused 622us total 63.926ms 09-08 19:48:52.366 5535-5535/com.leskoenterprises.buddybelt I/art: Waiting for a blocking GC Alloc 09-08 19:48:52.366 5535-5535/com.leskoenterprises.buddybelt I/art: WaitForGcToComplete blocked for 9.222ms for cause Alloc 09-08 19:48:52.366 5535-5535/com.leskoenterprises.buddybelt I/art: Starting a blocking GC Alloc 09-08 19:48:52.376 5535-5535/com.leskoenterprises.buddybelt I/art: Starting a blocking GC Alloc 09-08 19:48:52.436 5535-5535/com.leskoenterprises.buddybelt I/art: Clamp target GC heap from 264MB to 256MB 09-08 19:48:52.436 5535-5535/com.leskoenterprises.buddybelt I/art: Alloc partial concurrent mark sweep GC freed 37(3KB) AllocSpace objects, 0(0B) LOS objects, 3% free, 248MB/256MB, paused 627us total 56.868ms 09-08 19:48:52.446 5535-5535/com.leskoenterprises.buddybelt I/art: Starting a blocking GC Alloc 09-08 19:48:52.446 5535-5535/com.leskoenterprises.buddybelt I/art: Alloc sticky concurrent mark sweep GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 3% free, 248MB/256MB, paused 507us total 5.864ms 09-08 19:48:52.456 5535-5535/com.leskoenterprises.buddybelt I/art: Starting a blocking GC Alloc 09-08 19:48:52.526 5535-5535/com.leskoenterprises.buddybelt I/art: Clamp target GC heap from 264MB to 256MB 09-08 19:48:52.526 5535-5535/com.leskoenterprises.buddybelt I/art: Alloc concurrent mark sweep GC freed 25(12KB) AllocSpace objects, 0(0B) LOS objects, 3% free, 248MB/256MB, paused 513us total 72.830ms 09-08 19:48:52.536 5535-5535/com.leskoenterprises.buddybelt I/art: Forcing collection of SoftReferences for 19MB allocation 09-08 19:48:52.536 5535-5535/com.leskoenterprises.buddybelt I/art: Starting a blocking GC Alloc 09-08 19:48:52.596 5535-5535/com.leskoenterprises.buddybelt I/art: Clamp target GC heap from 264MB to 256MB 09-08 19:48:52.596 5535-5535/com.leskoenterprises.buddybelt I/art: Alloc concurrent mark sweep GC freed 6(128B) AllocSpace objects, 0(0B) LOS objects, 3% free, 248MB/256MB, paused 534us total 65.833ms 09-08 19:48:52.606 5535-5535/com.leskoenterprises.buddybelt W/art: Throwing OutOfMemoryError "Failed to allocate a 20169966 byte allocation with 8353792 free bytes and 7MB until OOM" 09-08 19:48:52.606 5535-5535/com.leskoenterprises.buddybelt I/art: Starting a blocking GC Alloc 09-08 19:48:52.606 5535-5535/com.leskoenterprises.buddybelt I/art: Starting a blocking GC Alloc 09-08 19:48:52.616 5535-5535/com.leskoenterprises.buddybelt I/art: Alloc sticky concurrent mark sweep GC freed 3(368B) AllocSpace objects, 0(0B) LOS objects, 3% free, 248MB/256MB, paused 557us total 5.973ms 09-08 19:48:52.616 5535-5535/com.leskoenterprises.buddybelt I/art: Starting a blocking GC Alloc 09-08 19:48:52.686 5535-5535/com.leskoenterprises.buddybelt I/art: Clamp target GC heap from 264MB to 256MB 09-08 19:48:52.686 5535-5535/com.leskoenterprises.buddybelt I/art: Alloc partial concurrent mark sweep GC freed 14(512B) AllocSpace objects, 0(0B) LOS objects, 3% free, 248MB/256MB, paused 677us total 64.068ms 09-08 19:48:52.696 5535-5535/com.leskoenterprises.buddybelt W/art: Suspending all threads took: 8.278ms 09-08 19:48:52.696 5535-5535/com.leskoenterprises.buddybelt I/art: Starting a blocking GC Alloc 09-08 19:48:52.756 5535-5535/com.leskoenterprises.buddybelt I/art: Clamp target GC heap from 264MB to 256MB 09-08 19:48:52.756 5535-5535/com.leskoenterprises.buddybelt I/art: Alloc concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 3% free, 248MB/256MB, paused 505us total 60.523ms 09-08 19:48:52.766 5535-5535/com.leskoenterprises.buddybelt I/art: Forcing collection of SoftReferences for 19MB allocation 09-08 19:48:52.766 5535-5535/com.leskoenterprises.buddybelt I/art: Starting a blocking GC Alloc 09-08 19:48:52.836 5535-5535/com.leskoenterprises.buddybelt I/art: Clamp target GC heap from 264MB to 256MB 09-08 19:48:52.836 5535-5535/com.leskoenterprises.buddybelt I/art: Alloc concurrent mark sweep GC freed 1(32B) AllocSpace objects, 0(0B) LOS objects, 3% free, 248MB/256MB, paused 486us total 69.653ms 09-08 19:48:52.836 5535-5535/com.leskoenterprises.buddybelt I/art: Starting a blocking GC HomogeneousSpaceCompact 09-08 19:48:53.066 5535-5535/com.leskoenterprises.buddybelt I/art: Clamp target GC heap from 264MB to 256MB 09-08 19:48:53.066 5535-5535/com.leskoenterprises.buddybelt I/art: HomogeneousSpaceCompact marksweep + semispace GC freed 2(64B) AllocSpace objects, 0(0B) LOS objects, 3% free, 248MB/256MB, paused 227.030ms total 227.030ms 09-08 19:48:53.066 5535-5535/com.leskoenterprises.buddybelt W/art: Throwing OutOfMemoryError "Failed to allocate a 20169966 byte allocation with 8349984 free bytes and 7MB until OOM" 09-08 19:48:53.086 5535-5535/com.leskoenterprises.buddybelt E/AndroidRuntime: Error reporting crash java.lang.OutOfMemoryError: Failed to allocate a 20169966 byte allocation with 8349984 free bytes and 7MB until OOM at java.lang.StringFactory.newStringFromChars(Native Method) at java.lang.AbstractStringBuilder.toString(AbstractStringBuilder.java:629) at java.lang.StringBuilder.toString(StringBuilder.java:663) at com.android.internal.os.RuntimeInit.Clog_e(RuntimeInit.java:60) at com.android.internal.os.RuntimeInit.access$200(RuntimeInit.java:44) at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:92) at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693) at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690) 09-08 19:48:53.086 5535-5535/com.leskoenterprises.buddybelt I/Process: Sending signal. PID: 5535 SIG: 9 ,然后检查顶级;错误消息告诉您它无法在任一名称空间中找到它。