How to change libraries export order in Android Studio ?

1,578 views
Skip to first unread message

Vincent de Chefdebien

unread,
Dec 16, 2014, 11:03:58 AM12/16/14
to adt...@googlegroups.com
I'm trying to migrate my project from Ant to Gradle, and i cannot solve the following issue: I need to access android @hide fields (without reflection).

Up until now, I used a custom jar containing java classes with all the hidden fields (example: WifiManager.WIFI_SCAN_AVAILABLE). Note that this custom jar was used only as a reference (excluded from final apk). In Eclipse, I modified the classpath (in "order and export" tab) to have this custom jar above the android SDK's jar.

In Ant, i had to add the following lines, in my project's custom_rules.xml:

<path id="project.target.class.path" >
<pathelement location="../../misc/classes-full-debug_V5.0.jar" />
<pathelement location="${project.target.android.jar}" />
</path>

With this i was able to use hidden fields from WifiManager, TelephonyManager, ConnectivityManager, etc.


How do I reproduce this behaviour using Gradle ? The problem is that the Gradle is accessing the 'unmodified' WifiManager class (provided by the android sdk) instead of the custom one. Is there a way to shadow it?


Scott Barta

unread,
Dec 17, 2014, 11:10:00 AM12/17/14
to adt...@googlegroups.com
You can't do this in Android+Gradle right now. Gradle doesn't favor the notion of import order, but uses a system where you declare your dependencies explicitly. What you would need to do is to tell Gradle that your project depends on your custom android.jar instead of the SDK one, but there's no way to do that, since the reference to the SDK's version is hardcoded in the SDK and isn't accessible.

--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Xavier Ducrohet

unread,
Dec 17, 2014, 1:00:29 PM12/17/14
to adt...@googlegroups.com
What Scott said. You would have to create and use a custom SDK.
--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!
Reply all
Reply to author
Forward
0 new messages