Adding drawables to an ImageView - android

I am having an issue with Mono for Android and adding drawables as background images or image resources in an ImageView. I have a file in my drawable folder called LogoLarge.png, which I want to display. Its Build Action is set to AndroidResource. So I try this:
<ImageView
android:id="#+id/Logo"
android:src="#drawable/LogoLarge"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
The LogoLarge resource is referenced in Resource.Designer.cs. Building the project works fine. When I try to deploy to the emulator, I get the following in the build output:
C:\Program Files (x86)\MSBuild\Novell\mandroid.exe -v --nosign --sdk-dir="C:\Android" --builddir="C:\Users\Vegard\Documents\Visual Studio 2010\Projects\HelloAndroid\HelloWorld2\obj\Debug\android" --framework-dir="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.2" --framework-dir="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0" -S="C:\Users\Vegard\Documents\Visual Studio 2010\Projects\HelloAndroid\HelloWorld2\obj\Debug\res" --package="HelloWorld2.HelloWorld2" --nolink --abi="armeabi" --java-sdk-dir="C:\Program Files\Java\jdk1.6.0_26" --debug --manifest-template="C:\Users\Vegard\Documents\Visual Studio 2010\Projects\HelloAndroid\HelloWorld2\Properties\AndroidManifest.xml" --sdk-platform="8" "C:\Users\Vegard\Documents\Visual Studio 2010\Projects\HelloAndroid\HelloWorld2\bin\Debug\HelloWorld2.dll" "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.2\Mono.Android.dll" "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll" "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Core.dll" "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.dll" "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.dll" "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.Linq.dll"
monodroid : error 1: System.NullReferenceException: Object reference not set to an instance of an object [C:\Users\Vegard\Documents\Visual Studio 2010\Projects\HelloAndroid\HelloWorld2\HelloWorld2.csproj]
at MonoDroid.Utils.ProcessRocks+<ReadStandardOutput>c__Iterator5.MoveNext () [0x00000] in <filename unknown>:0
at Monodroid.Toolbox.InvokeCommand (IEnumerable`1 commandLine) [0x00000] in <filename unknown>:0
at Monodroid.Toolbox.InvokeAapt (System.String packageName) [0x00000] in <filename unknown>:0
at Monodroid.Droidinator.CreatePackagedResources (System.Collections.Generic.List`1 javaTypes) [0x00000] in <filename unknown>:0
at Monodroid.Droidinator.CreateApk () [0x00000] in <filename unknown>:0
at Monodroid.MainClass.Main (System.String[] argv) [0x00000] in <filename unknown>:0
Done Building Project "C:\Users\Vegard\Documents\Visual Studio 2010\Projects\HelloAndroid\HelloWorld2\HelloWorld2.csproj" (SignAndroidPackage target(s)) -- FAILED.
If I remove the android:src property from the XML file, and put this in my Activity1.cs file, it works:
ImageView i = FindViewById<ImageView>(Resource.Id.Logo);
i.SetImageResource(Resource.Drawable.LogoLarge);
The same issue also occurs when trying to set a background image for any view using android:background="#drawable/SomeBackground" in XML, but works fine when doing it programmatically.
What is happening here. Is this a bug in MonoDroid?

I think that your LogoLarge must be logolarge , because you only can use lower case letters in the drawables.

Related

Xamarin.Android APK Deployment failed - INSTALL_FAILED_INVALID_APK base.apk code is missing

