mapbox-unity-sdk icon indicating copy to clipboard operation
mapbox-unity-sdk copied to clipboard

Native plugin errors while building on Unity Cloud Build.

Open mihakrajnc opened this issue 9 years ago • 28 comments

I'm using UCB as my CI and both my Android and iOS builds are failing.

iOS build is failing with the error:

[xcode] /BUILD_PATH/***********/temp.******/Libraries/Addons/Mapbox/Core/Plugins/iOS/MapboxMetricsClient.m:1:9: fatal error: 'MapboxMobileEvents/MapboxMobileEvents.h' file not found
6615:        [xcode] #import <MapboxMobileEvents/MapboxMobileEvents.h>
6616:        [xcode] 1 error generated.

I'm not an iOS developer, but looking at the MapboxMetricsClient.m file, i assume the import should be #import <MapboxMobileEvents/include/MapboxMobileEvents/MapboxMobileEvents.h> and not #import <MapboxMobileEvents/MapboxMobileEvents.h> ?

Android build is failing with this error:

Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool : Unsupported major.minor version 52.0

I didn't analyse the native .aar libraries that are used by Mapbox, but I'd say one of them is using Java 8 which UCB does not support. Not sure if this is a problem that UCB should fix, or Mapbox.

mihakrajnc avatar May 30 '17 00:05 mihakrajnc

thanks for flagging this @mihakrajnc - we will take a look on our end first. Any clues from your logs which .aar it's coming from?

@boundsj @zugaldia - do you have ideas from the iOS / android errors?

@david-rhodes - can you recreate these errors by setting up cloud build for the slippy demo?

isiyu avatar May 31 '17 02:05 isiyu

I didn't analyse the native .aar libraries that are used by Mapbox, but I'd say one of them is using Java 8 which UCB does not support.

The Android library we're using explicitly sets the Java target to version 7. Could you see if adding the same lines to the Android app project helps with the issue?

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

zugaldia avatar May 31 '17 14:05 zugaldia

@isiyu None, sorry, I checked the logs and all relevant information I get is this:

6040: [Unity] /APPLICATION_PATH/Android Studio.app/sdk/build-tools/25.0.3/apksigner sign --ks "/BUILD_PATH/inova-it.mapboxdemo.default-android/bvr/******.keystore" --ks-pass pass:"*****" --ks-key-alias "androiddebugkey" --key-pass pass:"*****" "/BUILD_PATH/******/Temp/StagingArea/Package.apk"
6041: [Unity] stderr[
6042: [Unity] Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool : Unsupported major.minor version 52.0
6043: [Unity] 	at java.lang.ClassLoader.defineClass1(Native Method)
6044: [Unity] 	at java.security.AccessController.doPrivileged(Native Method)
6045: [Unity] ]
6046: [Unity] stdout[
6047: [Unity] ]
6048: [Unity] exit code: 1
6049: [Unity]   at UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) [0x00000] in <filename unknown>:0 
6050: [Unity]   at UnityEditor.Android.PostProcessor.Tasks.TasksCommon.Exec (System.String command, System.String args, System.String workingdir, System.String errorMsg, Int32 retriesOnFailure) [0x00000] in <filename unknown>:0 
6051: [Unity] UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, Boolean)
6052: [Unity] UnityEditor.CloudBuild.Builder:Build()
6053: [Unity] (Filename:  Line: -1)

@zugaldia The Android build works fine when building locally (using the internal Unity compiler - the same as on Cloud Build), and I don't think I can add gradle options to it when building on Cloud Build.

I also just tried to build for iOS locally, and It fails with the same error as above. I fixed it by changing the line to:

#import "MapboxMobileEvents/include/MapboxMobileEvents/MapboxMobileEvents.h"

After that it fails again, inside of MapboxMobileEvents.h with:

MapboxMobileEvents.h:11:9: 'MapboxMobileEvents/MMEConstants.h' file not found

Changing all of the imports in MapboxMobileEvents.h to this finally fixes the build:

#import "MMEConstants.h"
#import "MMEEvent.h"
#import "MMEEventsManager.h"

mihakrajnc avatar May 31 '17 15:05 mihakrajnc

