Upgrading project from Plugins/Res to AAR?

I recently got assigned a task to upgrade an old android project (last made on 2018) to latest LTS release (2021.3). Reason was that we were using an obsolete IAP library due to which Playstore had unpublished our app or something. So now im trying to recompile that 2018 project in 2021.3 and after sorting out compilation issues and package conflicts when I press build I get this error: “OBSOLETE - Providing Android resources in Assets/Plugins/Android/res was removed, please move your resources to an AAR or an Android Library.”.

I get that solution is probably to build an AAR of the files inside RES. My question is, is there a way to automate this or do I have to do it manually? Also, will I have to update the references in code too? or are AAR files addressed the same way as files in Plugin/Res? because lot of those references come from 3rd party plugin/script codes, not the apps “own” code and it would be pretty painful if I have to edit all that line by line.

Any help on this would be appreciated.

Did you consider using ‘Android Library’ plugin folder, it’s much easier than managing AAR?

Check this and [this]( https://discussions.unity.com/t/574852 page-2#post-7850511).

However, I would still recommend to go with aar as its more easier to manage with little effort at start.

I tried the androidlib solution you mentioned. Its not working out. The app does compile now, but when I try to launch it, it crashes. Before I go into what my logcat shows, let me first start by mentioning what’s contained in the res file. Its a few drawables for (different resolutions I am assuming). A folder called layout. And then lots of folders called “values-en”, “values-es”, “values-fr”, etc which im assuming are language packs.

A quick search for “exception” in logcat takes me to this:

W System.err: java.io.FileNotFoundException: https://play.google.com/store/apps/details?id=com.thelearningapps.balloonpopunity&hl=en" so my guess that the system is trying to find the language pack but is unable to do so since res folder is removed? I could be wrong of course. Maybe im just messing up the androidlib part somehow. Im very new to this.

Also important to note here that first mention of “crash” in logcat actually happens a few lines earlier but it does not provide any detail there. This exception is first thing that is making sense to me.

Here are some of the lines leading up to the FileNotFound exception, if you think thats not the issue maybe something else it.

06-07 17:30:51.264  1351  1559 D GameManagerService: identifyGamePackage. com.thelearningapps.balloonpopunity, mCurrentUserId: 0, callerUserId: 0                        

06-07 17:30:51.264  1351  1559 D PkgDataHelper: getGamePkgData(). com.thelearningapps.balloonpopunity                                                                    

06-07 17:30:51.271  1351  1557 D SehCodecSolutionService: Update top [com.thelearningapps.balloonpopunity]                                                               

06-07 17:30:51.402  1351  2248 D MdnieScenarioControlService:  packageName : com.thelearningapps.balloonpopunity    className : com.unity3d.player.UnityPlayerActivity   

06-07 17:30:51.483 30986 30986 D LoadedApk: LoadedApk::makeApplication() appContext=android.app.ContextImpl@15e14fd appContext.mOpPackageName=com.thelearningapps.balloonpopunity appContext.mBasePackageName=com.thelearningapps.balloonpopunity appContext.mPackageInfo=android.app.LoadedApk@82235f2                                           

06-07 17:30:51.548 30986 30986 E AndroidRuntime: Process: com.thelearningapps.balloonpopunity, PID: 30986                                                                

06-07 17:30:51.553  1351  1428 W ActivityManager: crash : com.thelearningapps.balloonpopunity,10379                                                                      

06-07 17:30:51.553  1351  1428 W ActivityTaskManager:   Force finishing activity com.thelearningapps.balloonpopunity/com.unity3d.player.UnityPlayerActivity              

06-07 17:30:51.593  1351  4402 I ActivityManager: Process com.thelearningapps.balloonpopunity (pid 30986) has died: fg  TPSL(224,3256)                                   

06-07 17:30:51.596  1351  4402 I ActivityTaskManager: Removing activity ActivityRecord{d19e4dc u0 com.thelearningapps.balloonpopunity/com.unity3d.player.UnityPlayerActivity t12939 f}}(appDied)  from stack callers=com.android.server.wm.ActivityStack$RemoveHistoryRecordsForApp.processActivity:565 com.android.server.wm.ActivityStack$RemoveHistoryRecordsForApp.process:480 com.android.server.wm.ActivityStack.handleAppDied:3379 com.android.server.wm.RootWindowContainer.handleAppDied:3654 com.android.server.wm.ActivityTaskManagerService$LocalService.handleAppDied:8304                                                                                                             

