jvoegele / gradle-android-plugin

Android plugin for the Gradle build system.
Apache License 2.0
406 stars 95 forks source link

jar dependencies are not packaged #11

Closed marcusb closed 13 years ago

marcusb commented 13 years ago

Runtime (and compile) dependencies are not included in the application package. As a result, applications which declare dependencies in the build script crash with a "class not found" exception when launched.

My attempted workaround is to include them in the invocation of dx in androidPackage():

ant.apply(executable: ant.dx, // ...
    // ...
    configurations.runtime.each {
        fileset file: it
    }
}

This includes the classes from the dependencies in classes.dex.

I still couldn't get my app to run, but this may be due to other things. Will have to investigate.

I suspect that one problem with this solution could be that transitive dependencies are omitted, but I haven't verified this.

marcusb commented 13 years ago

The app actually works now.

jvoegele commented 13 years ago

In the current state of the plugin, proguard does the work to package dependencies into the JAR file that eventually gets packaged as the Android apk file. This works so long as you do not disable proguard in the build. I am working on making proguard truly optional in the build, so that everything works whether or not you have proguard enabled.

fdasoghe commented 13 years ago

I think this could be fixed in the latest release, 0.9.5 (the build lifecycle now uses the jar, indipendently from the proguard task).

marcusb, could you please verify and possibly close this issue?

Thanks,

Fabio

fdasoghe commented 13 years ago

Hello.

I've created a Google Code hosting for this project, and two linked Google Groups (user and developer).The intent is to use Google's facilities for every aspect regarding discussions, issue tracking, documentation, wiki, and keeping using GitHub for source code repository, forking and merging.

The project is here: http://code.google.com/p/gradle-android-plugin/

Please, don't open new issues on GitHub but on the new hosting project.

Cheers,

Fabio

mttkay commented 13 years ago

Hmm, it almost looks as if I bumped into the same issue using the latest release 0.9.7: http://groups.google.com/group/gradle-android-plugin-users/browse_thread/thread/8c8d383340e5f75b

maybe this wasn't fixed after all? in fact, on the master branch of gradle-android, I still only see the JARs in libs/ being passed to the dexer, but then again, maybe I'm just missing something.

mttkay commented 13 years ago

OK, so in order to verify whether it's the proguard task (or the lack thereof) causing this or not, I enabled use of proguard in my build. What I did was simply copying the standard proguard.cfg over to my app project, and set proguard.enabled = true.

Now I am getting an exception in AndroidPackageTask.createPackage(AndroidPackageTask.groovy:109): apply returned: 1

I assume that means the execution of the dexer failed with a non-zero exit code (better error messages would really help here). Any ideas?

fdasoghe commented 13 years ago

Why you copied the proguard.cfg file? The proguard task doesn't use any external file.

Please, repeat the build with flags -d -S on Gradle's command line and post here the output (maybe you want to open this issue on Google Code and put there the attachment).

mttkay commented 13 years ago

fair question. I don't know. I guess I assumed that gradle-android would read it, considering that this is how proguard is usually configured, and it's also the standard way to configure proguard for Android apps. To be honest, I think gradle-android should honor that file, but that's probably another issue.

I'll move this to Google code then.

mttkay commented 13 years ago

for the record: http://code.google.com/p/gradle-android-plugin/issues/detail?id=2

jvoegele commented 13 years ago

I merged apechinsky's proposed fix for this into master. Please try using latest master and advise as to whether it is working.

fdasoghe commented 13 years ago

Let's continue on Google Code about this issue (kindly from kaeppler: http://code.google.com/p/gradle-android-plugin/issues/detail?id=2 ).

About proguard.cfg file, I agree with kaeppler, and indeed I wrote about it in the developer groups (http://groups.google.com/group/gradle-android-plugin-developers/browse_thread/thread/83625da16e942802).