LogCat is unable to show exceptions - android

Suppose I have this piece of code:
public class Class1 extends Activity
{
private int [] array;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
someFunction(array.length); <--- NullPointerException
}
}
Normally the LogCat in eclipse tells me what the exception is, and where is the line that is causing trouble, but for an unknown reason, it does not anymore. Instead, it just throw the following error :
12-30 22:27:06.650: E/Trace(28894): error opening trace file: No such file or directory (2)
12-30 22:27:06.670: W/dalvikvm(28894): Refusing to reopen boot DEX '/system/framework/hwframework.jar'
How can I solve this? I´ve seen many posts speaking of this problem, but I haven´t been able to solve the issue. Thanx.

I found that the only way to solve the issue, was shutting down eclipse and starting again. I dont know why this happens, but restarting fixed it.

Related

Android Monitor logcat not displaying any messages - studio version 2.2.1

I am new to app development and have come across an issue my course hasn't yet covered but requires.
I have created a simple app that generates a log entry using Log.i after clicking a button - see screenshot below.
link to screenshot
As you may well see, no logs have been generated at all for the running emulator. This happened on an earlier app and after searching for an answer, found that going to the terminal and finding the appropriate directory, I could restart the adb using the 'kill-server' and 'start-server' commands. As this didn't work, I found the file in windows explorer and double clicked the adb.exe file. This seemed to fix the problem.
Having started another project (the one linked in the screenshot), the same problem has arisen but the same steps do not correct the issue and as such have nothing being generated in the logcat.
*beneath the emulator you see, I have nothing in the search box, the logcat is set to verbose and regex(?) is ticked.
Any help with this would be greatly appreciated as i'm reluctant to proceed with the course material before sorting out this issue.
Thanks.
some additional information I have found in the 'AVD' section of the 'Run' Window :
libpng warnings
adb successful start?
EDIT - requested code
EDIT 2 - It's a bit of a bodge but it seems the adb operator command 'logcat' used in the Terminal, turns the terminal into the logcat i.e. c:..\sdk\adb logcat' - all my missing logs, including the ones generated by the buttonClicked function appear in the terminal and new logs also appear there.
Terminal as logcat
Thank you for your responses but maybe someone knows a way to fix the logcat itself, i'd appreciate the answer. Thanks again.
I have managed to resolve the issue by closing all related software, rebooting my laptop and running the adb.exe file in the ..\android\sdk\platform-tools\ directory before launching the android studio.
Hope this helps if anyone else has the same issue.
Stitches S, I think you are not calling the buttonclicked method anywhere as I haven't seen it calling in the screenshot. But if you are calling it somewhere else then try log.d() to print that. It always works for me.
if you want to see log on button click set the buttonClick method inside the oncreate(), may be its doing nothing that's why not showing any log
this code is working in my case:
public class About_us extends AppCompatActivity {
TextView header, address;
private String Info="Info";
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.contact);
header=findViewById(R.id.head);
address= findViewById(R.id.tv_address);
}
public void buttonClick(View view){
Log.d( Info,"button is clickd" );
}
}
and this is my xml view
<TextView android:id="#+id/head"
android:onClick="buttonClick"
android:layout_width="match_parent"
android:background="#color/third"
android:text="#string/app_name"
android:gravity="center"
android:textSize="20sp"
android:textColor="#color/first"
android:layout_height="30dp"/>

Eclipse duplicate Android code error

I'm using Eclipse Indigo to develop Android application. The problem I'm experiencing is that some given error messages are duplicated many times, preventing the code to be compiled even when the errors are fixed. For example, I wrote:
private OnClickListener foo = new OnClickListener()
{
#Override
public void onClick( View v )
{
// ...
}
}
I was reported "Syntax error, insert ";" to complete FieldDeclaration" 7 times. I fixed it and 6 error messages remained.
I closed Eclipse then restarted it, nothing changed. I guess it is a file to delete or something like this. Any idea?
Thanks!
Here is how I fixed the problem, for those who may experience it someday.
1) I copied all the faulty (or reported as faulty but not really faulty) code to a text editor.
2) I deleted it from the java file and saved it. The errors disappeared.
3) I pasted back the code to the java file then saved it. The errors did not re-appear.
That's it.

Android: NoClassDefError occurs in <4.0 but not >=4.0?