06-07 17:30:51.600   975  1507 I Layer   : id=55100 removeFromCurrentState ActivityRecord{d19e4dc u0 com.thelearningapps.balloonpopunity/com.unity3d.player.UnityPlayerActivity t12939}#0 (94)                                                                                                                                                    

06-07 17:30:51.602   975  1508 I SurfaceFlinger: id=55100 Removed ActivityRecord{d19e4dc u0 com.thelearningapps.balloonpopunity/com.unity3d.player.UnityPlayerActivity t12939}#0 (94)                                                                                                                                                             

06-07 17:30:51.611   975   975 I Layer   : id=55100[1] Destroyed ActivityRecord{d19e4dc u0 com.thelearningapps.balloonpopunity/com.unity3d.player.UnityPlayerActivity t12939}#0                                                                                                                                                                   

06-07 17:30:51.617  4225  4225 I SDHMS:PowerAnomaly:GATHERERAPPERROR: update AppError : uid=10379, pkg=com.thelearningapps.balloonpopunity, errorType=crash              

06-07 17:30:51.629  4225  4225 I SDHMS:PowerAnomaly:ANALYZERAPPERROR: analyze app error : uid=10379, pkg=com.thelearningapps.balloonpopunity, appErrorCount=1            

06-07 17:30:51.747  1351  1559 W ActivityTaskManager: Activity top resumed state loss timeout for ActivityRecord{d19e4dc u0 com.thelearningapps.balloonpopunity/com.unity3d.player.UnityPlayerActivity t-1 f}}                                                                                                                                    

06-07 17:30:51.761  1351  2091 W SemWifiTransportLayerUtils: getApplicationCategory - IOException com.thelearningapps.balloonpopunity                                    

06-07 17:30:51.761  1351  2091 W System.err: java.io.FileNotFoundException: https://play.google.com/store/apps/details?id=com.thelearningapps.balloonpopunity&hl=en

Without having repro project it’s hard to say, but if you really really need for those resources be in unityLibrary/src/main/res, you can use Unity - Scripting API: IPostGenerateGradleAndroidProject and then perform File.Copy manually from the location of your choosing.

Alternatively, please submit a bug - Unity QA: Building quality with passion. You may have a use case which we didn’t know about.

Doesn’t sound like error is related to res folder. The url actually returns an error so most likely in your code you are fetching it internally. Only reason I assume is at launch you try to fetch the page and check if there is an updated version to prompt the user. However, i’m not aware what exactly is being done in your code.

hey guys. Any updates on this?
Especially if I want to use the network_security_config.xml file, where to put it?

You can place it anywhere you want, and then use https://docs.unity3d.com/ScriptReference/Android.IPostGenerateGradleAndroidProject.html to copy it wherever you need, by using File.Copy, which in your case, is probably /res/xml directory.

Hey, thanks for your answer.
But in the case of Unity 2021.2 and higher, I can’t use the /res folder .

You don’t need to use res folder, if you use https://docs.unity3d.com/ScriptReference/Android.IPostGenerateGradleAndroidProject.html you can have source file anywhere you want.

Hey.
I already resolved my problem, I’ve moved the “android:networkSecurityConfig=” @ /network_security_config"" attribute to the aar’s manifest, and now it works.

1 Like

@gagasik
Im having the same problem with the exact same file. Would you be able to give some info on how you created an AAR for the network_security_config.xml file. Where did you put it in the filesystem?

If you mean the AAR, then I put it under the /Assets/Plugins/Android