Android Studio writes aar to Unity notes

This blog is to make a work note for later viewing.

common mistakes

1. BuildConfig duplicate error

Add in the android tag in build.gradle

 //这个配置是为了防止 导出包时 与Unity 包的buildConfig 文件发生冲突导致打apk 失败,添加后android studio 导出的aar 包不会包含 buildConfig文件
    buildFeatures{
        buildConfig = false
    }

2. UnityPlayerActivity.java problem

Because the new version of unity classes.jar does not contain UnityPlayerActicity.java, we need to go to the installation directory to copy <font size=4>C:\Program Files\Unity\Hub\Editor\2020.3.33f1\Editor\Data\PlaybackEngines\AndroidPlayer\ Source\com\unity3d\player</font>

 The above solution is to delete UnityPlayerActivity.java in the packaged aar

 3. 编译出现 Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.

 Add a directory in gradle.prooerties and fill in the corresponding installation directory

4. Modify the compiled aar name and add the following code to the android tag of build.gradle

 

Guess you like

Origin blog.csdn.net/qq_23879197/article/details/126599112