I recently switched to Unity 2021.2.3f1 and when I try to build I get this error.
“Exception: OBSOLETE - Providing Android resources in Assets/Plugins/Android/assets was removed, please move your resources to an AAR or an Android Library. See “AAR plug-ins and Android Libraries” section of the Manual for more details.”
I looked it up and came across this
That briefly explains what AAR are and That I need to create one to import in my project.
Then there is a link to the android studio page on how to create an android Library.
Can I just open android studio and create an android library from a new android studio project and import it into my unity project?
I would prefer to create a library from my unity project directly, how can I do that?
If I try to export the project(to open it in Android studio) I still get the same error.
Actually, if your concern is only about files within assets folder and nothing else (considering you don’t have any other code referencing its resouce id’s), you can simply copy the contents of assets folder to Streaming Assets.
Why? → Because, the contents of Streaming assets are copied to assets folder finally once the final executable is built.
Else(Most likely), Can you try this once and let me know if it works?
Steps to create a quick android project
Create a new folder named yourModuleName.androidlib in Assets/Plugins/Android
Create AndroidManifest.xml in the above folder and update with your contents
Create project.properties file with below contents and save it.
target=android-31
android.library=true
Copy your assets folder to yourModuleName.androidlib
Now Unity auto merges the your file and you are free from unity updates which is more flexible!
Added a sample androidlib folder for your reference.
If I put AndroidManifest inot the androidlib folder I get and error in build.
I deleted the asset folder in Android folder and now it seem to build correctly but I get an error when I test the app if I try to connect to PlayGames and other GoogleServices
I get this error when the app is started
Logcat Error
2022/06/18 12:09:54.475 16078 19556 Error Unity AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.games.Games
2022/06/18 12:09:54.475 16078 19556 Error Unity java.lang.ClassNotFoundException: com.google.android.gms.games.Games
2022/06/18 12:09:54.475 16078 19556 Error Unity at java.lang.Class.classForName(Native Method)
2022/06/18 12:09:54.475 16078 19556 Error Unity at java.lang.Class.forName(Class.java:454)
2022/06/18 12:09:54.475 16078 19556 Error Unity at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
2022/06/18 12:09:54.475 16078 19556 Error Unity at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
2022/06/18 12:09:54.475 16078 19556 Error Unity at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
2022/06/18 12:09:54.475 16078 19556 Error Unity at android.os.Handler.dispatchMessage(Handler.java:102)
2022/06/18 12:09:54.475 16078 19556 Error Unity at android.os.Looper.loop(Looper.java:246)
2022/06/18 12:09:54.475 16078 19556 Error Unity at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
2022/06/18 12:09:54.475 16078 19556 Error Unity Caused by: java.lang.ClassNotFoundException: com.google.android.gms.games.Games
2022/06/18 12:09:54.475 16078 19556 Error Unity ... 8 more
2022/06/18 12:09:54.475 16078 19556 Error Unity at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0
2022/06/18 12:09:54.475 16078 19556 Error Unity at UnityEngine.AndroidJNISafe.FindClass (System.String name) [0x00000] in <00000000000000000000000000000000>:0
2022/06/18 12:09:54.475 16078 19556 Error Unity at UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className) [0x00000] in <000000000000
Can you tell me what I need to put into the androidlib folder to make GoogleServices works?
The error stated is because of not having the dependency library. I would suggest to pass me a sample project to help you out. That ways its easy for me to pin point the issue.
Then why wouldn’t the error suggest this and instead suggest something so complicated using third-party tools? If only Unity ate their own dogfood… who approves this stuff?