Search in sources :

Example 1 with AndroidLocationException

use of com.android.prefs.AndroidLocation.AndroidLocationException in project android by JetBrains.

the class KeystoreUtils method getOrCreateDefaultDebugKeystore.

public static File getOrCreateDefaultDebugKeystore() throws Exception {
    try {
        File debugLocation = new File(KeystoreHelper.defaultDebugKeystoreLocation());
        if (!debugLocation.exists()) {
            File keystoreDirectory = new File(AndroidLocation.getFolder());
            if (!keystoreDirectory.canWrite()) {
                throw new AndroidLocationException("Could not create debug keystore because \"" + keystoreDirectory + "\" is not writable");
            }
            ILogger logger = new StdLogger(StdLogger.Level.ERROR);
            // Default values taken from http://developer.android.com/tools/publishing/app-signing.html
            // Keystore name: "debug.keystore"
            // Keystore password: "android"
            // Keystore alias: "androiddebugkey"
            // Key password: "android"
            KeystoreHelper.createDebugStore(null, debugLocation, "android", "android", "AndroidDebugKey", logger);
        }
        if (!debugLocation.exists()) {
            throw new AndroidLocationException("Could not create debug keystore");
        }
        return debugLocation;
    } catch (AndroidLocationException exception) {
        throw new Exception("Failed to get debug keystore path", exception);
    }
}
Also used : StdLogger(com.android.utils.StdLogger) ILogger(com.android.utils.ILogger) AndroidLocationException(com.android.prefs.AndroidLocation.AndroidLocationException) GradleBuildFile(com.android.tools.idea.gradle.parser.GradleBuildFile) File(java.io.File) GradleSettingsFile(com.android.tools.idea.gradle.parser.GradleSettingsFile) KeyStoreException(java.security.KeyStoreException) AndroidLocationException(com.android.prefs.AndroidLocation.AndroidLocationException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 2 with AndroidLocationException

use of com.android.prefs.AndroidLocation.AndroidLocationException in project otertool by wuntee.

the class CreateAvdDialog method createContents.

/**
	 * Create contents of the dialog.
	 */
private void createContents() {
    shell = new Shell(getParent(), getStyle());
    shell.setSize(335, 236);
    shell.setText(getText());
    GridLayout gl_shell = new GridLayout(1, false);
    gl_shell.marginRight = 5;
    gl_shell.marginLeft = 5;
    gl_shell.marginTop = 5;
    gl_shell.verticalSpacing = 0;
    gl_shell.marginWidth = 0;
    gl_shell.horizontalSpacing = 0;
    gl_shell.marginHeight = 0;
    shell.setLayout(gl_shell);
    Label lblName = new Label(shell, SWT.NONE);
    lblName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    lblName.setText("Name:");
    text = new Text(shell, SWT.BORDER);
    text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
    new Label(shell, SWT.NONE);
    Label lblTarget = new Label(shell, SWT.NONE);
    lblTarget.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    lblTarget.setText("Target:");
    combo = new Combo(shell, SWT.READ_ONLY);
    combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
    addTargets(combo);
    new Label(shell, SWT.NONE);
    btnPersistantStorage = new Button(shell, SWT.CHECK);
    btnPersistantStorage.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
    btnPersistantStorage.setText("Persistant system storage");
    btnLaunchAvdAfter = new Button(shell, SWT.CHECK);
    btnLaunchAvdAfter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
    btnLaunchAvdAfter.setText("Launch AVD after creation");
    new Label(shell, SWT.NONE);
    composite = new Composite(shell, SWT.NONE);
    GridLayout gl_composite = new GridLayout(2, false);
    gl_composite.marginWidth = 0;
    gl_composite.marginHeight = 0;
    gl_composite.horizontalSpacing = 0;
    gl_composite.verticalSpacing = 0;
    composite.setLayout(gl_composite);
    composite.setLayoutData(new GridData(SWT.RIGHT, SWT.BOTTOM, true, true, 1, 1));
    Button btnCreateAvd = new Button(composite, SWT.NONE);
    btnCreateAvd.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
    btnCreateAvd.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            boolean exists = false;
            try {
                exists = AvdWorkshop.isAvdExist(text.getText());
            } catch (AndroidLocationException e) {
                logger.error("Problem getting avds: ", e);
            }
            if (text.getText().trim().equals("") || combo.getText().trim().equals("")) {
                GuiWorkshop.messageError(shell, "Please set a name, and select a target.");
            } else if (exists) {
                GuiWorkshop.messageError(shell, "There is already and AVD with that name, please use a name that does not already exist.");
            } else {
                result = new CreateAvdBean();
                result.setName(text.getText());
                result.setPersistant(btnPersistantStorage.getSelection());
                ;
                result.setTarget(combo.getText());
                result.setLaunch(btnLaunchAvdAfter.getSelection());
                shell.close();
            }
        }
    });
    btnCreateAvd.setText("Create AVD");
    Button btnCancel = new Button(composite, SWT.NONE);
    btnCancel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
    btnCancel.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            shell.close();
        }
    });
    btnCancel.setText("Cancel");
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) AndroidLocationException(com.android.prefs.AndroidLocation.AndroidLocationException) Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CreateAvdBean(com.wuntee.oter.view.bean.CreateAvdBean)

Aggregations

AndroidLocationException (com.android.prefs.AndroidLocation.AndroidLocationException)2 GradleBuildFile (com.android.tools.idea.gradle.parser.GradleBuildFile)1 GradleSettingsFile (com.android.tools.idea.gradle.parser.GradleSettingsFile)1 ILogger (com.android.utils.ILogger)1 StdLogger (com.android.utils.StdLogger)1 CreateAvdBean (com.wuntee.oter.view.bean.CreateAvdBean)1 File (java.io.File)1 IOException (java.io.IOException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 CertificateException (java.security.cert.CertificateException)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Combo (org.eclipse.swt.widgets.Combo)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 Shell (org.eclipse.swt.widgets.Shell)1