My Xamarin.Android app can no longer be deployed to an emulator/device. I can compile it successfully and the deployment process is started but in the end it fails. I'm using Visual Studio for Mac and Xamarin.Android:
[INSTALL_FAILED_INVALID_APK: Package couldn't be installed in
/data/app/my.app.bundle.id-agudyKm4Ib_8OheG3_5zmg==: Package
/data/app/my.app.bundle.id-agudyKm4Ib_8OheG3_5zmg==/base.apk code is
missing]
My build configuration is below:
Multi-dex = ON because without it I'm getting the DEX size error
DEX compiler = DX (D8 doesn't work, I'm getting a compilation error that some classes are missing, see below)
Code shrinker = Off (this is a debug build to run on local emulator/device)
This error occurs if I set DEX compiler to D8:
R8 : warning : Missing class: androidx.appcompat.widget.AppCompatEditText (and 10 more similar errors)
missing R8 : error : Compilation can't be completed because some library classes are missing.
The error occurs with all the settings above, this is basically the only configuration I can build my app but unable to deploy it to device:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: Deployment failed
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: Mono.AndroidTools.InstallFailedException: Failure [INSTALL_FAILED_INVALID_APK: Package couldn't be installed in /data/app/my.app.bundle.id-agudyKm4Ib_8OheG3_5zmg==: Package /data/app/my.app.bundle.id-agudyKm4Ib_8OheG3_5zmg==/base.apk code is missing]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess (System.String output, System.String packageName) [0x00152] in /Users/runner/runners/2.165.0/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Internal/AdbOutputParsing.cs:341
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: at Mono.AndroidTools.AndroidDevice+<>c__DisplayClass95_0.<InstallPackage>b__0 (System.Threading.Tasks.Task`1[TResult] t) [0x00016] in /Users/runner/runners/2.165.0/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/AndroidDevice.cs:753
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: at System.Threading.Tasks.ContinuationTaskFromResultTask`1[TAntecedentResult].InnerInvoke () [0x00024] in <f9d1b832704f410aa8ec771f4fe80552>:0
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: at System.Threading.Tasks.Task.Execute () [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-10/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2319
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: --- End of stack trace from previous location where exception was thrown ---
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: at AndroidDeviceExtensions.PushAndInstallPackage (Mono.AndroidTools.AndroidDevice device, System.String apkFile, System.String packageName, System.Boolean reinstall, Mono.AndroidTools.Adb.AdbProgressReporter notifyProgress, System.Threading.CancellationToken token) [0x00189] in /Users/runner/runners/2.165.0/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:187
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: at AndroidDeviceExtensions.PushAndInstallPackage (Mono.AndroidTools.AndroidDevice device, System.String apkFile, System.String packageName, System.Boolean reinstall, Mono.AndroidTools.Adb.AdbProgressReporter notifyProgress, System.Threading.CancellationToken token) [0x003df] in /Users/runner/runners/2.165.0/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:203
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: at Xamarin.AndroidTools.AndroidDeploySession.InstallPackage () [0x003be] in /Users/runner/runners/2.165.0/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:433
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: at Xamarin.AndroidTools.AndroidDeploySession.RunAsync (System.Threading.CancellationToken token) [0x003ae] in /Users/runner/runners/2.165.0/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:217
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: at Xamarin.AndroidTools.AndroidDeploySession.RunLoggedAsync (System.Threading.CancellationToken token) [0x0002f] in /Users/runner/runners/2.165.0/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:119
Not a Xamarin expert but if you can see the native files, can you check gradle.properties if it has:
android.useAndroidX=true
android.enableJetifier=true
Also inside the build.gradle of the native files (app directory) you should have:
implementation "androidx.appcompat:appcompat:1.1.0"
Unfortunately the I wasn't able to make it work with DEX Compiler = DX, and when you switch to D8, the migration to AndroidX is required. In terms of Xamarin, you have to add the following package and all additional requested dependencies:
<PackageReference Include="Xamarin.AndroidX.AppCompat">
<Version>1.1.0</Version>
</PackageReference>
Another issue I hit was the usage of old packages.config file which have to be migrated to the project PackageReference. This is not supported from Visual Studio for Mac so you have to switch to Windows to accomplish that tasks. A lot of extra steps just to compile an application in support.

The "ConvertResourcesCases" task failed unexpectedly. Xamarin Android build

When I build my Xamarin Android app with Visual Studio 2017 for Mac(7.7.4 build 1), Mono JIT compiler version 5.18.0.248 (2018-08/a4956c837e1 Fri Jan 25 16:13:12 EST 2019) I get the following exceptions:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: The "ConvertResourcesCases" task failed unexpectedly.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: System.IO.IOException: Could not create file "/Users/username/Companymobil/src/Company.Recipes.Droid/obj/Debug/lp/35/jl/res/values-ca/values-ca.xml" or "/var/folders/b5/821mhz8n0px17rnxglrjq5mc0000gp/T/tmp565e9644.tmp". File already exists.
/var/folders/b5/821mhz8n0px17rnxglrjq5mc0000gp/T/
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) [0x00193] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-08/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.IO/File.cs:111
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Xamarin.Android.Tasks.ConvertResourcesCases.FixupResources (Microsoft.Build.Framework.ITaskItem item, System.Collections.Generic.Dictionary`2[TKey,TValue] acwMap) [0x00204] in <78f051a6e2064f849cc3ee585300af39>:0
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Xamarin.Android.Tasks.ConvertResourcesCases.FixupResources (System.Collections.Generic.Dictionary`2[TKey,TValue] acwMap) [0x0000f] in <78f051a6e2064f849cc3ee585300af39>:0
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Xamarin.Android.Tasks.ConvertResourcesCases.Execute () [0x000a7] in <78f051a6e2064f849cc3ee585300af39>:0
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00023] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-08/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:573
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x001f6] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-08/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:784
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: The "ConvertResourcesCases" task failed unexpectedly.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: System.IO.IOException: Could not create file "/Users/username/Companymobil/src/Company.ServerAnnouncement.Droid/obj/Debug/lp/15/jl/res/layout/notification_template_icon_group.xml" or "/var/folders/b5/821mhz8n0px17rnxglrjq5mc0000gp/T/tmp4d4475a7.tmp". File already exists.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) [0x00193] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-08/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.IO/File.cs:111
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Xamarin.Android.Tasks.ConvertResourcesCases.FixupResources (Microsoft.Build.Framework.ITaskItem item, System.Collections.Generic.Dictionary`2[TKey,TValue] acwMap) [0x00204] in <78f051a6e2064f849cc3ee585300af39>:0
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Xamarin.Android.Tasks.ConvertResourcesCases.FixupResources (System.Collections.Generic.Dictionary`2[TKey,TValue] acwMap) [0x0000f] in <78f051a6e2064f849cc3ee585300af39>:0
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Xamarin.Android.Tasks.ConvertResourcesCases.Execute () [0x000a7] in <78f051a6e2064f849cc3ee585300af39>:0
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00023] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-08/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:573
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x001f6] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-08/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:784
If I click on Build (NOT Rebuild) those exceptions get less every time I build until it finally builds successfully.
If I use jetbrains Rider, the build works every single time.
I gave full permissions (r/w) to everyone on the directories mentioned in the exception and I still get the error. I use APFS case-insensitive.
I would be very grateful for any pointer to solve this.
Thank you very much Leon Lu from Microsoft for pointing me in the right direction. The error stems from a condition in parallel building xamarin android. When parallel builds are disabled, the outcome is the same each time. Parallel builds can be disabled in the Preferences of Visual Studio 2017 for Mac (see attached image).
The issue seems to be fixed (see GitHub link in Leon Lu's comment) and be rolling out in one of the future updates.

Unity - Error building Player: CommandInvokationFailure: Failed to re-package resources

I'm having some issues with Google Play Services and Unity 5.0.4.
The issue occurs when I want to build my build my project, I get the following error
CommandInvokationFailure: Failed to re-package resources.
I've read a lot and tried to fix it, but no solution been working for me.
I've got the latest Google Play serivces (Rev 32), Google Repository (Rev 32) and Android Support Repository (Rev 35).
I've also read that you can't have API 24 installed, so I've uninstalled and removed it completely. I can't find any other solution to my problem.
Whole console log:
CommandInvokationFailure: Failed to re-package resources.
C:\Android\android-sdk\build-tools\23.0.3\aapt.exe package
--auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "C:/Android/android-sdk\platforms\android-23\android.jar" -F
bin/resources.ap_ --extra-packages
com.google.example.games.mainlibproj stderr[ AndroidManifest.xml:19:
error: Error: No resource found that matches the given name (at
'value' with value '#integer/google_play_services_version'). ]
stdout[ Configurations: (default) v14 v21 xhdpi-v4 Files:
drawable\app_banner.png
Src: (xhdpi-v4) res\drawable-xhdpi\app_banner.png drawable\app_icon.png
Src: () res\drawable\app_icon.png values\strings.xml
Src: () res\values\strings.xml values\styles.xml
Src: () res\values\styles.xml
Src: (v14) res\values-v14\styles.xml
Src: (v21) res\values-v21\styles.xml AndroidManifest.xml
Src: () AndroidManifest.xml Resource Dirs: Type drawable
drawable\app_banner.png
Src: (xhdpi-v4) res\drawable-xhdpi\app_banner.png
drawable\app_icon.png
Src: () res\drawable\app_icon.png Type values
values\strings.xml
Src: () res\values\strings.xml
values\styles.xml
Src: () res\values\styles.xml
Src: (v14) res\values-v14\styles.xml
Src: (v21) res\values-v21\styles.xml Including resources from package: C:\Android\android-sdk\platforms\android-23\android.jar
applyFileOverlay for drawable applyFileOverlay for layout
applyFileOverlay for anim applyFileOverlay for animator
applyFileOverlay for interpolator applyFileOverlay for transition
applyFileOverlay for xml applyFileOverlay for raw applyFileOverlay for
color applyFileOverlay for menu applyFileOverlay for mipmap Processing
image: res\drawable-xhdpi\app_banner.png Processing image:
res\drawable\app_icon.png
(processed image res\drawable\app_icon.png: 94% size of source)
(processed image res\drawable-xhdpi\app_banner.png: 93% size of source)
(new resource id app_banner from xhdpi-v4\drawable\app_banner.png #generated)
(new resource id app_icon from drawable\app_icon.png #generated) ] UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo
psi, UnityEditor.Android.WaitingForProcessToExit
waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.PostProcessor.Tasks.TasksCommon.Exec
(System.String command, System.String args, System.String workingdir,
System.String errorMsg)
UnityEditor.Android.PostProcessor.Tasks.BuildResources.CompileResources
(UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessor.Tasks.BuildResources.Execute
(UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks
(UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.HostView:OnGUI()
There can be following possible problems:
There might be some duplicate jar files in your plugins folder. Find them and remove one of them to fix this problem.
There might be an issue with merging data from more than one manifest files.
Check following posts to get the pointer :
http://forum.unity3d.com/threads/commandinvokationfailure-android-asset-packaging-tool-failed-no-stderr-to-lookup.274631/
http://answers.unity3d.com/questions/1074000/unity-5-android-build-failed-to-re-package-resourc.html
https://github.com/playgameservices/play-games-plugin-for-unity/issues/900
https://github.com/playgameservices/play-games-plugin-for-unity/issues/1011
Error building player for Android in Unity?
EDIT :
You are missing res folder in plugins.
Check this answer : https://stackoverflow.com/a/38076937/4366237
And this forum post : http://forum.unity3d.com/threads/help-cant-build-project-after-trying-to-use-google-play-services.243284/

Unity 3d android building error

When I try to build a .apk file it gives me the following 2 errors:
Error building Player: Win32Exception:
ApplicationName='C:/Users/Teodor/AppData/Local/Android/android-sdk/platforms/android-18\aapt.exe',
CommandLine='package -v -f -m -J gen -M AndroidManifest.xml -S "res"
-I "C:/Users/Teodor/AppData/Local/Android/android-sdk/platforms/android-18\android.jar"
-F bin/resources.ap_', CurrentDirectory='Temp/StagingArea' UnityEditor.HostView:OnGUI()
and
Exception: Error building Player: Win32Exception:
ApplicationName='C:/Users/Teodor/AppData/Local/Android/android-sdk/platforms/android-18\aapt.exe',
CommandLine='package -v -f -m -J gen -M AndroidManifest.xml -S "res"
-I "C:/Users/Teodor/AppData/Local/Android/android-sdk/platforms/android-18\android.jar"
-F bin/resources.ap_', CurrentDirectory='Temp/StagingArea' UnityEditor.BuildPlayerWindow.BuildPlayerWithDefaultSettings (Boolean
askForBuildLocation, BuildOptions forceOptions) (at
C:/BuildAgent/work/842f9557127e852/Editor/Mono/BuildPlayerWindow.cs:367)
UnityEditor.BuildPlayerWindow.GUIBuildButtons (Boolean
enableBuildButton, Boolean enableBuildAndRunButton, Boolean
canInstallInBuildFolder) (at
C:/BuildAgent/work/842f9557127e852/Editor/Mono/BuildPlayerWindow.cs:972)
UnityEditor.BuildPlayerWindow.ShowBuildTargetSettings () (at
C:/BuildAgent/work/842f9557127e852/Editor/Mono/BuildPlayerWindow.cs:953)
UnityEditor.BuildPlayerWindow.OnGUI () (at
C:/BuildAgent/work/842f9557127e852/Editor/Mono/BuildPlayerWindow.cs:726)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags
invokeAttr, System.Reflection.Binder binder, System.Object[]
parameters, System.Globalization.CultureInfo culture) Rethrow as
TargetInvocationException: Exception has been thrown by the target of
an invocation. System.Reflection.MonoMethod.Invoke (System.Object obj,
BindingFlags invokeAttr, System.Reflection.Binder binder,
System.Object[] parameters, System.Globalization.CultureInfo culture)
System.Reflection.MethodBase.Invoke (System.Object obj,
System.Object[] parameters) UnityEditor.HostView.Invoke (System.String
methodName, System.Object obj) (at
C:/BuildAgent/work/842f9557127e852/Editor/Mono/GUI/DockArea.cs:225)
UnityEditor.HostView.Invoke (System.String methodName) (at
C:/BuildAgent/work/842f9557127e852/Editor/Mono/GUI/DockArea.cs:218)
UnityEditor.HostView.OnGUI () (at
C:/BuildAgent/work/842f9557127e852/Editor/Mono/GUI/DockArea.cs:119)
and I dont know how to fix it.
In Unity 4.2.0 it doesn't give me any errors, but in 3.4.2 even if the project contains just the main camera and a cube it gives me these errors and the .apk file is not built. How can I resolve this?
Try to search the Android SDK directory for the file aapt.exe. In the later versions, it was moved to android-sdk/build-tools/18.0.0/. Look there and, if you find it, copy it from there to your android-sdk/platforms/android-18 folder.
I had an error very similar to this. What solved it for me was installing the Android SDK Build Tools using the Android SDK Manager.
There are some new Tools introduced in Android sdk -18 so the old unity version will not work
with new android tools as most of them are changed.

Monodroid will not deploy when using an ImageView

I have this in my Main.axml;
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
>
<Button
android:id="#+id/MyButton"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="#string/Hello"/>
<ImageView
android:src="#drawable/samplebackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/MyButton"/>
</RelativeLayout>
It builds fine and sampleBackground is a jpg that has been included in my project.
However when I try to deploy I get an error;
Object reference not set to an instance of an object
And there are a bunch of lines stating <filename unknown>
If I remove the ImageView from the markup the application deploys fine.
Any thoughts?
full stack
------ Build started: Project: MonoAndroidApplication1, Configuration: Debug Any CPU ------
MonoAndroidApplication1 -> C:\Development\MonoAndroidApplication1\MonoAndroidApplication1\bin\Debug\MonoAndroidApplication1.dll
Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.225]
Copyright (C) Microsoft Corporation 2007. All rights reserved.
Build started 8/06/2011 8:37:40 AM.
Project "C:\Development\MonoAndroidApplication1\MonoAndroidApplication1\MonoAndroidApplication1.csproj" on node 1 (SignAndroidPackage target(s)).
_GenerateAndroidAssetsDir:
Skipping target "_GenerateAndroidAssetsDir" because it has no outputs.
_ResolveMonoAndroidSdks:
Looking for Android SDK..
Key HKCU\SOFTWARE\Android SDK Tools\Path not found.
Key HKLM\SOFTWARE\Android SDK Tools\Path found:
Path contains adb.exe in \platform-tools (C:\Program Files\Android\android-sdk).
Looking for Java SDK..
Key HKLM\SOFTWARE\JavaSoft\Java Development Kit\CurrentVersion found: 1.6.
Key HKLM\SOFTWARE\JavaSoft\Java Development Kit\1.6\JavaHome found:
Path contains jarsigner.exe in \bin (C:\Program Files\Java\jdk1.6.0_25).
MonoAndroid Tools: C:\Program Files\MSBuild\Novell\
MonoAndroid Framework: C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.2\;C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\
Android SDK: C:\Program Files\Android\android-sdk\
Java SDK: C:\Program Files\Java\jdk1.6.0_25\
_ValidateAndroidPackageProperties:
GetAndroidPackageName Task
ManifestFile:
AssemblyName: MonoAndroidApplication1
PackageName: MonoAndroidApplication1.MonoAndroidApplication1
_UpdateAndroidResgen:
Skipping target "_UpdateAndroidResgen" because all output files are up-to-date with respect to the input files.
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
_CopyOutOfDateSourceItemsToOutputDirectoryAlways:
Copying file from "C:\Development\MonoAndroidApplication1\MonoAndroidApplication1\Resources\Drawable-land\Icon.png" to "bin\Debug\Resources\Drawable-land\Icon.png".
CopyFilesToOutputDirectory:
MonoAndroidApplication1 -> C:\Development\MonoAndroidApplication1\MonoAndroidApplication1\bin\Debug\MonoAndroidApplication1.dll
ContractDeclarativeAssemblyCS:
Skipping target "ContractDeclarativeAssemblyCS" because all output files are up-to-date with respect to the input files.
_ConvertDebuggingFiles:
Skipping target "_ConvertDebuggingFiles" because all output files are up-to-date with respect to the input files.
_CompileAndroidPackage:
Mandroid Task
Assemblies: C:\Development\MonoAndroidApplication1\MonoAndroidApplication1\bin\Debug\MonoAndroidApplication1.dll; C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.2\Mono.Android.dll; C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll; C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Core.dll; C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.dll; C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.dll; C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.Linq.dll
I18nAssemblies:
BuildDirectory: C:\Development\MonoAndroidApplication1\MonoAndroidApplication1\obj\Debug\
ReferenceAssembliesDirectory: C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.2\;C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\;;
AndroidSdkDirectory: C:\Program Files\Android\android-sdk\
JavaSdkDirectory: C:\Program Files\Java\jdk1.6.0_25\
AssetDirectory: C:\Development\MonoAndroidApplication1\MonoAndroidApplication1\obj\Debug\assets\
AndroidSdkPlatform: 8
MonoAndroidToolsDirectory: C:\Program Files\MSBuild\Novell\
ResourceDirectory: C:\Development\MonoAndroidApplication1\MonoAndroidApplication1\obj\Debug\res\
ManifestTemplate:
Package: MonoAndroidApplication1.MonoAndroidApplication1
NativeLibrary:
JavaSource:
Debug: True
UseSharedRuntime: True
SupportedAbis: armeabi
LinkMode: None
ExtraArgs:
C:\Program Files\MSBuild\Novell\mandroid.exe -v --nosign --sdk-dir="C:\Program Files\Android\android-sdk" --builddir="C:\Development\MonoAndroidApplication1\MonoAndroidApplication1\obj\Debug\android" --framework-dir="C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.2" --framework-dir="C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0" -S="C:\Development\MonoAndroidApplication1\MonoAndroidApplication1\obj\Debug\res" --package="MonoAndroidApplication1.MonoAndroidApplication1" --nolink --abi="armeabi" --java-sdk-dir="C:\Program Files\Java\jdk1.6.0_25" --debug --sdk-platform="8" -A="C:\Development\MonoAndroidApplication1\MonoAndroidApplication1\obj\Debug\assets" "C:\Development\MonoAndroidApplication1\MonoAndroidApplication1\bin\Debug\MonoAndroidApplication1.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.2\Mono.Android.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Core.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.Linq.dll"
monodroid : error 1: System.NullReferenceException: Object reference not set to an instance of an object [C:\Development\MonoAndroidApplication1\MonoAndroidApplication1\MonoAndroidApplication1.csproj]
at MonoDroid.Utils.ProcessRocks+c__Iterator5.MoveNext () [0x00000] in :0
at Monodroid.Toolbox.InvokeCommand (IEnumerable1 commandLine) [0x00000] in <filename unknown>:0
at Monodroid.Toolbox.InvokeAapt (System.String packageName) [0x00000] in <filename unknown>:0
at Monodroid.Droidinator.CreatePackagedResources (System.Collections.Generic.List1 javaTypes) [0x00000] in :0
at Monodroid.Droidinator.CreateApk () [0x00000] in :0
at Monodroid.MainClass.Main (System.String[] argv) [0x00000] in :0
Done Building Project "C:\Development\MonoAndroidApplication1\MonoAndroidApplication1\MonoAndroidApplication1.csproj" (SignAndroidPackage target(s)) -- FAILED.
Build FAILED.
"C:\Development\MonoAndroidApplication1\MonoAndroidApplication1\MonoAndroidApplication1.csproj" (SignAndroidPackage target) (1) ->
(_CompileAndroidPackage target) ->
monodroid : error 1: System.NullReferenceException: Object reference not set to an instance of an object [C:\Development\MonoAndroidApplication1\MonoAndroidApplication1\MonoAndroidApplication1.csproj]
EDIT:
I found the solution; just make sure the image filename is in lowercase.
My image was named Image.png by renaming it to image.png it worked.
It's easy enough to reproduce - just create a new solution with a layout with a ImageView. Set the android:src="#drawable/Image".
If I type the Image with lowercase, image, it gives a compiler error, but when i correct it to Image no compile time errors, but the packaging fails...
The Image is in the correct folder and set to AnddroidResource.
So I would indeed like some help on this one too.
Thanks, Nicklas
Make sure that the Build Action for that image file is set to AndroidResource. You can set the Build Action by right clicking on the file in Visual Studio and selecting Properties.

Categories

Resources