I just started Android programming. While trying to get device id for AdMob test device, I came across posts that indicated I needed to use the device id from telephony manager. The id did not work for AdMob. But here is the code to get the id from telephony manager.
import android.content.Context;
import android.telephony.TelephonyManager;
import android.util.Log;
public class DesiDeviceUtility {
private static final String TAG = "DesiDeviceUtility";
public static String getDeviceId(Context context)
{
final TelephonyManager tm =
(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
String deviceId = tm.getDeviceId();
Log.d(TAG, deviceId);
return deviceId;
}
}
Eclipse sucks. Java sucks. Android documentation sucks. That is my opinion now. It may change over time.
This is my first Android and Java project and I am new to Eclipse as well. So, it is expected that I will face a few issues along the way. Usually that is not a problem if there is a clean documentation available. Google is the king of no documentation or poor documentation. Oh, and when you know you suck, you provide no option for feedback, like no comments on this blog.
Anyways, here is the problem I had.
My main project refers to a library. It produces a jar file. Well, at least it is supposed to produce a jar file. Main project produces the apk file. It works fine as long as I don’t have to make changes to the library. Then it won’t rebuild. After a lot of searching on the Internet and finding no solution, I was playing with all the project and classpath files.
Then I added the APK builder to the library project and then suddenly the project started rebuilding the jar files.
To the .project file of the library project, I added this under build spec:
This entry is part 3 of 3 in the series Desi Videos
Here are some constraints that I had when I started off this morning.
- I have no experience in developing mobile apps.
- I have almost no knowledge of Java. Windows Phone development would have been much easier for me.
- I have never used Eclipse. I am a Visual Studio user and have plenty of Silverlight experience.
Recently I bought my first Android Phone (went from iPhone to Windows Phone to Android). The Lava Xolo X900 based on Intel Atom. This is basically an Intel Reference Design according to reviews. After seeing the enable debug option, I decided to jump in. Here is how I went until I was able to run my first app on the phone after about 8 hours.
Note: I chose to install 32 bit editions of the software on Windows 7 64 bit to be safe. On Windows, 64 bit is trouble whenever there are dependencies.
Begin downloading Android SDK while reading on the net. Then realized I need to install Eclipse. Started researching what version of Eclipse I needed. I also needed Java SDK. Research that one too.
Android SDK documents say I needed either 5 or 6 of the Java SDK. Even though 7 is available, I decided to stick with 6. It is on the same page as 7. Confusing title says it is Java SE 6 update 32. It is not like an update that need to be applied on an existing installation. It is the complete installation with the update. I also decided to use SE instead of EE/ME because of references to it all over the net.
Next step, I installed Eclipse for Java SE. Not the kind of installation you expect on Windows. Just an extract on to a folder. I went with c:\eclipse instead of user folder.
Next installed the Android SDK. It starts up SDK manager and Intel Android USB driver. From the Android SDK manager, I selected all the extras, Android 2.3.3 with Intel Atom x86 System Image in addition to the default selections.
Once done, opened eclipse and went to help->install new software. Added ADT Plugin – http://dl-ssl.google.com/android/eclipse/ (https) didn’t work for me until I added http as well.
From there it was easy even though eclipse sucked compared to Visual Studio in my experience. But I will stick with it for now.
Getting the simple app to run on the simulator took a while. But the answers are out there.
Exception has been thrown by the target of an invocation.
at System.Windows.Navigation.PageResourceContentLoader.EndLoad(IAsyncResult asyncResult)
at System.Windows.Navigation.NavigationService.ContentLoader_BeginLoad_Callback(IAsyncResult result)
Things to look for are in the Xaml.
- It could be a style assigned to the wrong target type.
I just got this error when I was trying build a project.
error CS1668 : Warning as error : Invalid search path ‘c:\Program Files\Microsoft Visual Studio 9.0\VC\PlatformSDK\lib’ specified in ‘LIB environment variable’ — ‘The system cannot find the path specified. ‘
I remember seeing this error before and fixed it by faking the directories. This time I know why it happened. I just uninstalled the Silverlight 2.0 SDK. I don’t need it anymore. I have no idea why the Silverlight 2.0 SDK would delete this folder and contents. If it did, why didn’t it remove it from the LIB environment variable? Reboot didn’t help. I could fix it by updating the LIB variable or just create the directory structure.