Sdk folder location

38 views
Skip to first unread message

Ryan Bis

unread,
Apr 15, 2012, 1:57:08 PM4/15/12
to adt...@googlegroups.com
Ok, my plugin essential copies the adt plugin enough to duplicate the new wizard. The other day I decided to update my plugin to the newest version. Of course, like an idiot, I didn't back up my old version. But anyways, I'm having an issue with the sdk folder location. It seems to be when the plugin tries to use getOsSdkFolder. It seems to lock it, and eclipse "loses" the location of the sdk folder.

Is there a safe way to get the sdk folder without locking it?

(It's called within the AltBridge class - which is essentially the same as the AdtPlugin class. The method runs the getossdkfolder method from the AdtPrefs class).


Tor Norbye

unread,
Apr 16, 2012, 12:32:17 PM4/16/12
to adt...@googlegroups.com
On Sun, Apr 15, 2012 at 10:57 AM, Ryan Bis <impi...@gmail.com> wrote:
> Ok, my plugin essential copies the adt plugin enough to duplicate the new
> wizard. The other day I decided to update my plugin to the newest version.
> Of course, like an idiot, I didn't back up my old version. But anyways, I'm
> having an issue with the sdk folder location. It seems to be when the plugin
> tries to use getOsSdkFolder. It seems to lock it, and eclipse "loses" the
> location of the sdk folder.
>
> Is there a safe way to get the sdk folder without locking it?

Can you give some more information on what "locking" you are referring
to here? There are no locks on that method, it's a simple accessor.

-- Tor

Ryan Bis

unread,
Apr 16, 2012, 12:41:48 PM4/16/12
to adt...@googlegroups.com
Well, using AdtPrefs.getPrefs().getOsSdkFolder() doesn't return anything when I run it through my plugin. (So it doesn't copy over the proguard file, and causes the wizard to die out there). Then, if I try to use the regular adt wizard to create a new project, it also returns nothing for the sdk folder. However, if I close eclipse and restart, then use the adt create new project wizard everything works fine. It's only when I use my plugin's new project wizard that this happens. I was able to narrow it down to that method.



On Monday, April 16, 2012 12:32:17 PM UTC-4, Tor Norbye wrote:

Julia Perdigueiro

unread,
Apr 16, 2012, 2:02:43 PM4/16/12
to adt...@googlegroups.com
have you tried this?

IEclipsePreferences pref = InstanceScope.INSTANCE.getNode("com.android.ide.eclipse.adt");
String sdkPath = pref.get("com.android.ide.eclipse.adt.sdk", "");

Raphaël Moll

unread,
Apr 16, 2012, 2:31:41 PM4/16/12
to adt...@googlegroups.com
On Mon, Apr 16, 2012 at 9:41 AM, Ryan Bis <impi...@gmail.com> wrote:
Well, using AdtPrefs.getPrefs().getOsSdkFolder() doesn't return anything when I run it through my plugin. (So it doesn't copy over the proguard file, and causes the wizard to die out there). Then, if I try to use the regular adt wizard to create a new project, it also returns nothing for the sdk folder. However, if I close eclipse and restart, then use the adt create new project wizard everything works fine. It's only when I use my plugin's new project wizard that this happens. I was able to narrow it down to that method.


A quick look at the code shows that AdtPrefs holds a singleton. From what you said, it's clear the prefs aren't initialized yet when you try to acccess them.
So what does initialize it? AdtPrefs.loadValues() does. 
Where is it called from? From AdtPlugin.start(bundle).

So my suggestion would be to either make sure the AdtPlugin bundle is started properly, or that you call AdtPrefs.getPrefs().loadValues(null /*event*/) yourself once.

And of course all this is marked as internal for a reason. Relying on it is risky.
If you need us to provide extension points, feel free to tell us what you'd like (even better: discuss it here _first_ and _then_ provide an implementation via a changeset on gerrit.)

HTH
R/

Ryan Bis

unread,
Apr 16, 2012, 2:55:41 PM4/16/12
to adt...@googlegroups.com
Julia,
 Thank you, that worked to get the folder.

R:
Ok, I obviously went about this the wrong way then. What I wanted to do is have a seperate new project wizard which does the same thing as the adt wizard, but also copies a jar file into the new project, along with some other java classes, and some extra folders, and xml files. It also replaces the default Activity class that is first generated by the wizard. It also copies the viewrules jar into the project, and adds the modification to the project.properties file.

What would be the best approach to achieving this?

Thanks.


On Monday, April 16, 2012 2:31:41 PM UTC-4, Raphaël wrote:

Ryan Bis

unread,
Apr 18, 2012, 4:21:57 PM4/18/12
to adt...@googlegroups.com
Ok, so I tried a different approach this time. After messing about, I decided it would be best to do this without using the adtplugin class, or adtprefs (the only thing I needed was the SDK folder location, which Julia so kindly pointed out for me). Now, the problem I have is that the project doesn't generate the R file automatically. If I exit eclipse, then go back in, and clean the project, everything is fine (the R file gets generated, and errors go away).

I think it's a problem with aapt (when I use a wizard from my plugin, I get an error saying aapt could not be found. A restart of eclipse fixes this until I use something from my plugin again). Could you point me in the direction of the methods that control this? (I think this has been the real underlying issue I've had all along).

Thanks,
Ryan

Reply all
Reply to author
Forward
0 new messages