The below works with the latest buildtools (19.0.1) and gradle plugin
(0.7.2) in terminal however in AS it shows "Cannot resolve symbol" for the
jar which is "provided".
Any ideas on how to exclude the certain classes from the dex. This is for
the xposed framework where the jar is already on the device.
On Friday, 16 August 2013 18:51:10 UTC+1, Andy Lo A Foe wrote:
>
> I just ran into the same issue where I needed to exclude the jar for a a
> device provided implementation (uses-library). The following gradle config
> snippet worked for me:
>
> configurations {
> provided
> }
>
> android.applicationVariants.all {
> variant -> variant.javaCompile.classpath += configurations.provided
> }
>
> dependencies {
> provided files('libs/samsung_ble_sdk_200.jar')
> }
>
> Last comment in
> https://code.google.com/p/android/issues/detail?id=55764helped i.e. use
> ".all" instead of ".each" for latest gradle release.
>
> Cheers,
> Andy
>
> On Friday, July 19, 2013 6:15:42 PM UTC+2, Xavier Ducrohet wrote:
>>
>> I thought the section of the doc I linked you to had the information but
>> it doesn't! sorry about that.
>>
>> in the Android plugin, The equivalent (sort of) of runtime is called apk.
>> You can do
>>
>> dependencies {
>> apk files('libs/foo.jar')
>> }
>>
>> and it'll only get packaged but won't be on the compile classpath.
>>
>> However it sounds like you want the opposite. It seems you want to have
>> the jar be used for compilation but not for packaging?
>> In a 'java' project 'runtime' is not what you want.
>>
>> I think you can do something like this, but I'm not 100% sure.
>>
>> dependencies {
>> compile files('libs/foo.jar')
>> apk.exclude files('foo.jar')
>> }
>>
>> Again I'm not 100% sure this is going to work. I have to check.
>>
>> Your current code should work though. as you create a new dependency
>> configuration, add your dependency to it and then manually add it to the
>> compilation classpath. The final packaging will not know about this
>> dependency so it won't get in the apk.
>>
>>
>> On Fri, Jul 19, 2013 at 4:00 AM, Eason <[email protected]> wrote:
>>
>>> > Question
>>> Hi Xavier Ducrohet,
>>>
>>> Thanks a lot for your response, but I'm still confused. Could you please
>>> help me
>>> again? Thanks a lot. My question is, for example:
>>>
>>> If I want to build apk without referencing one jar(ex:XXX.jar), I can't
>>> use
>>> compile" dependency because the XXX.jar will also be packaged into apk if
>>> using "compile files('XXX.jar')".
>>>
>>> I've tried to use "runtime" dependency, but this will get the error
>>> called
>>> "Could not find method runtime() for arguments"
>>>
>>> Finally, I know "android" plugin doesn't support "runtime" dependency.
>>>
>>> After searching from google, I should use my own dependency, called
>>> "provided".
>>> Then my build.gradle will be:
>>>
>>> configurations {
>>> provided
>>> }
>>>
>>> dependencies {
>>> provided files('libs/jarSample.jar')
>>> }
>>>
>>> android.applicationVariants.each { variant ->
>>> variant.javaCompile.classpath += configurations.provided
>>> }
>>>
>>> After building, I will get the apk without jarSample.jar be packaged.
>>>
>>>
>>> Finally, my question is:
>>> (1)How do I know which dependency is supported by "android" plugin?
>>> (2)I don't really know what "variant.javaCompile.classpath" stands for.
>>>
>>> Could you please help me? Thanks a lot.
>>>
>>> >Xavier Ducrohet <xav <at> android.com> writes:
>>> >
>>> >
>>> >
>>> >
>>>
>>> http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Dependencies-Android-Libraries-and-Multi-project-setup
>>> >
>>> >
>>> > On Thu, Jul 18, 2013 at 7:39 PM, Eason <lovewen1012 <at> gmail.com>
>>> wrote:
>>> >
>>> >
>>> > Xavier Ducrohet <xav <at> android.com> writes:
>>> > >
>>> > >
>>> > > 'runtime' is not a valid dependency configuration. 'apk' is the
>>> > configuration to add dependency only for packaging but not compiling.
>>> > >
>>> > >
>>> > >
>>> > > On Mon, Jun 3, 2013 at 8:06 PM, <huan.zheng.ray <at> gmail.com>
>>> wrote:
>>> > >
>>> > > Hi,I'm using android studio, but i'm facing a problem that gradle
>>> androidplugin seems not supporting runtime dependencies,
>>> > > which BTW is not a problem when i was using Eclipse to develop or use
>>> > Android.mk to compile with source code build system.
>>> > >
>>> > >
>>> > > i'm trying to do this.
>>> > >
>>> > >
>>> > >
>>> > > buildscript { .......}apply plugin: 'android'dependencies {
>>> compile
>>> > fileTree(dir: 'libs', include: '*.jar') runtime
>>> > file('lib/pluginapi.jar')}android { ......}
>>> > >
>>> > > when i compile with 'gradle build', i got below error:
>>> > >
>>> > >
>>> > >
>>> > >
>>> > > A problem occurred evaluating root project 'XXXXX'.> Could not find
>>> method
>>> > runtime() for arguments
>>> [C:\Work\Android\workspace\XXXXX\lib\pluginapi.jar]
>>> > on root project 'XXXXX'.* Try:Run with --stacktrace option to get the
>>> stacktrace. Run with --info or --debug option to get more log output.
>>> > >
>>> > >
>>> > >
>>> > > I don't think runtime dependency is meaningless for Android,
>>> sometimes, we
>>> > need to use this feature.
>>> > >
>>> > > Thanks much for your feedback!
>>> > >
>>> > >
>>> > >
>>> > >
>>> > Hi all,
>>> > I'm new to Gradle, I don't know how to find the entrance to propose a
>>> new
>>> > problem, thus, I would like to ask one question about
>>> plugin-dependencies
>>> > like this.
>>> > Could someone give me some directions? Thanks a lot
>>> > My question is:
>>> > (1)What the dependency which "android" plugin have?
>>> > It's because I've had many times "try-and-error" to use runtime
>>> > dependency configuration in "android" plugin, and finally find the
>>> "runtime"
>>> > is only supported in "java" plugin.
>>> > Is there any document to find which dependency configuration is
>>> supported?
>>> > Thanks a lot for your great help.
>>> >
>>> > --
>>> > 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+unsubscribe <at> googlegroups.com.
>>> > For more options, visit https://groups.google.com/groups/opt_out.
>>> >
>>> >
>>> >
>>> > -- Xavier DucrohetAndroid SDK Tech LeadGoogle
>>> Inc.http://developer.android.com | http://tools.android.comPlease do not
>>> send me questions directly. Thanks!
>>> >
>>> >
>>> >
>>> >
>>>
>>>
>>>
>>>
>>> --
>>> 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 [email protected].
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>
>> --
>> Xavier Ducrohet
>> Android SDK Tech Lead
>> Google Inc.
>> http://developer.android.com | http://tools.android.com
>>
>> Please do not send me questions directly. Thanks!
>>
>
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.