Selasa, 11 Agustus 2015

Install Android SDK on Netbeans 7.2


If you have never used netbeans before, please  don't try to use this plug in. Wait until  you are familiar with the IDE first. 


I. INSTALL AND SETUP ANDROID SDK 



1. You need to download the Android SDK: 



2. Install the Android SDK to C:\Android\android-sdk 



3. Run Android SDK and install the recommended installations.  If you want to use your programs on your Android device, I suggest  installing the emulator for your device as well as the emulator for  the newest Android versions. 



II. SETUP ANDROID VIRTUAL DEVICE(AVD) 



4. In Android SDK, go to Tools> AVC Manager. 



5. Create a new Android Virtual Device(Emulator). Name it whatever you want.  Set the target to the version of Android you want to emulate. 



6. Set the size of the virtual SD card to whatever you want. For my first  Emulator i set it to 100 MB. 



7. Set Snapshot enabled to true to speed up future loading time. This takes a  snapshot of the Emulator State on closing so that it does not go through  the startup animations. 



8. Finally, click Create AVD at the bottom. 



III. TEST YOUR ANDROID EMULATOR 



9. Still in the AVD Manager, click Start. 



10. You will see that Save to snapshot has been selected. 



11. If you want it to load from that snapshot everytime, select  "LAUNCH FROM SNAPSHOT" 



12. The emulator runs very slowly, especially the first time  with the startup animations. You will get used to it after awhile. 



13. You should get to the menu screen. 



14. After checking that everything is okay, you can test out  the emulator, or exit out. 



15. Exiting saves a snapshot, which takes awhile. After taking the  first snapshot, it is okay to uncheck the "Save to snapshot". You really  don't need to do it after the first time, unless you want to save info  to the emulator for testing purposes, such as adding phone numbers, etc. 



IV. INSTALLING THE PLUGIN ON NETBEANS 



16. Start Netbeans. Go to Tools->Plugins->Settings  This is a list of all the places your plugin manager checks for updates. 



17. Add a new update center: http://kenai.com/projects/nbandroid/downloads/download/updatecenter/updates.xml  this is the home of the NetBeans Android project. 



18. After installing, go to Tools->Plugins->Available Plugins. There  should be a new plugin called Android. Install it. It is only about  700 kb.  I have had problems with the test runner on Netbeans 7.2. I think  the Test Runner for Netbeans 7.0 isn't compatable with 7.2. 



NOTE: On previous versions, you had to add Android to the Tools->Java Platforms.  (I Think). You don't need to do this anymore. 



19. Go to Tools->Options->Miscellaneous->Android  There is now an android tab in your options. Set the location  of your android SDK installation. Mine is C:\Android\android-sdk 



20. You should now be able to create an Android Project. File->New->Android->Android Project 



21. Name your Project. 



22. The convention for naming an Android Package is different than for 
normal Java Projects. 
WRONG: "MyPackage" //ERROR! 
RIGHT!: "My.Package" //GOOD! 
This is what it means when it says "Package name must have at least two parts" 



23. This is the source code for your main file: 



package bl.ah; 



import android.app.Activity; 
import android.os.Bundle; 



public class MainActivity extends Activity 
{ 
/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) 
{ 
super.onCreate(savedInstanceState); 
setContentView(R.layout.main); 
} 
} 



24. add import "My.Package.R" where My.Package is the name of your package. 



25. After Building, you can press Start to startup your android emulator. 




YOU CAN ALSO INSTALL A PACKAGE MANUALLY 
This is good practice anyway. 



26. Use the explorer to go to your project folder. In the bin folder, 
you should find a .apk file. This is the compressed version of your program. 
It works sort of like a .jar file. 



You can install it manually onto your emulator from the command line(start->search->cmd.exe if you haven't 
used the command line before. It can also be found in c:\windows\System32 or SysWOW64 



26. If you know how to set system variables, add C:\Android\android-sdk\platform tools; to your path 
26.b. If you don't know how, use the commandline: cd C:\Android\android-sdk\platform tools 



27. In this folder is adb.exe. This is the android debug bridge. 



START YOUR ANDROID EMULATOR NOW 
28. In the command prompt, type adb install C:\{path to project}\bin\{projectName}.apk 



EX: adb install C:\Sean\aa1\bin\aa1-debug.apk 



29. You should get 3 lines saying how large the installation file was, 
where it was installed, and whether it was successful. 



If it doesn't print this, either you typed in the instructions wrong, or you had an error. 
Here is more information about android bridgehttp://developer.android.com/tools/help/adb.html 




NOW, Run your android emulator. 
There should be an app named MainActivity. It was named after the class 
name. The icon is the green android. 



----------------------------- 
CONGRATS 



----------------------------- 
If you have any problems, this is the place to post them! 




---------------------------- 
For information about making GUI's I have found this page to be useful: 

Tidak ada komentar :

Posting Komentar