Reputation: 3987
Both the current official Google Cardboard app and the older versions of the Google Cardboard drivers for Unity work for Android 4.1 and above.
However the current version of Google Cardboard for Unity library is set for Android 4.4 and above. I have tried to change the settings from 4.4 to 4.1 searching all the strings like: <uses-sdk android:minSdkVersion="19"
to change it to <uses-sdk android:minSdkVersion="16"
.
The player settings has been change to 16 too.
Unfortunately I get the following error when compiling:
Error: [Temp/StagingArea/AndroidManifest-main.xml:14, /Users/ch/workspaces/unity_workspace/educainventions/Temp/StagingArea/android-libraries/unitygvractivity/AndroidManifest.xml:2]
Main manifest has <uses-sdk android:minSdkVersion='16'> but library uses minSdkVersion='19'
And that's right: /Temp/StagingArea/android-libraries/unitygvractivity/AndroidManifest.xml is set to minSdkVersion='19'
I have changed that file to 16 too, but when compiling it changes to 19, and the same error occurs.
What creates that file to change it from 19 to 16? I think a solution could be to generate the Android code, then compile it with Android Studio. However doing it every time would be very slow so a continuos waste of time...
Upvotes: 1
Views: 561
Reputation: 3987
The generated file with 19
instead 16
is created at: Temp/StagingArea/android-libraries/unitygvractivity/AndroidManifest.xml
. I have realised that we can find a file with the same name of that folder, unitygvractivity.aar
, within Assets/Plugins/Android/
. Searching on Google I have found that we can decompress that file. I decompress it with The Unarchiver in OSX. According to this answer, we could also execute:
unzip unitygvractivity.aar -d unitygvractivity
Once unziped, we can find AndroidManifest.xml
within the extracted folder unitygvractivity
. We change 19
by 16
in that file, and we compress it back to the aar format. According to the same answer we can execute:
jar cvf unitygvractivity.aar -C unitygvractivity/ .
Finally we change the original unitygvractivity.aar
file by the new one we just created. It will compile.
So the next question is: if it has worked in Android 4.1, why Google set it for 4.4 and above? Maybe a part of the library I did not use need 4.4?
UPDATE: Answer of Google (https://github.com/googlevr/gvr-unity-sdk/issues/439):
We uses some level-19 APIs in our sdk so it is not guaranteed to work with pre-19 target. You should set 19 as your minimal target for cardboard
Upvotes: 1
Reputation: 11
Every time you build Android game it generates new manifest.Try to copy it to Assets/Plugins/Android. After you copy it, unity uses this manifest instead of generating new... Worked in my case. BTW.If you use library which min sdk is 19,setting up unity to 16 won't help.
Upvotes: 0