I'm not an iOS developer, but looking at the MapboxMetricsClient.m file, i assume the import should be #import <MapboxMobileEvents/include/MapboxMobileEvents/MapboxMobileEvents.h> and not #import <MapboxMobileEvents/MapboxMobileEvents.h> ?

Actually the fact that using the full path works indicates that the header search paths are not set up correctly for the project. It sounds like this may be specific to UCB and I'm not sure what the correct fix would for that environment.

boundsj avatar May 31 '17 15:05 boundsj

@boundsj Current header search paths are defined with:

proj.AddBuildProperty(target, "HEADER_SEARCH_PATHS", "$(SRCROOT)/Libraries/Mapbox/Core/Plugins/iOS/MapboxMobileEvents/include");

But, the files are nested under .../iOS/MapboxMobileEvents/include/MapboxMobileEvents. Do we need to change the path or make it recursive?

david-rhodes avatar May 31 '17 16:05 david-rhodes

@david-rhodes ~/MapboxMobileEvents/include/ holds all the header files in a MapboxMobileEvents directory so I don't think you need to make it recursive. That's why <MapboxMobileEvents/MapboxMobileEvents.h> works*

*It did work when you tested locally last week, right? 😄

It seems like this issue may be specific to building in the UCB environment? I've never used that environment and I'm not sure how to get it set up.

Can you try to repro the issue @mihakrajnc noted above with UCB?

boundsj avatar May 31 '17 16:05 boundsj

@mihakrajnc Can you check a few things for me, please?

  1. Ensure that you have Mapbox_iOS_build.cs in Unity/Editor/Build folder
  2. Make sure your xcode project has this last search path (from local build) screen shot 2017-05-31 at 11 08 43 am

Edit: also, do you have your own [PostProcessBuild] scripts? These may be conflicting?

david-rhodes avatar May 31 '17 17:05 david-rhodes

@david-rhodes

  1. The Mapbox_iOS_build.cs file is in the project and in the correct folder.
  2. The xcode project has the custom string in the search path: $(SRCROOT)/Libraries/Mapbox/Core/Plugins/iOS/MapboxMobileEvents/include
  3. No other [PostProcessBuild] scripts in the project.

Edit: Even with the temporary fixes, the UCB build still fails (although the local build is fine) with:

