Error in android tetris - getEntry - android

At the time me and a friend are programming the classic game Tetris, for a school project. I have been programming for an while now and had implemented both a rotate and a moveBlock, and newBlock, draw, etc., methods, so I thought now maybe would be the perfect time to run it for the first time. But then i get the error msg:
11-11 21:27:41.877: WARN/ResourceType(473): getEntry failing because entryIndex 7 is beyond type entryCount 7
11-11 21:27:41.877: WARN/ResourceType(473): Failure getting entry for 0x7f060007 (t=5 e=7) in package 0: 0x80000001
11-11 21:27:51.697: WARN/ActivityManager(59): Launch timeout has expired, giving up wake lock!
11-11 21:27:51.697: WARN/ActivityManager(59): Activity idle timeout for HistoryRecord{45009538 com.prosjekt.tetris2/.TetrisandroidGameActivity}
I'm running it with a Thread that uses a self built View (surfaceHolder/surfaceView), with methods, basically I'm following an lesson that the teacher has, where she programmed a snake game. So with updating of the methods so they are correct with tetris it should work, but now I can't see the error. Anyone know what the error message means, just paste questions if more info needed.
I have added a lot of LOG commands and I just got LOG from the TetrisView (surfaceView) constructor and from the constructor in the Thread, so it's never inside any of the methods.

Related

NFC service dead android.os.DeadObjectException

We are working on NFC tag android app and it is working properly 50% of times, and rest of the times we get NFC service dead exception in below try blocks:
Scenario is we connect to nfc Tag first time and send data, it always works fine.
Then we don't move phone away and after 1-2 seconds we again tries to connect to nfc tag(if not connected) to send data and 30% of times we get NFC service dead exception and it doesn't start until we disable and enable mobile's NFC.
Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY
+ Process.THREAD_PRIORITY_MORE_FAVORABLE); //first line of doInBackground()
if(((ArrayList<Byte>) params[0]).size()<=0){
return "No image selected!";
}
NfcA nfcaTag = (NfcA) params[2];
try{
nfcaTag = NfcA.get(tag);
if (!nfcaTag.isConnected()){
nfcaTag.connect(); //this is line 175 MainActivity
}
try {
nfcaTag.close();
}
Exception:
NFC service dead
android.os.DeadObjectException
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:622)
at android.nfc.INfcTag$Stub$Proxy.connect(INfcTag.java:285)
at android.nfc.tech.BasicTagTechnology.connect(BasicTagTechnology.java:73)
at android.nfc.tech.NfcA.connect(NfcA.java)
at de.silab.nfc.vistagnfcappv1.MainActivity$2.onClick(MainActivity.java:175)
at android.view.View.performClick(View.java:5723)
at android.view.View$PerformClick.run(View.java:22689)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6361)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Is there any way to solve this issue. We are stuck here since long time.
And any way to restart NFCAdapter/ nfc service by catching this exception?
Your nfcaTag's hosting process is dead. It has been close()'d. Your first step should be to debug by logging info to the console about your variables to see if something is unusual.
I find it strange that you close() your nfcaTag immediately after connect()'ing it. Maybe these two statements conflict?
Also, consider why you have initialized the nfcaTag only to change it immediately in the next try statement.
Is your NfcA.get(tag) occasionally returning a null NfcA object? Is tag occasionally null? You need to test every variable, especially the ones you haven't shared here completely in your question.

Android MediaPlayer Error (-2,0)

