unity-jar-resolver icon indicating copy to clipboard operation
unity-jar-resolver copied to clipboard

Use android debugImplementation and releaseImplementation

Open troy-lamerton opened this issue 5 years ago • 4 comments

Is there a way to specify debugImplementation and releaseImplementation for android dependencies?

For example, you can log useful debugging info inside myplugin-debug.aar. When building for release, proguard can strip these logs away.

// desired output to mainTemplate.gradle
debugImplementation files('./libs/myplugin-debug.aar')
releaseImplementation files('./libs/myplugin-release.aar')

At the moment I am constantly adding/removing Log.d calls used for debugging.

troy-lamerton avatar Nov 25 '19 05:11 troy-lamerton

Thinking more about this, is it better to use a local file-system repository instead?

I didn't set up a local maven repo before.. would that allow choosing between debug and release binaries?

troy-lamerton avatar Nov 27 '19 07:11 troy-lamerton

@troy-lamerton sounds like a neat idea for a feature. Right now it's not possible to specify debug vs. release artifacts. However, I could imagine that it would be possible to inject different dependencies based upon the Unity build settings, you would need to at least update https://github.com/googlesamples/unity-jar-resolver/blob/master/source/PlayServicesResolver/src/AndroidXmlDependencies.cs to support dependencies per build type, https://github.com/googlesamples/unity-jar-resolver/blob/master/source/JarResolverLib/src/Google.JarResolver/PlayServicesSupport.cs (in particular GetAllDependencies) to return the appropriate set of dependencies based upon the build configuration type, https://github.com/googlesamples/unity-jar-resolver/blob/master/source/PlayServicesResolver/src/PlayServicesResolver.cs AndroidBuildSystemSettings to track the build type and prompt for resolution if the build type changes.

stewartmiles avatar Dec 02 '19 20:12 stewartmiles

Ok so what you described would solve the debug vs release question, that's great.

How best to use local aars though? The only reason I would make this feature is to use it with aars built from a local android gradle project.

troy-lamerton avatar Dec 03 '19 11:12 troy-lamerton

@troy-lamerton if you want to use local AARs why not plumb them into the Gradle build in Unity via the mainTemplate.gradle file instead? That would allow you to build the local AARs as part of your application's build process.

If you want to use local AARs you can do so already if you publish them to a local maven repo see https://github.com/googlesamples/unity-jar-resolver/blob/master/sample/Assets/PlayServicesResolver/Editor/SampleDependencies.xml#L10 . Repository references can be local paths relative to the Unity project, or any URI including file URIs.

stewartmiles avatar Dec 03 '19 18:12 stewartmiles