\r
import com.android.prefs.AndroidLocation.AndroidLocationException;\r
import com.android.sdklib.ISdkLog;\r
+import com.android.sdklib.SdkConstants;\r
import com.android.sdklib.SdkManager;\r
import com.android.sdklib.internal.avd.AvdManager;\r
import com.android.sdklib.internal.repository.AddonPackage;\r
\r
private Shell mWindowShell;\r
\r
+ private AndroidLocationException mAvdManagerInitError;\r
+\r
/**\r
* Creates a new updater data.\r
*\r
return mWindowShell;\r
}\r
\r
+ /**\r
+ * Check if any error occurred during initialization.\r
+ * If it did, display an error message.\r
+ *\r
+ * @return True if an error occurred, false if we should continue.\r
+ */\r
+ public boolean checkIfInitFailed() {\r
+ if (mAvdManagerInitError != null) {\r
+ String example;\r
+ if (SdkConstants.currentPlatform() == SdkConstants.PLATFORM_WINDOWS) {\r
+ example = "%USERPROFILE%"; //$NON-NLS-1$\r
+ } else {\r
+ example = "~"; //$NON-NLS-1$\r
+ }\r
+\r
+ MessageDialog.openError(mWindowShell,\r
+ "Android Virtual Devices Manager",\r
+ String.format(\r
+ "The AVD manager normally uses the user's profile directory to store " +\r
+ "AVD files. However it failed to find the default profile directory. " +\r
+ "\n" +\r
+ "To fix this please set the environment variable ANDROID_SDK_HOME to " +\r
+ "a valid path such as \"%s\".",\r
+ example));\r
+\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
// -----\r
\r
/**\r
mAvdManager = null; // remove the old one if needed.\r
mAvdManager = new AvdManager(mSdkManager, mSdkLog);\r
} catch (AndroidLocationException e) {\r
- mSdkLog.error(e, "Unable to read AVDs");\r
+ mSdkLog.error(e, "Unable to read AVDs: " + e.toString()); //$NON-NLS-1$\r
+\r
+ // Note: we used to continue here, but the thing is that\r
+ // mAvdManager==null so nothing is really going to work as\r
+ // expected. Let's just display an error later in checkIfInitFailed()\r
+ // and abort right there. This step is just too early in the SWT\r
+ // setup process to display a message box yet.\r
+\r
+ mAvdManagerInitError = e;\r
}\r
\r
// notify adapters/parsers\r