Anyone familiar with this error with Android MediaPlayer ?
MediaPlayer: Error (-2,0)
It's not documented.
It probably comes from OpenCore, which MediaPlayer is a high level abstraction of. "-2" means that some operation was canceled.
Here the list of error codes.
/*
Error due to cancellation
*/
const PVMFStatus PVMFErrCancelled = (-2);
Here is the doc with the detailed code description.
3.8. PVMFErrCancelled
This error code is returned when some old request is cancelled. In that sense this error is actually
an expected value and should not be treated as a fatal error.
So, you may probably ignore it, or double check how you implemented the workflow and whether it fits the expected one (you can find it in MediaPlayer class' reference).
From MediaErrors.h, include/utils/Errors.h, and unix_system_errors we can see that MediaPlayer error code -2 can mean:
Signal from CodecBase to MediaCodec that the component was not found.

Error while creating a new activity in Android Studio

Every time I create a new activity in Android Studio, I get an error like this:
Read access is allowed from event dispatch thread or inside read-action only (see com.intellij.openapi.application.Application.runReadAction())
Details: Current thread: Thread[ApplicationImpl pooled thread 17,4,main] 1345722054;
dispatch thread: false; isDispatchThread(): false
SystemEventQueueThread: Thread[AWT-EventQueue-0 1.3#AI-141.2178183, eap:false,6,main] 2033877427
It doesn't cause any problem though, and the activity is created like it should normally be. So what is the problem?
There is no evidence that this log is related to your application.
it has something to do with android studio (intellij) which you can easily ignore as long as everything is working fine for you.

Race condition between Application onCreate and resources loaded?

I have the following application class for my app. When the application starts, I want to get some settings from preferences and start a background service.
public class MyApplication extends Application {
public void onCreate() {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
String key = getResources().getString(R.string.prefkey_updateinterval);
...
}
This normally works fine, but occasionally when starting my program from eclipse "Run" I get this error:
10-10 08:25:47.016: E/AndroidRuntime(26402): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f0a0004
10-10 08:25:47.016: E/AndroidRuntime(26402): at android.content.res.Resources.getText(Resources.java:216)
10-10 08:25:47.016: E/AndroidRuntime(26402): at android.content.res.Resources.getString(Resources.java:269)
10-10 08:25:47.016: E/AndroidRuntime(26402): at com.karwosts.MyApp.PortfolioStore.onCreate(PortfolioStore.java:40)
10-10 08:25:47.016: E/AndroidRuntime(26402): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969)
10-10 08:25:47.016: E/AndroidRuntime(26402): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3395)
This id is from my R.java:
public static final int prefkey_updateinterval=0x7f0a0004;
Since this works fine most of the time, I have to assume that there is some kind of race condition between onCreate and the resources being loaded?
If that's the case, is it recommended not to read resources in Application onCreate?
If so, is there a better place to initialize a service when application launches?
Since this works fine most of the time, I have to assume that there is some kind of race condition between onCreate and the resources being loaded?
If the same APK file -- no recompile, no reinstall, etc. -- does not consistently generate the error, then it might be some sort of race condition, though that would surprise me.
If the same APK file consistently fails, then this is a more garden-variety resources-out-of-sync-with-the-rest-of-the-code problem, and cleaning the project will clear it up.
is there a better place to initialize a service when application launches?
IMHO, the number of apps that need to "initialize a service when application launches" is extremely low, to the point where I cannot think of a scenario off the cuff where this would be a good plan. That's not to say that you do not have such a scenario, but it's a serious code smell in my book without an explanation.
I've noticed that in cases where a lot of resources are used (and generated in R.java), cleaning the application before running fixes these issues. So I would assume this is not a race condition - but an issue with Eclipse or the Android SDK with not refreshing resources. As for the placement of the code - it's is as good as any other option, in my opinion.

NullpointerException from spinner.java:828 dismiss

I'm new to java/android and trying to help out with an open source project. I decided I could learn the most from trying to fix bugs and so I've been running Monkey on the app to start generating crash reports with bugsense (I don't have access to play.google crash reports). I consistently run into the crash below and since it doesn't identify where in the code the app is having problems, I'm not even sure what exactly the problem is. I'm not asking for a line by line fix (although it is open source) but some helpful hints would be much appreciated.
Complete Repo: https://github.com/rackspace/android-rackspacecloud
Stacktrace + source: http://pastebin.com/YkX7NvdD
Stacktrace:
// CRASH: com.rackspace.cloud.android (pid 3330)
// Short Msg: java.lang.NullPointerException
// Long Msg: java.lang.NullPointerException
// Build Label: google/takju/maguro:4.1.1/JRO03C/398337:user/release-keys
// Build Changelist: 398337
// Build Time: 1341437384000
// java.lang.NullPointerException
// at android.widget.Spinner$DialogPopup.dismiss(Spinner.java:828)
// at android.widget.Spinner$DialogPopup.onClick(Spinner.java:862)
// at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:924)
// at android.widget.AdapterView.performItemClick(AdapterView.java:298)
// at android.widget.AbsListView.performItemClick(AbsListView.java:1086)
// at android.widget.AbsListView.onKeyUp(AbsListView.java:2996)
// at android.widget.ListView.commonKey(ListView.java:2196)
// at android.widget.ListView.onKeyUp(ListView.java:2051)
// at android.view.KeyEvent.dispatch(KeyEvent.java:2633)
// at android.view.View.dispatchKeyEvent(View.java:7086)
// at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1354)
// at android.widget.ListView.dispatchKeyEvent(ListView.java:2026)
// at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1358)
// at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1358)
// at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1358)
// at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1358)
// at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1358)
// at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1892)
// at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1369)
// at android.app.Dialog.dispatchKeyEvent(Dialog.java:702)
// at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1819)
// at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3575)
// at android.view.ViewRootImpl.deliverKeyEvent(ViewRootImpl.java:3531)
// at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3113)
// at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4153)
// at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4132)
// at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4224)
// at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171)
// at android.os.MessageQueue.nativePollOnce(Native Method)
// at android.os.MessageQueue.next(MessageQueue.java:125)
// at android.os.Looper.loop(Looper.java:124)
// at android.app.ActivityThread.main(ActivityThread.java:4745)
// at java.lang.reflect.Method.invokeNative(Native Method)
// at java.lang.reflect.Method.invoke(Method.java:511)
// at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
// at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
// at dalvik.system.NativeStart.main(Native Method)
//
** Monkey aborted due to error.
Events injected: 5252
:Sending rotation degree=0, persist=false
:Dropped: keys=0 pointers=23 trackballs=0 flips=0 rotations=0
## Network stats: elapsed time=47382ms (0ms mobile, 47382ms wifi, 0ms not connected)
** System appears to have crashed at event 5252 of 10000 using seed 0
According to the code I am seeing at GrepCode, we have this :
public void dismiss() {
mPopup.dismiss();
mPopup = null;
}
So your NPE is caused by mPopup which is private AlertDialog of DialogPopup (private class of Spinner), probably the dialog to show the options of the spinner when you click it. mPopup is only set to something different from null at DialogPopup.show(). That method is called at Spinner.performClick(),i.e., when the spinner is clicked.
But then this is the weird part. The stack trace seem to be when an item of the mPopup was clicked, because DialogPopup is set as its OnClickListener. So at that point mPopup should not be null. But when DialogPopup.dismiss() it is null.
What can explain that? Here's my hypothesis. Well, monkey usually is pretty fast. Faster than actual users. It might be able to click two items before the mPopup was really dismissed by the first DialogPopup.onClick(). So we have two calls to DialogPopup.dismiss(), with the second cauing the NPE.
So here are my conclusions:
Because we are dealing only with internal classes and your code is not responsible for triggering the code that crashed, this is very likely an Android platform bug.
To fix this you must be able to reproduce and debug in eclipse in order to fully understand what is happening . You will need to download the Android platform code inorder to be able to step into the spinner code. Alternatively you can put log on the Spinner code and build Jelly Beans and flash your phone ( or replace the framework.jar)
If my hypothesis is correct, then debugging with ecplise won't help. You will need the logs to debug the problem. But if my hypothesis is right, then we think we should not worry. Normal user will hardly be able to click so fast.
You could advice the Android guys to do a if-null check. But only after you found the real root cause. Otherwise , you will be maskig the problem

Categories

Resources