Open daniel-keen opened 2 years ago
I was able to fix this myself (I am mostly a Unity developer and not familiar with Android Studio but here is how I did it:)
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
ndkVersion = "21.3.6528147"
}
In this, you want to change minSdkVersion = 21 to minSdkVersion = 22
Then Ctrl + S to save the file and click sync on the blue gradle popup which should be above the open file tabs
However, this has now led me to this error which I am looking into Manifest merger failed : Apps targeting Android 12 and higher are required to specify an explicit value for
android:exportedwhen the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
@ROBYER1 Yep.. aand this is where I stuck too Moreover, I managed to add "android:exported" in every missing place I could find, (that is unity library manifest). Unfortunately I then get the same error but for some mysterious "service" thing. Although I cannot find any "service" keyword in my android project...
@ROBYER1 Yep.. aand this is where I stuck too :D Moreover, I managed to add "android:exported" in every missing place I could find, (that is unity library manifest). Unfortunately I then get the same error but for some mysterious "service" thing. Although I cannot find any "service" keyword in my android project...
Where did you add android:exported?
Also what is the error about service?
Okay so to get past that android:exported error I had to go to:
example\unity\builds\android\unityLibrary\src\main\AndroidManifest.xml
Line 4 looked like this : <activity android:name="com.unity3d.player.UnityPlayerActivity" android:theme="@style/UnityThemeSelector" android:screenOrientation="fullUser" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:resizeableActivity="false" android:hardwareAccelerated="false">
I simply added android:exported="true"
to the end so it looked like:
<activity android:name="com.unity3d.player.UnityPlayerActivity" android:theme="@style/UnityThemeSelector" android:screenOrientation="fullUser" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:resizeableActivity="false" android:hardwareAccelerated="false" android:exported="true">
I can then get it running using the Emulator Pixel 5 in Android studio using this step: https://stackoverflow.com/a/55442281
You haven't started the bundler yet. Run npm start or react-native start in the root directory of your project before react-native run-android.
Then in the Emulator, I get this lovely error when I click the load Unity button:
your hardware does not support this application - failed to load libmain.so
However on my actual android device - Sony Xperia 1 phone, I get this error: Unable to load script.Make sure you are either running a Metro server or that your bundle 'index.android.bundle' is packaged correctly for release.
Which I am looking into, it's probably my lack of experience with React that is letting me down here tbh but the setup and install Readme on this repo covers none of this unfortunately.
Okay so I haven't fixed the emulator running issue but I don't need that anyway - I got it running on device, I had to do the following:
In Unity Project Settings > Player, set il2cpp instead of mono and ticked ARMv7 and ARM64
In Android Studio I had il2cpp errors about NDK so I installed the matching NDK that Unity used in Android Studio SDK manager
On build and run, the app would still have the error about the Metro server not running, I ran this command to get past that:
adb reverse tcp:8081 tcp:8081
from: https://stackoverflow.com/a/46250725
In my project I use minSdkVersion = 26 and everything works fine, I can’t understand what is the problem with building a Unity project with this flag and running it in RN?
In my project I use minSdkVersion = 26 and everything works fine, I can’t understand what is the problem with building a Unity project with this flag and running it in RN?
I would close this issue if I was the owner, if anyone follows my steps above they will get past any unusual errors in the Example app. However the real issue now is that the app runs and if I try to open the Unity window a second time it always crashes - I filed a bug here please see https://github.com/azesmway/react-native-unity/issues/34
Hi @ROBYER1,
I have the same problem (i have a lot of problem): Manifest merger failed : Apps targeting Android 12 and higher are required to specify an explicit value for android:exported
I followed your tread and i put android:exported
in unity export manifest but nothing.... i have the same errror....
any suggestion? need change the min version sdk in unity player config?
your build work?
Thanks
ok now build! i changed ->
ext { buildToolsVersion = "31.0.0" minSdkVersion = 22 compileSdkVersion = 31 targetSdkVersion = 31 ndkVersion = "21.3.6528147" }
with ->
ext { buildToolsVersion = "30.0.0" minSdkVersion = 22 compileSdkVersion = 30 targetSdkVersion = 30 ndkVersion = "21.3.6528147" }
Great! This can probably be closed now?
Yes I think.... you have any suggestion for this problem? https://github.com/azesmway/react-native-unity/issues/39#issuecomment-1225519321
Thanks
I am trying to make example project work. And unfortunately I can't.
I see the example project was built using Unity 2019.1.19f1 which uses 'API level 21' as Minimum API level. I have spent some time on trying to set up the environment in the same way, and it just doesn't work. Seems like API Level 21 has been deprecated.
My question is, is there any chance the library will be able to use API level 22 as its minimum sdk version?