I am trying to launch a new intent from my Activity, but I get a NoClassDefFoundError. The exception occurs resolving MyClassB.class. Oddly I can resolve other classes, and the error only occurs in android versions 2.2 and 2.3, it works fine in 4.0+.
Both the class that causes the error and the other classes that resolve successfully are in the same package as the Activity where the code is executing. Basically, the below code gives the below error on 2.2/2.3, but works fine on 4.0+. I have also tried using the full package name like: com.me.MyClassB.class, but get the same error.
I realized this question is pretty vague, but am thoroughly confused and hoping that somebody might be able to help.
package com.me;
public class MyActivity extends Activity
{
protected onCreate(Bundle bundle)
{
super.onCreat(bundle);
Class a = MyClassA.class;
Class b = MyClassB.class;
}
}
01-17 10:37:36.473: E/AndroidRuntime(1976): java.lang.NoClassDefFoundError: com.me.MyClassB
I'm not sure if this is the problem but in your onCreate method you need to add super.onCreate(bundle) at the beginning e.g.
protected onCreate(Bundle bundle)
{
super.onCreate(bundle);
Class a = MyClassA.class;
Class b = MyClassB.class;
}
This was caused because MyClassB.class implements ActionBar.OnNavigationListener. It seems if classes contain certain code for a higher api level, they don't get setup properly at runtime, resulting in these sorts of errors. I expecteded MyClassB.class to crash on 2.3, but the NoClassDefFoundError was particularly mystifying.

Millennial Media interstitial crash

In the onCreate() method of the activity I want the interstitial to appear in,
I have the following code:
MMAdView interAdView = new MMAdView(this, MY_APP_ID, MMAdView.FULLSCREEN_AD_LAUNCH, true, null);
interAdView.fetch();
interAdView.setListener(new BasicMMAdListener()
{
#Override
public void MMAdCachingCompleted(MMAdView adview, boolean success)
{
if(success)
adview.display();
}
});
The code compiles without error, but at runtime I get the following Log output
which indicates an error at the first line of my code snippet, i.e. the one
starting: MMAdView interAdView = new MMAdView(this, ...
Could not find class 'com.millennialmedia.android.MMAdView', referenced from method com.mycompany.mygame.myactivity.onCreate
I am puzzled because I thought that if there was somehow a missing
class then the app should not compile.
Thanks to Vinay's comment, it forced me to investigate another problem I'd been having first.
My problem disappeared when I resolve an earlier problem covered on SO here.

LogCat not displaying anything after crash/reinstall

First off, as background: I am on a Mac, running OS X 10.6.7. Using Eclipse for an Android Development class I'm in (and hopefully eventually to actually develop directly for Android).
I had a nasty crash of Eclipse a few days ago, and after restarting I stopped getting any output from LogCat whatsoever. I tried everything I could think of, and I couldn't get anything at all to show up in the log. I tried a nuke-it-from-orbit reinstall of Eclipse, and it's at least made a little bit of a difference. When I run this code snippet I came up with to test things:
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class LogTester extends Activity {
/** Called when the activity is first created. */
public static final String TAG = "LogTester";
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.d(TAG, "Activity was created");
Log.d(TAG, "Anybody Home?");
}
}
...it shows me this (apparently I can't post images directly as a noob), but when I actually click on the LogTester tab of LogCat, I see nothing. The same thing vice-versa when I click back over to the main log tab, which as you can see should have 11 new items in it.
I tried changing the font since maybe there was some sort of issue with displaying the font, and I've heard there are weird issues with fonts and 10.6.7. But I get a "Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench"." error and a complete refusal to change the font type. I can't figure out where Eclipse hides this preference so I can try and fiddle with it manually.
Anyone have any ideas/suggestions as to things I should try next? This is absolutely maddening. Thanks!
UPDATE (3/31 1am): I deleted and recreated my AVM for about the 15th time and LogCat suddenly started working. Hell if I know why, but I'm not questioning it.
try switching to DDMS perspective and click on your active emulator in the Device tab. Your Logcat should refresh then.
I know this post is old but a filter got turned on for some reason using Firebase which really confused me for a few mintues while I tried to figure out what was going on.
Here's where you change the filter (in the android monitor panel):

Categories

Resources