Android Studio (Kotlin): Error when starting the debugger - android-studio

I am a novice at Android and Kotlin, and I've started to follow the "fundamentals" codelabs. I also have an experimental app of my own that I wrote from scratch. It runs nicely on the emulator and the device, but now I can no longer run it in the debugger (using the "bug" icon). When I do that, I immediately get this stack trace:
access:-1, Linux (libcore.io)
access:131, ForwardingOs (libcore.io)
access:76, BlockGuardOs (libcore.io)
access:131, ForwardingOs (libcore.io)
access:7719, ActivityThread$AndroidOs (android.app)
checkAccess:281, UnixFileSystem (java.io)
exists:813, File (java.io)
updateLoader:75, ResourceOverlays (com.android.tools.deploy.instrument)
addResourceOverlays:37, ResourceOverlays (com.android.tools.deploy.instrument)
addResourceOverlays:110, InstrumentationHooks (com.android.tools.deploy.instrument)
getResources:1312, LoadedApk (android.app)
createSystemContext:2993, ContextImpl (android.app)
getSystemContext:2647, ActivityThread (android.app)
handleBindApplication:6621, ActivityThread (android.app)
access$1500:256, ActivityThread (android.app)
handleMessage:2090, ActivityThread$H (android.app)
dispatchMessage:106, Handler (android.os)
loopOnce:201, Looper (android.os)
loop:288, Looper (android.os)
main:7842, ActivityThread (android.app)
invoke:-1, Method (java.lang.reflect)
run:548, RuntimeInier (com.android.internal.os)
main:1003, ZygoteInit (com.android.internal.os)
In this frame:
exists:813, File (java.io)
I see:
this = {File#19636} "/data/data/com.example.codegame/code_cache/.overlay/base.apk/res"
Any idea which file this is supposed to be? There is no /data/ folder on my machine!
I should add that:
Earlier, I was able to start the app in the debugger. I guess at some point I made some changes that are causing the problem, but I have no idea what!
If I just run the app (in the emulator), I can attach the debugger after it started.
This doesn't happen with other projects.
This error persists when I close and re-open Studio.
Any suggestions or hints would be appreciated.
Thanks!

Related

How to code neutralinoJS to move the window to 0,0?

Clueless dude here that does not get any results with anything in neutralino except HTML and CSS mods.
I have to neu build because CheckNetIsolation does nothing on my x64 Windows 10 Pro machine. So I can run the "myApp" executable. While that's annoying my real problem is I can't get any js code to produce results.
For example I enter Neutralino.window.move(0,0); immediately before Neutralino.init(); in VSCode. The window opens and remains in its default location.
What's my problem?
Check your neutralino.config.json file. In the latest version of Neutralino, enableHTTPServer has been replaced with just enableServer.
My Neu App remained while as well, until I did that.
Also, ensure that you have VSCode installed.
Finally, according to the documentation (scroll down to DANGER):
Aways use the ready event to call native API functions immediately. Don't call native API functions before the init() call or right after the init() call because the init() function doesn't synchronously wait until the WebSocket connection is established.
You need to call Neutralino.init() before any other functions, and since you need to move the window immediately, place it within the ready event:
Neutralino.init();
Neutralino.events.on('ready', () => {
Neutralino.window.move(0, 0);
});
I hope all this helps.

Why are Log.d() and Log.v() not printing

I have the following test code in my Activity:
#Override
public void onStart() {
super.onStart();
Log.e(CLASS_NAME, "ERROR onStart()");
Log.w(CLASS_NAME, "WARN onStart()");
Log.i(CLASS_NAME, "INFO onStart()");
Log.d(CLASS_NAME, "DEBUG onStart()");
Log.v(CLASS_NAME, "VERBOSE onStart()");
On the logcat view in Android Studio, it only prints:
02-10 15:56:10.190 6194-6194/org.example.my_app E/MyActivity﹕ ERROR onStart()
02-10 15:56:10.190 6194-6194/org.example.my_app W/MyActivity﹕ WARN onStart()
02-10 15:56:10.190 6194-6194/org.example.my_app I/MyActivity﹕ INFO onStart()
On top of the box, the menu is set to Log level: “Verbose”, and if I go into the menu next to it, choose “Edit filter configuration”, “by Log Level” is also set to “Verbose”. Why are the Log.d() and Log.v() not printing anything? What might I am missing? Any suggestions would be appreciated.
Accepted answer not working
My solution:
when your Log.d is not working then Log.wtf is work
It's working for me, may be this is helpful to other, who find solution
Android Studio filters lines that have already been logged but Log itself may filter some levels when logging. See Log.isLoggable:
The default level of any tag is set to INFO.
(However on many phone it is actually set to DEBUG or VERBOSE.)
Fix For meizu phone
Settings -> Accessibility -> Developer options -> advanced
logging->set "Allow all"
For Meizu MX4(Flyme 6.1.0.0), M2(Flyme 6.1.0.0G), M5(Flyme 6.3.0.0G) :
Settings->Accessibility - > Developer Options -> Performance
optimization -> Advanced logging -> set "Allow all"
Huawei, logcat not showing the log for my app?
For other phone search in "developers options": option "logging" and set "all".
Turn off your Developer Option then Restart Your Phone After that on developer option It definitely works by sure!!
I've faced also to the same issue. Even following the previous answers, I didn't find the way to show logs in the Logcat.
After many tries done on my own, here is the (other) way to get logs shown:
Just selecting "Show only selected application" in the combobox did the job. Priorly, it was "Firebase" which was selected.
Hopefully, you will see your logs ;-)
I was trying everything. From log.d to log.wtf. But nothing worked.
Then I restarted my Android Studio. After that, the debugger started working again.
Hope this helps to someone.
For me the issue was that I had actually disabled the logger buffer in my developer settings so go to Settings -> Developer options -> Logger buffer size and set it to anything that isn't 'off'.
I had similar problem to this one. However in my case the problem was empty first string. It worked in older version of Android Studio, but stopped working in Android Studio ver 5.6 after update.
When I used:
Log.d(string1, string2); in my logging wrapper class,
then whenever string1 was "", the logcat would ignore it. The solution was to add
if(string1 == null || string1 == "") {
string1 = "defaultString";
}
before
Log.d(string1, string2);
I hope this helps anyone with this problem.
This started happening with me in Android Studio 3. I was getting old Log.v's printing, but when I added a new one nothing happened. Ditto with debugger breakpoints.
Cleaning the solution and restarting Android Studio worked for me, but there was a simpler solution.
Disable Instant Run. It seems that Instant Run doesn't recognise new Log.v's or breakpoints.
Along the way I also added Gradle-aware Make to my Run/Debug configuration for the main activity. I don't know whether that was necessary, but I'm keeping it. ([Main Menu] Run -> Edit Configurations...)
i had the same problem. I switched off and on developer options and usb debugging and all logs worked. i also enabled gpu debug layers in developer options(i dont think that helped).

How to handle exceptions thrown in Isolates?

I'm experimenting with Dart and using the new streamSpawnFunction to create a new isolate.
I'm running my code in Dartium but i've noticed that if some kind of unrecoverable error occurs in the isolate i get no error message on the console. Because breakpoints in Isolate code are not working debugging is really painful.
The old Port based Isolate spawn function (spawnFunction) has a callback function for handling errors. I wonder why this is not available with streamSpawnFunction. Is there a new way to subscribe to the error events of an Isolate?
The missing functionality of streamSpawnFunction is just an oversight. I filed http://dartbug.com/9208 and I will try to fix it next week.
I'm not sure if it is a known problem that breakpoints don't work in isolates. I will let you file a bug-report (http://dartbug.com) so the devs can ask you questions and you are kept informed on the process.

libspotify: logging out or releasing session causes crash

This is in response to dan's (dan^spotify on IRC) offer to take a look at my testcase, but I post it here in case anyone has encountered similar issues.
I'm experiencing a problem with libspotify where the application crashes (memory access violation) in both of these two scenarios:
the first sp_session_process_events (triggered by notify main thread callback) that's called after the sp_session_logout() function is called crashes the application
skipping logout and calling sp_session_release() crashes the application
I've applied sufficient synchronization from the session callbacks, and I'm otherwise operating on a single thread.
I've made a small testcase that does the following:
Creates session
Logs in
Waits 10 seconds
Attempts to logout, upon which it crashes (when calling sp_session_process_events())
If it were successful in logging out (which it isn't), would call sp_session_release()
I made a Gist for the testcase. It can be found here: https://gist.github.com/4496396
The test case is made using Qt (which is what I'm using for my project), so you'd need Qt 5 to compile it. I've also only written it with Windows and Linux in mind (don't have Mac). Assuming you have Qt 5 and Qt Creator installed, the instructions are as follows:
Download the gist
Copy the libspotify folder into the same folder as the .pro file
Copy your appkey.c file into the same folder
Edit main.cpp to login with your username and password
Edit line 38-39 in sessiontest.cpp and set the cache and settings path to your liking
Open up the .pro file and run from Qt Creator
I'd be very grateful if someone could tell me what I'm doing wrong, as I've spent so many hours trying anything I could think of or just staring at it, and I fear I've gone blind to my own mistakes by now.
I've tested it on both Windows 7 and Linux Ubuntu 12.10, and I've found some difference in behavior:
On Windows, the testcase crashes invariably regardless of settings and cache paths.
On Linux, if setting settings and cache to "" (empty string), logging out and releasing the session works fine.
On Linux, if paths are anything else, the first run (when folder does not already exist) logs out and releases session as it should, but on the next run (when folder already exists), it crashes in the exact same way as it does on Windows.
Also, I can report that sp_session_flush_caches() does not cause a crash.
EDIT: Also, hugo___ on IRC was kind enough to test it on OSX for me. He reported no crashes despite running the application several times in a row.
While you very well may be looking at a bug in libspotify, I'd like to point out a possibly redundant call to sp_session_process_events(), from what I gathered from looking at your code.
void SessionTest::processSpotifyEvents()
{
if (m_session == 0)
{
qDebug() << "Process: No session.";
return;
}
int interval = 0;
sp_session_process_events(m_session, &interval);
qDebug() << interval;
m_timerId = startTimer(interval);
}
It seems this code will pickup the interval value and start a timer on that to trigger a subsequent call to event(). However, this code will also call startTimer when interval is 0, which is strictly not necessary, or rather means that the app can go about doing other stuff until it gets a notify_main_thread callback. The docs on startTimer says "If interval is 0, then the timer event occurs once every time there are no more window system events to process.". I'm not sure what that means exactly but it seems like it can produce at least one redundant call to sp_session_process_events().
http://qt-project.org/doc/qt-4.8/qobject.html#startTimer
I notice that you will get a crash on sp_session_release if you have a track playing when you call it.
I have been chasing this issue today. Login/logout works just fine on Mac, but the issue was 100% repeatable as you described on Windows.
By registering empty callbacks for offline_status_updated and credentials_blob_updated, the crash went away. That was a pretty unsatisfying fix, and I wonder if any libspotify developers want to comment on it.
Callbacks registered in my app are:
logged_in
logged_out
notify_main_thread
log_message
offline_status_updated
credentials_blob_updated
I should explicitly point out that I did not try this on the code you supplied. It would be interesting to know if adding those two extra callbacks works for you. Note that the functions I supply do absolutely nothing. They just have to be there and be registered when you create the session.
Adding the following call in your "logged in" libspotify callback seems to fix this crash as detailed in this SO post:
sp_session_playlistcontainer(session);

Trappable error 0xC0000005

We have one very old legacy application written on Classic ASP. Recently on a couple of servers we've started to get fatal errors. IIS process crashes. We've got few error's stack traces with IIS Debug Tool. There is 2 common types of errors.
We are using only few types of COM components in our application: ADO, Scripting.Dictionary, Scripting.FileSystem & MSXML6.
IIS logs says that error description is access violation exception (0xC0000005).
Do you have any ideas about the reason of errors or any ways for future debugging. Any ways to get more info about this errors will be very appreciated.
Thanks.
Stack traces:
1.
1996e18
oleaut32!VariantCopy+173
oleaut32!SafeArrayCopyData+14e
oleaut32!SafeArrayCopy+e3
oleaut32!VariantCopy+5b
oleaut32!VariantCopyInd+1a1
asp!CComponentObject::GetVariant+27
asp!CApplnVariants::get_Item+da
oleaut32!DispCallFunc+16a
oleaut32!CTypeInfo2::Invoke+234
asp!CDispatchImpl<IVariantDictionary>::Invoke+55
oleaut32!CTypeInfo2::Invoke+58a
asp!CDispatchImpl<IApplicationObject>::Invoke+55
vbscript!IDispatchInvoke2+b2
vbscript!IDispatchInvoke+59
vbscript!InvokeDispatch+13a
vbscript!InvokeByName+42
vbscript!CScriptRuntime::RunNoEH+22b2
vbscript!CScriptRuntime::Run+62
vbscript!CScriptEntryPoint::Call+51
vbscript!CSession::Execute+c8
vbscript!COleScript::ExecutePendingScripts+144
vbscript!COleScript::SetScriptState+14d
asp!CActiveScriptEngine::TryCall+19
asp!CActiveScriptEngine::Call+31
asp!CallScriptFunctionOfEngine+5b
asp!ExecuteRequest+17e
asp!Execute+24c
asp!CHitObj::ExecuteChildRequest+12c
asp!CErrInfo::LogCustomErrortoBrowser+28a
asp!CErrInfo::LogErrortoBrowserWrapper+8b
asp!CErrInfo::LogError+77
asp!HandleError+100
asp!HandleErrorMissingFilename+ac
asp!CActiveScriptEngine::Call+a7
asp!CallScriptFunctionOfEngine+5b
asp!ExecuteRequest+17e
asp!Execute+24c
asp!CHitObj::ViperAsyncCallback+3f0
asp!CViperAsyncRequest::OnCall+92
comsvcs!CSTAActivityWork::STAActivityWorkHelper+32
ole32!EnterForCallback+c4
ole32!SwitchForCallback+1a3
ole32!PerformCallback+54
ole32!CObjectContext::InternalContextCallback+159
ole32!CObjectContext::DoCallback+1c
comsvcs!CSTAActivityWork::DoWork+12d
comsvcs!CSTAThread::DoWork+18
comsvcs!CSTAThread::ProcessQueueWork+37
comsvcs!CSTAThread::WorkerLoop+190
msvcrt!_endthreadex+a3
kernel32!BaseThreadStart+34
2.
scrrun!FreeList+f   
scrrun!VBADictionary::~VBADictionary+28   
scrrun!VBADictionary::`scalar deleting destructor'+d   
scrrun!VBADictionary::Release+17   
oleaut32!VariantClear+b1   
oleaut32!ReleaseResources+98   
oleaut32!_SafeArrayDestroyData+4d   
oleaut32!_SafeArrayDestroy+b3   
oleaut32!SafeArrayDestroy+f   
oleaut32!VariantClear+75   
vbscript!VAR::Clear+a6   
vbscript!CScriptRuntime::Cleanup+63   
vbscript!CScriptRuntime::Run+8d  
vbscript!CScriptEntryPoint::Call+51  
vbscript!CScriptRuntime::RunNoEH+1e02 
vbscript!CScriptRuntime::Run+62  
vbscript!CScriptEntryPoint::Call+51   
vbscript!CScriptRuntime::RunNoEH+1e02  
vbscript!CScriptRuntime::Run+62   
vbscript!CScriptEntryPoint::Call+51   
vbscript!CScriptRuntime::RunNoEH+1e02   
vbscript!CScriptRuntime::Run+62   
vbscript!CScriptEntryPoint::Call+51   
vbscript!CScriptRuntime::RunNoEH+1e02   
vbscript!CScriptRuntime::Run+62   
vbscript!CScriptEntryPoint::Call+51   
vbscript!CSession::Execute+c8  
vbscript!COleScript::ExecutePendingScripts+144  
vbscript!COleScript::SetScriptState+14d  
asp!CActiveScriptEngine::TryCall+19   
asp!CActiveScriptEngine::Call+31   
asp!CallScriptFunctionOfEngine+5b   
asp!ExecuteRequest+17e  
asp!Execute+24c   
asp!CHitObj::ViperAsyncCallback+3f0   
asp!CViperAsyncRequest::OnCall+92   
comsvcs!CSTAActivityWork::STAActivityWorkHelper+32   
ole32!EnterForCallback+c4   
ole32!SwitchForCallback+1a3   
ole32!PerformCallback+54   
ole32!CObjectContext::InternalContextCallback+159   
ole32!CObjectContext::DoCallback+1c   
comsvcs!CSTAActivityWork::DoWork+12d   
comsvcs!CSTAThread::DoWork+18   
comsvcs!CSTAThread::ProcessQueueWork+37   
comsvcs!CSTAThread::WorkerLoop+190   
msvcrt!_endthreadex+a3
kernel32!BaseThreadStart+34
We had very similar situation last couple weeks. It was very complicated to track down this issue. The problem is in OnError handler of VB6 code. There are 2 cases to reproduce:
you do not have OnError handler, error occurs and goes directly to
IIS
error occurs in OnError handler and goes directly to IIS.
After ~100 such errors IIS will fail to work normally. It will be absolutely unpredictable behavior after this moment.

Resources