I'm trying to create an Android plugin for my Unity game. I have watched a lot of tutorials (most of them are outdated based on eclipse) and have read the documentation also. I'm using Unity 2019.3.0f6. I want to extend my main activity in Android Studio project with UnityPlayerActivity

I don't understand what does the ending lines mean "Locate the file, and add classes.jar to the classpath Unity uses to compile the new Activity. Compile your Activity source file and package it into a JAR or AAR package, then copy it into your Project folder"
I understand UnityPlayerActivity does not exist in the classes.jar at PlaybackEngines/AndroidPlayer/Variations/mono or il2cpp/Development or Release/Classes/ and so I can't import com.unity3d.player.UnityPlayerActivity; I can only import UnityPlayer and IUnityPlayerLifecycleEvents. I am also interested to understand what is the UnityPlayer class and IUnityPlayerLifecycleEvents in this context.

But the UnityPlayerActivity.java is available at C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\src\com\unity3d\player
How do I add it in the Unity3d library or classes.jar. Or even import it to extend my mainactivity. I don't understand what am I doing wrong here. I am using Android Studio, although I am new to it.
Don't worry, make android plugins for unity could be a little bit messy at the start, even more if you don't have any experience with Android!
Some tips:
Assets/Plugins/Android (it's
important, I've been struggling for this stupidity here)classes.jar in AndroidStudio project in app/libs.Android/libsTo create plugins on AndroidStudio you need to create a library (this steps is to create it from an activity):
.implementation to .libraryTo recompile the plugin do the follow:
Rebuild AndroidStudio solution
Go to AndroidStudio solution...app\build\outputs\aar get the .aar
file
.aar to .zip or .rarOpen the modified file and extract 2 items:
classes.jar (this is another classes.jar, not the same stored in app/libs in your AndroidStudio project)AndroidManifest.xmlCopy those files into Unity project in Assets/Plugins/Android
(remember, project directory structure is important!)
You can download the classes.jar file (the first one) from my Utility_Repo or from the path you name it D:\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Variations\mono\Development\Classes\classes.jar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With