7

Using Android Studio, I have an Android library project which produces 'library/build/outputs/aar/MyLIB.aar" just fine in Debug mode, but does not do so in Release mode. I see no errors, just "BUILD SUCCESSFUL" in the "Gradle Console" window but no Release Mode artifact.

There was a similar question raised here, and I'm getting the same behavior as #user1624552 mentions in the link:

"gradlew clean" followed by "gradlew aR" resultd in my AAR being created and correctly placed in the directory above. But using Android Studio and the "Release Mode" Build Variant does NOT create an AAR file.

Is there something configured in the Debug variant which is not configured in the Release variant?

Thanks, ALF

Community
  • 1
  • 1
Bungles
  • 1,969
  • 2
  • 25
  • 54
  • 1. Are you using ProGuard? 2. If you have a demo app which uses the library, it may have been merged into the final APK – milosmns Dec 08 '15 at 23:18
  • The following code is from my library's build.gradle file. There is reference to proguard in the "buildTypes" section, but even after deleting that block I get the same results. Note also that it says "cannot resolve symbol getDefaultProguardFile' when I hover over that function name.
    [code] buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }[/code]
    – Bungles Dec 09 '15 at 00:00
  • Ok so ProGuard seems to be off. Check if you can build a release apk of a real app using that library. – milosmns Dec 09 '15 at 00:03
  • I can't build an app because this won't product an AAR file. Also I apologies for the lack of formatting but I can't seem to get formatting to work in comments. – Bungles Dec 09 '15 at 00:07
  • Yeah, but if you build with Studio using a library and a demo app which uses the lib, it should be automatically placed and merged later on into the APK. Maybe create another project with new gradle and try again? If that doesn't do the trick, I have no idea what else to try :/ – milosmns Dec 09 '15 at 00:11
  • Not sure I'm following. I have a library that I can currently build and link with an app that uses it. I can build that library (.aar) with 'gradlew' on the command line in both debug and release modes without issue. I can build that library with Android Studio, but only in debug mode -- it will not produce an AAR file using the "Build Variant" of 'release'. You're saying build a demo app with the library and as you can see I've done that and it works -- except in this one case. Thus my puzzlement... – Bungles Dec 09 '15 at 18:42
  • Right, misunderstood that part. Did you maybe raise an issue on Android Studio bug report website? If so, did they respond at all? – milosmns Dec 09 '15 at 22:20
  • I haven't reported a bug because I'm not yet certain this isn't something I'm doing wrong. – Bungles Dec 09 '15 at 22:56
  • Yeah.. Update the thread if you find anything from them, it's an interesting problem at least – milosmns Dec 09 '15 at 23:09

2 Answers2

4

Right click the task you want and click "Run".

enter image description here

A J
  • 4,542
  • 5
  • 50
  • 80
3

To get the aar, you can do the following

  1. View/Tool Windows/Gradle”, to open the gradle window

  2. From gradle window, run assembly Gradle task by double-click on My_Plugin_Android/:My_Plugin/Tasks/build/assemble

Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
Abdalla
  • 2,071
  • 2
  • 16
  • 27