最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】android中使用System.out.println结果不工作:无法在ADT的LogCat或console中看到输出结果

Android crifan 6133浏览 0评论

【问题】

折腾:

【已解决】android中的java中的string转int

期间,使用:

	void strToIntTest(){
		String testStr1 = "123";
		String testStr2 = "0x456";

		int convertedIntValue1 = Integer.parseInt(testStr1);
		//int convertedIntValue2 = Integer.parseInt(testStr2);
		int convertedIntValue2 = Integer.decode(testStr2); //1110
		
		System.out.println("convertedIntValue1=" + convertedIntValue1 + ", convertedIntValue2=" + convertedIntValue2);
	}

结果是:

System.out.println

不工作。

无法在ADT中的LogCat或console中看到输出结果:

can  not see output in logcat or console

【解决过程】

1.参考:

Why doesn’t System.out.println work? (in Android)

去用:

	void strToIntTest(){
		String testStr1 = "123";
		String testStr2 = "0x456";

		int convertedIntValue1 = Integer.parseInt(testStr1);
		//int convertedIntValue2 = Integer.parseInt(testStr2);
		int convertedIntValue2 = Integer.decode(testStr2); //1110
		
		//System.out.println("convertedIntValue1=" + convertedIntValue1 + ", convertedIntValue2=" + convertedIntValue2);
		android.util.Log.d("strToIntTest", "convertedIntValue1=" + convertedIntValue1 + ", convertedIntValue2=" + convertedIntValue2);
	}

其中,此处不能直接写成:

Log.d()

或:

Log.i()

因为:

此处自己另外实现了一个Log类,直接使用Log.d或Log.i会误以为使用我自己的类呢。。。

结果是:

还是无法输出。。。

2.再去参考:

Logcat not displaying my log calls

去试试执行:

D:\DevRoot\android\adt-bundle-windows\sdk\platform-tools

下面的:

adb logcat

结果可以看到对应的输出了:

adb logcat can see my log.d output

3.但是还是想要实现:

用Log输出后,可以直接在Debug模式下的LogCat中看到:

【未解决】Android中用AVD模拟器调试程序用Log输出信息,结果ADT中的LogCat中看不到(但 adb logcat中可以看到)

 

【总结】

还是很诡异。抽空继续解决。

转载请注明:在路上 » 【已解决】android中使用System.out.println结果不工作:无法在ADT的LogCat或console中看到输出结果

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.184 seconds, using 22.12MB memory