Best eclipse questions in June 2012

Eclipse keeps Building workspace... and Building workspace... and Building workspace

9 votes

Why would Eclipse, when building an Android project, get stuck in an infinite loop for Building workspace... and (re) Building workspace... and (re) Building workspace...

Is this a known bug?

What is the proper way to get out of this loop?

Notes:

  1. If I uncheck Project > Build Automatically, it builds fine and even exports a perfectly running signed release APK.
  2. This problem only started after I upgraded to the latest SDK r19. Prior to that (SDK r11) I never experienced this problem.
  3. Bug 160868 describes exactly this problem. But hasn't it being solved since then?
  4. A similar problem description found here but like the previous one, it's old and not directly related to Android development.
  5. Issue 27940 suggests a bug in handling a const named BuildConfig.DEBUG which may or may not be related. But hasn't it been fixed in r18???
  6. I found this great tip for auto tagging / date-stamping in the Android build system, but I am not using anything like that, in addition to double-checking and verifying that builders come at the right order the Project builders list order (same order as other projects that do not exhibit this infinite-loop build behavior).
  7. My hunch tells me there might be a lock-file or flag that somehow got stuck (read-only mode?) and thus confuses the build system. Any idea what that boolean may be and where to find it?
  8. If I first open another project in the same workspace (that doesn't exhibit this problem), the project that has this problem miraculously stops the infinite rebuilding. This doesn't happen if I reverse the order of which project is opened first. Does this imply gremlins in the Eclipse/SDK/ADT build system?

No "blind shooting" please: answer this question only if you have personally experienced this amazing phenomenon (and solved it) or can point to an article that experienced this amazing phenomenon (and solved it).

Turns out bug 27940 hasn't been fixed yet.

I use the following workaround:

  1. Disable "Project > Build Automatically"
  2. Project > Clean
  3. Project > Build All

android finish current activity causes app close

8 votes

I am executing maswebview class and I would like to finish only this activity. I tried maswebview.this.finish() but when executed, app is been closed. Then if I set a new view for the tab content, it is loaded properly and webviewmas dissapears but just for a while, then appears again fitting fullscreen. How to finish maswebview completely? ThanK you

public void onClick(View arg0) 
            {
                /*
                Intent intent = getIntent();
                intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
                startActivityForResult(intent, 1);
                Intent intentmas = new Intent (maswebview.this, mas.class);
                intentmas.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 
                intentmas.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
                intentmas.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
                intentmas.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                View vista = getLocalActivityManager().startActivity("maswb", intentmas).getDecorView();
                setContentView(vista);  */

                maswebview.this.finish();

Do you have any other activities of your app in the stack by the time you call finish()? If you don't, you'll want to start the desired activity instead of finishing the current one.

But actually it seems to me that you're trying to accomplish something that can be done simpler. Can you provide more info on the task at hand and your app structure you're trying to go about it with?

From what you said, it seems like you have tabbed UI and you're trying to show a webview in one of the tabs, then hide it.

First, I don't see why you want the webview in a separate activity. Seems to me you could just have it in layout of one of the tabs and just call setVisibility(GONE) to hide it.

Second - and this is important - looks like you're trying to implement tabs the old way - TabWidget, TabHost, etc. Since Honeycomb has been released, there's much more convenient way to implement tabbed UI - Action Bar Tabs and Fragments - that approach is much more convenient and will render your webview problems obsolete: there's a thing called WebViewFragment which is basically a WebView but smarter - it will handle its own lifecycle with minimum effort required from you (i.e. pause when removed, resume when added). It will take some effort to study up on Fragments, but it's well worth it. You can get Fragments API for pre-Honeycomb android sdks as a static library - it's called android-support-v4 and you can download it in Android SDK Manager.