Setting Up Xamarin Studio Business Edition v4.0.3 for Google Nexus 7 and UG007 MiniPC Development
Contents:
- Using the Android SDK Manager
- Supporting a Google Nexus 7 with the Android 4.2 OS Update
- Supporting the UG007 or UG007 II Android MiniPC
- Xamarin Employees List Sample Program Fails to Run with Nexus 7 or UG007 AVDs
Updated 4/10/2013 with the following Visual Studio 2012 Update 2 issue apparently caused by a installing a Xamarin.Android 4.6.2 update of 4/10/2013:
Visual Studio’s Extensions and Updates dialog shows the Xamarin.Android version to be v4.6.49, not v4.6.2.
Control Panel’s Program and Features pane shows the version to be 4.6.02001.
Team Xamarin’s Chris Hardy (@chrisntr) replied to my How Do I Create Working Android Virtual Devices for Nexus 7 and UG007 MiniPC? crosspost from StackOverflow to the Xamarin Developer Center’s Android Forum on 4/10/2013:
It looks like you're having problems because your SD Card size is set to 100mb, when we recommend a minimum of 512mb (as we preload the whole of the Mono framework on the device - http://docs.xamarin.com/guides/android/advanced_topics/application_package_sizes), so try changing that value and see if that gets you up and running.
It's worth noting that Xamarin don't provide any AVDs (we just set up a few by default on installation), these are provided by Google via the Android Virtual Device Manager (AVD Manager) and we would recommend deploy directly to device or to use a x86 emulator - http://docs.xamarin.com/guides/android/deployment,_testing,_and_metrics/configuring_the_x86_emulator as this is much much faster than the slow Google provided emulators.
Increasing the SD Card Size value to 1 GiB didn’t solve the problem with Xamarin Studio; both AVDs throw a "Deployment Failed. Internal Error" exception. Currently, I can’t test with Visual Studio because of the issue reported above.
Updated 4/9/2013 with addition of monodroid.log file excerpts for Nexus 7 and UG007 AVDs, and links to copies of them and exception detail screen captures to my public SkyDrive account here.
The current version of Xamarin Studio was v4.0.3 (build 13) when this post was written in early April 2013.
Installing Xamarin Studio adds a Xamarin Account item to the Tools menu, which provides access to your account information, and a Xamarin item to the Tools | Options menu:
The UG007 and UG007 II MiniPCs run Android v4.1.1 (Jelly Bean) and the latest update to the Google Nexus 7 is Android v4.2. For more information about the UG007 and UG007 II, see my earlier First Look at the CozySwan UG007 and Other Android 4.1+ MiniPC Devices post. Support for these Android versions isn’t provided in the default Xamarin Studio 4.0.3 installation.
Using the Android SDK Manager
Xamarin Studio deploys Google’s Android SDK to your C:\Users\UserName\AppData\Local\Android\android-sdk folder by default. The Android SDK Manager is part of the Android SDK and runs from Eclipse or Windows. Open the Android SDK Manager from Windows 7’s Start, All Programs, Android SDK Tools menu. By default, Xamarin Studio v4.0.3 includes Android SDK versions 2.1 to 4.0.3, as shown (partially) by the Android SDK Manager here:
Note: Only Android 3.1 includes a reference to the Google TV Addon, which isn’t compatible with Windows.
Supporting a Google Nexus 7 with the Android 4.2 OS Update
To fully support the Nexus 7 with an updated OS, you must install the Android 4.2.2 (API 17), as shown here:
Note: Downloading and installing the two APIs without MIPS images requires about 30 minutes with a moderate-speed DSL connection.
Note: Xamarin issued a Xamarin.Android 4.6.2 update on 4/10/2013 not shown above.
The Nexus 7 has a predefined device, but requires creating a new Android Virtual Device (AVD) from the Android SDK Manager’s Tools menu:
If you specify 1 GB RAM in the Memory Options section, which the Nexus 7 and UG007 provide, you receive the following warning:
Warning: Specifying a large SD card, such as 32 GB for the SD card installed in my UG007 creates an image file of the same size on your development machine. A tooltip recommends a minimum of 9 MiB, but Xamarin recommends a minimum of 512 MB. I use 1 GiB for safety.
The following dialog confirms the properties of the newly-created AVD:
Click the Android Virtual Devices tab, select the AVD_for_Nexus_7_by_Google item:
Click the Start button to open the Launch Options dialog to determine if your development machine has enough free RAM to run the emulator with the requested RAM size specified earlier. Optionally, mark the Scale Display to Real Size check box:
Note: Don’t mark the Launch from Snapshot checkbox if you haven’t run the AVD previously.
Click Launch to validate the requested RAM value. If the requested RAM isn’t available, the following message appears:
In this case, click Edit, reduce the requested RAM (to 512 MB for this example), and repeat the test process until the expected emulator image appears as follows:
Leave the emulator running if it’s the AVD you plan to use with Visual Studio or Xamarin Studio; otherwise close it to conserve RAM.
In Visual Studio 2012, open the Properties window for the EmployeeDirectory.Android project, open the Minimum Android to Target list and select Android 4.2 for the Nexus 7 AVD:
When you change the Minimum Android version, you must close the project (saving changes) and reopen it.
Supporting the UG007 or UG007 II Android MiniPC
To support the UG007, you must install the Android 4.2.2 (API17) package, define a UG007 device and then create a new UG007 AVD. To define a UG007 device, choose Manage AVDs from the Tools menu and select the Device Definitions tab:
Click New Device to open the Create New Device window and specify the following settings:
Click Create Device to add the device to the list:
With the UG007 item selected, click the Create AVD button and apply the following settings:
See the notes regarding recommended minimum SD card size in the Nexus 7 section above;
Click OK to create the new AVD:
Click OK to display the new AVD in the list:
If you have sufficient RAM, the following emulator image appears:
In Visual Studio 2012, open the Properties window for the EmployeeDirectory.Android project, open the Minimum Android to Target list and select Android 4.1 for the UG007 AVD:
When you change the Minimum Android version, you must close the project (saving changes) and reopen it.
When you run a Mono for Android project in Visual Studio with F5, the following dialog opens:
Similarly, Xamarin Studio displays this dialog:
Select the running emulator to use and click OK.
Xamarin Employees List Sample Program Fails to Run with Nexus 7 or UG007 AVDs
After rebuilding the Employees List sample program for Android v4.1 or v4.2 and running it with F5:
- In Visual Studio 2012, the project hangs on Waiting for device… and displays this message:
- In Xamarin Studio, deployment fails with an internal error:
Following is an excerpt from the monodroid.log file for the Nexus 7 AVD with the emulator running when pressing F5:
Mono.AndroidTools.AndroidLogger Verbose: 0 : -- Start Push - 04/09/2013 11:44:42 (117.168ms) -- Mono.AndroidTools.AndroidLogger Verbose: 0 : [INPUT] C:\Program Files (x86)\MSBuild\Xamarin\Android\Mono.Android.DebugRuntime-armeabi-v7a.apk : /data/local/tmp/Mono.Android.DebugRuntime-armeabi-v7a.apk Mono.AndroidTools.AndroidLogger Verbose: 0 : [OUTPUT] Faulted: System.AggregateException: One or more errors occurred. ---> Mono.AndroidTools.AdbException: No such file or directory at Mono.AndroidTools.Util.AggregateAsyncResult.CheckError(CancellationToken token) at Mono.AndroidTools.Adb.AdbSyncClient.EndPush(IAsyncResult result) at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization) --- End of inner exception stack trace --- ---> (Inner Exception #0) Mono.AndroidTools.AdbException: No such file or directory at Mono.AndroidTools.Util.AggregateAsyncResult.CheckError(CancellationToken token) at Mono.AndroidTools.Adb.AdbSyncClient.EndPush(IAsyncResult result) at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)<--- Mono.AndroidTools.AndroidLogger Verbose: 0 : -- End Push -- Mono.AndroidTools.AndroidLogger Verbose: 0 : [D:RunShellCommand]: emulator-5554 rm "/data/local/tmp/Mono.Android.DebugRuntime-armeabi-v7a.apk" Mono.AndroidTools.AndroidLogger Verbose: 0 : -- Start DeleteFile - 04/09/2013 11:44:42 (91.7816ms) -- Mono.AndroidTools.AndroidLogger Verbose: 0 : [INPUT] rm "/data/local/tmp/Mono.Android.Debug
With the UG007 AVD emulator running when pressing F5, the problem occurs at this point:
Mono.VisualStudio.Extension.ProcessWrapper Verbose: 0 : -- Starting Process - 04/09/2013 12:34:30 -- Mono.VisualStudio.Extension.ProcessWrapper Verbose: 0 : Executable: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe Mono.VisualStudio.Extension.ProcessWrapper Verbose: 0 : Arguments: /p:Configuration=Debug /p:Platform="AnyCPU" /target:SignAndroidPackage "C:\Users\Administrator\Documents\Xamarin Studio\EmployeeDirectoryDemo\EmployeeDirectory.Android\EmployeeDirectory.Android.csproj" Mono.VisualStudio.Extension.ProcessWrapper Verbose: 0 : -- Process Finished [2147483647] -- Mono.AndroidTools.AndroidLogger Verbose: 0 : [D:RunShellCommand]: emulator-5554 "pm" "path" "android" Mono.AndroidTools.AndroidLogger Verbose: 0 : [D:WaitUntilReady]: -- Device not ready yet, output: Error: Could not access the Package Manager. Is the system running? Mono.AndroidTools.AndroidLogger Verbose: 0 : [D:RunShellCommand]: emulator-5554 "pm" "path" "android" Mono.AndroidTools.AndroidLogger Verbose: 0 : [D:WaitUntilReady]: -- Device not ready yet, output: Error: Could not access the Package Manager. Is the system running?
These messages continue for several minutes until the Deploy Error message appears and the end of the monodroid.log file appears as shown here:
Mono.AndroidTools.AndroidLogger Verbose: 0 : [D:RunShellCommand]: emulator-5554 am broadcast -a mono.android.intent.action.PACKAGE_VERSIONS -e "packages" "Mono.Android.DebugRuntime,Mono.Android.Platform.ApiLevel_14,EmployeeDirectory.Android" Mono.Android.DebugRuntime/com.xamarin.mono.android.PackageVersions Mono.AndroidTools.AndroidLogger Verbose: 0 : -- Start Broadcast - 04/09/2013 13:05:32 (5580.5308ms) -- Mono.AndroidTools.AndroidLogger Verbose: 0 : [INPUT] am broadcast -a mono.android.intent.action.PACKAGE_VERSIONS -e "packages" "Mono.Android.DebugRuntime,Mono.Android.Platform.ApiLevel_14,EmployeeDirectory.Android" Mono.Android.DebugRuntime/com.xamarin.mono.android.PackageVersions Mono.AndroidTools.AndroidLogger Verbose: 0 : [OUTPUT] Error type 2 android.util.AndroidException: Can't connect to activity manager; is the system running? at com.android.commands.am.Am.run(Am.java:100) at com.android.commands.am.Am.main(Am.java:81) at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235) at dalvik.system.NativeStart.main(Native Method) Mono.AndroidTools.AndroidLogger Verbose: 0 : -- End Broadcast -- Mono.AndroidTools.AndroidLogger Verbose: 0 : [D:RunShellCommand]: emulator-5554 cat /data/system/packages.xml Mono.AndroidTools.AndroidLogger Verbose: 0 : -- Start GetPackages - 04/09/2013 13:05:37 (77.1277ms) -- Mono.AndroidTools.AndroidLogger Verbose: 0 : [INPUT] cat /data/system/packages.xml Mono.AndroidTools.AndroidLogger Verbose: 0 : [OUTPUT] /system/bin/sh: cat: /data/system/packages.xml: No such file or directory Mono.AndroidTools.AndroidLogger Verbose:
I’ve uploaded the full monodroid.log files and a capture of the exception details window for the Nexus 7 and UG007 AVDs to the public Xamarin Studio folder of my SkyDrive account here.
The sample program deploys as expected in both Visual Studio and Xamarin Studio with the MonoForAndroid_API_15 AVD:
I will update this post when I learn more about the problem from replies to my How Do I Create Working Android Virtual Devices for Nexus 7 and UG007 MiniPC? question on Stack Overflow. I didn’t receive a useful reply from stack overflow, so I posted the same question to Xamarin’s Android forum.
Full disclosure: I have a complimentary license for Xamarin Studio Business Edition.
0 comments:
Post a Comment