7085:        [xcode] ld: warning: arm64 function not 4-byte aligned: ltmp0 from /BUILD_PATH/****.default-ios/temp.FUXwgr/Libraries/libiPhone-lib.a(unwind_test_arm64.o)
7086:        [xcode] ld: warning: arm64 function not 4-byte aligned: _unwind_tester from /BUILD_PATH/****.default-ios/temp.FUXwgr/Libraries/libiPhone-lib.a(unwind_test_arm64.o)
7087:        [xcode] ld: warning: object file (/BUILD_PATH/****.default-ios/temp.FUXwgr/Libraries/Addons/Mapbox/Core/Plugins/iOS/MapboxMobileEvents/libMapboxMobileEventsStatic.a(MMEUIApplicationWrapper.o)) was built for newer iOS version (10.3) than being linked (7.0)
7088:        [xcode] ld: bitcode bundle could not be generated because '/BUILD_PATH/****.default-ios/temp.FUXwgr/Libraries/Addons/Mapbox/Core/Plugins/iOS/MapboxMobileEvents/libMapboxMobileEventsStatic.a(MMEUIApplicationWrapper.o)' was built without full bitcode. All object files and libraries for bitcode must be generated from Xcode Archive or Install build for architecture arm64
7089:        [xcode] clang: error: linker command failed with exit code 1 (use -v to see invocation)
7090:        [xcode] ** ARCHIVE FAILED **
7091:        [xcode] The following build commands failed:
7092:        [xcode] 	Ld /BUILD_PATH/Library/Developer/Xcode/DerivedData/Unity-iPhone-fucjqbniqvlhkbadxjpeepnrtwtw/Build/Intermediates/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/Objects-normal/arm64/mapboxdemo normal arm64
7093:        [xcode] (1 failure)
7094: ! build of 'default-ios' failed. compile failed

mihakrajnc avatar Jun 01 '17 14:06 mihakrajnc

@mihakrajnc I just did a successful Android cloud build with v1.0 of the SDK in a vanilla project. I didn't get any errors on android and the apk works as expected.

Do you have other native plugins you're using? There may be a conflict between them.

david-rhodes avatar Jun 02 '17 21:06 david-rhodes

@david-rhodes We're also running into issues with regards to some bitcoding of the mapbox libraries for iOS.

As far as we can see, this is the error that makes our Unity Cloud Build unpassable: bitcode bundle could not be generated because '/BUILD_PATH/project.project-app.weekly-builds-ios/temp.JbtXot/Libraries/Mapbox/Core/Plugins/iOS/MapboxMobileEvents/libMapboxMobileEventsStatic.a(MMEUIApplicationWrapper.o)' was built without full bitcode. All object files and libraries for bitcode must be generated from Xcode Archive or Install build for architecture arm64

We tried to circumvent this by adding a post-build file to Unity Cloud build that disabled bitencoding, and then we got another error about needing X-code 7.3 instead of 8 and then we could build. But with bitencoding disabled we get a "BadAccess Error" in Unity3D.WebOperationQueue.. This caused the app to crash...

Not sure if I should tag along in this issue, but seeing as it's related to Unity Cloud build and native code, i'll put it here. If it needs it's own issue, I can create one.

Alexphauge avatar Jun 06 '17 09:06 Alexphauge

@Alexphauge Thanks for the report! We just discovered this as well and a fix is in the works! You can safely exclude these native libraries for testing purposes, however.

david-rhodes avatar Jun 06 '17 15:06 david-rhodes

@david-rhodes We hit another issue. The previous one is still open for me (but I just replaced all of the imports with paths for now).

The new problem was with signing. When trying to sign my app (in this case for enterprise distribution), I couldn't, because of the "resources.bundle" inside of MapboxMobileEvents folder.

It gets added to the iOS build (under Build Phases -> Copy Bundle Resources), and then wants to be signed alongside the app:

screen shot 2017-06-20 at 17 55 25

Removing it from Copy Bundle Resources works and the app can be normally signed. When I do this the maps work and I don't see any problems with the build.

EDIT: As a fix for this I selected the folder in Unity ->Unchecked iOS -> Apply. After that it won't get added to the build.

mihakrajnc avatar Jun 20 '17 16:06 mihakrajnc

@mihakrajnc Thanks for the report! We're looking into fixes for all these plugin/build/signing issues.

david-rhodes avatar Jun 20 '17 17:06 david-rhodes

We have been unable to elegantly auto resolve Android library conflicts, but we did add a preprocess build step that warns of duplicate libraries (https://github.com/mapbox/mapbox-unity-sdk/pull/191). Additionally, if you there is a UnitTest as well. If you enable UnitTests in cloud build, you should be warned of build failures accordingly.

Because we've update iOS libraries and we now have this android check, I'm closing this ticket. Let's open a new ticket for any issues that remain.

david-rhodes avatar Aug 01 '17 22:08 david-rhodes

Still having the same issue mentioned

navidre avatar Aug 30 '17 15:08 navidre

@navidre Which issue, specifically (there are many issues in this thread)? What version of the SDK are you using?

david-rhodes avatar Aug 30 '17 15:08 david-rhodes

Original MapboxMobileEvents/MapboxMobileEvents.h not found error. I deleted everything and re-imported Mapbox and it is working now. Thank you!

navidre avatar Aug 30 '17 15:08 navidre

I getting errors when I try to use vuforia and mapbox. I dont know I tried rebuild and it seemed to just work the second time.

aiursrage2k avatar Oct 13 '17 19:10 aiursrage2k

@aiursrage2k I'm afraid we need more information. Is this related to cloud build?

david-rhodes avatar Oct 16 '17 15:10 david-rhodes

I'm not an iOS developer, but looking at the MapboxMetricsClient.m file, i assume the import should be #import <MapboxMobileEvents/include/MapboxMobileEvents/MapboxMobileEvents.h> and not #import <MapboxMobileEvents/MapboxMobileEvents.h>

I discovered that this error occured for me because I had the Symlink Unity Libraries checkbox turned on while building for iOS. Please make sure this is unchecked before building 33154796-e62110da-cf9f-11e7-8010-c7e488e81b6b

apavani avatar Nov 27 '17 19:11 apavani