Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

Cannot use library via gradle on large project ? #144

Closed
AndroidDeveloperLB opened this issue Mar 15, 2016 · 45 comments
Closed

Cannot use library via gradle on large project ? #144

AndroidDeveloperLB opened this issue Mar 15, 2016 · 45 comments

Comments

@AndroidDeveloperLB
Copy link

I have a large project, with a lot of dependencies and modules.

For some reason, on a POC it works fine, but when using the large project, all it gets is the annotation library ("squidb-annotations-2.0.0").

I've performed the same exact steps as on the POC.

How could it be?

@sbosley
Copy link
Contributor

sbosley commented Mar 15, 2016

No idea, but I would be very surprised if this is a squidb problem. Is it possible you're hitting the dex limit? http://developer.android.com/tools/building/multidex.html. What's the error you're seeing?

@AndroidDeveloperLB
Copy link
Author

There is no error, but since the only library that's available is the annotation one, I can't use any class of the repo.
About multidexing, not only we use the solution of Google (was a long time ago), but I don't think it matters because I think multi-dexing is an issue at runtime, and not at code-writing time (which is also why proguard can help).

@AndroidDeveloperLB
Copy link
Author

btw, is it true there is version 3, yet the gradle version is still on 2 ?

@sbosley
Copy link
Contributor

sbosley commented Mar 15, 2016

Version 3 is in beta, so it's only available via source at this time (via this branch).

I've never seen this issue before and we too use squidb in projects with a very large number of dependencies, so I'm not sure what else to suggest. If you can post your gradle configuration or a sample project that exhibits the issue I'd be happy to take a look!

@AndroidDeveloperLB
Copy link
Author

About beta, it's ok to put beta repos on gradle. Google does this all the time (including alpha).
About the gradle configuration, I can't (closed source and I don't have permission to share this). Sorry.

@sbosley
Copy link
Contributor

sbosley commented Mar 15, 2016

I suppose I should have clarified -- we've chosen not to put v3 on jcenter yet not because of a technical limitation but because we don't feel it's entirely ready for public consumption :) For those that are eager to test it (the main new feature is j2objc support) building from source is pretty easy. It'll be ready soon!

Gives me an idea though -- have you tried cloning the repo and building squidb from source to see if the problem is related to getting the artifacts from jcenter or if it's triggered purely by having the dependencies in general?

Could you post just the small section of your gradle config where you add the squidb libs as dependencies so we can at least rule out anything fishy going on there?

@AndroidDeveloperLB
Copy link
Author

For now, we've put the code itself as module into the project, instead of using gradle-repo.
About out config, I've asked. Answer is no

@sbosley
Copy link
Contributor

sbosley commented Mar 15, 2016

If it works when building from source, I have to guess that there was probably something not quite right about how the configuration was set up, either with adding the dependencies themselves or in adding jcenter as a repository. You can double check that you've exactly reproduced all pieces of the config listed on this wiki page -- if anything from that sample was missing it would cause problems. Without being able to see your config or reproduce the problem though I'm afraid there's probably not much else I can do to help.

@AndroidDeveloperLB
Copy link
Author

I can say that both me and my team manager tried to use the gradle repo using the instructions, and it didn't work as on the POC.
But, I can say that you didn't separate some lines, and shown that all lines are added to the same file (here: https://github.com/yahoo/squidb/wiki/Adding-SquiDB-as-a-dependency ).
The "apply plugin: 'com.neenbedankt.android-apt'" is supposed to be in the gradle file of "app", above the "dependencies" , and the rest is supposed to be on the other file.

@sbosley
Copy link
Contributor

sbosley commented Mar 15, 2016

"The other file?" I'm not sure what you mean. That wiki page is based on our sample app's gradle file. All those things are indeed in the same file, which seems to be working fine. It's possible you are using a different project organization than we are, or have different gradle conventions.

Again though, without being able to see the config or reproduce the problem in a sample project, I'm afraid I'm really just out of ideas. I'd be totally happy to give it a look if you can create a non-proprietary sample project with a large number of dependencies that exhibits the same issue.

@AndroidDeveloperLB
Copy link
Author

When you create a new project, you get a global gradle file, and one per module.
Some things should be added to the global one, and some into the module's one. This is especially important for managing multiple apps inside the same project, or when you have a lot of dependencies.

@sbosley
Copy link
Contributor

sbosley commented Mar 15, 2016

Ah, I see what you're saying. Yes, you can put some of those things in the global gradle file, and you're right that in many cases you should, but we have often run into cases where we want to build certain modules in isolation or where the global gradle file is not available. In such cases we put all the things needed to satisfy the dependencies in the module's gradle file, as seen in the documentation.

Again, your configuration may be different. Without an error message or a sample project demonstrating the issue, there's really no way to know the cause of the problems you're seeing.

@AndroidDeveloperLB
Copy link
Author

ok, we will send you the gradle files, but can you please do it via email instead of here?

@sbosley
Copy link
Contributor

sbosley commented Mar 20, 2016

Sure! I've been meaning to set up a squidb-support email address for this kind of thing, so I will do so tomorrow.

@sbosley
Copy link
Contributor

sbosley commented Mar 21, 2016

It might take me a bit longer to set that up, so for now you can email to sbosley [at] yahoo-inc.com.

@AndroidDeveloperLB
Copy link
Author

Sent. Please let me know when you got it.

On Mon, Mar 21, 2016 at 9:39 PM, Sam Bosley notifications@github.com
wrote:

It might take me a bit longer to set that up, so for now you can email to
sbosley [at] yahoo-inc.com.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#144 (comment)

@sbosley
Copy link
Contributor

sbosley commented Apr 15, 2016

Hey @AndroidDeveloperLB -- I was actually just able to reproduce this issue. The TL;DR version -- I think it's an Android Studio bug.

When working with a library project which had a dependency on the squidb 2.0.0 artifacts, I upgraded them to the 2.0.3 artifacts and got the same issue you have been having. One thing I noticed was that building from the command line seemed fine, but Android Studio was missing the symbols. In other words, gradle was able to download and use the dependencies just fine, but for some reason they weren't being added to the classpath in Android Studio.

I don't know why the solution I stumbled on worked, but for me it worked when I added the squidb artifacts to the main app's build.gradle file instead of the library project's build.gradle file. I also noticed that other projects (like LeakCanary) have had similar issues reported.

Given that both building from the command line and adding the dependencies to the main app build.gradle fixed the issue when I encountered it, my best guess at this time is that it's a weird Android Studio bug. Feel free to give any of the things I've suggested here a try and let me know how it goes.

@AndroidDeveloperLB
Copy link
Author

I don't understand. How do I fix this issue?

On Fri, Apr 15, 2016 at 11:58 PM, Sam Bosley notifications@github.com
wrote:

Hey @AndroidDeveloperLB https://github.com/AndroidDeveloperLB -- I was
actually just able to reproduce this issue. The TL;DR version -- I think
it's an Android Studio bug.

When working with a library project which had a dependency on the squidb
2.0.0 artifacts, I upgraded them to the 2.0.3 artifacts and got the same
issue you have been having. One thing I noticed was that building from the
command line seemed fine, but Android Studio was missing the symbols. In
other words, gradle was able to download and use the dependencies just
fine, but for some reason they weren't being added to the classpath in
Android Studio.

I don't know why the solution I stumbled on worked, but for me it worked
when I added the squidb artifacts to the main app's build.gradle file
instead of the library project's build.gradle file. I also noticed that
other projects (like LeakCanary) have had similar issues reported.

Given that both building from the command line and adding the dependencies
to the main app build.gradle fixed the issue when I encountered it, my best
guess at this time is that it's a weird Android Studio bug. Feel free to
give any of the things I've suggested here a try and let me know how it
goes.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#144 (comment)

@sbosley
Copy link
Contributor

sbosley commented Apr 15, 2016

I'm saying it's likely an Android Studio bug that's out of our control, but I was able to get the symbols to reappear in Android Studio by declaring the squidb dependencies in the app's build.gradle file, rather than in the library's build.gradle file. You can try that to see if it helps.

@AndroidDeveloperLB
Copy link
Author

What to put exactly?

On Sat, Apr 16, 2016 at 12:37 AM, Sam Bosley notifications@github.com
wrote:

I'm saying it's likely an Android Studio bug that's out of our control,
but I was able to get the symbols to reappear in Android Studio by
declaring the squidb dependencies in the app's build.gradle file, rather
than in the library's build.gradle file. You can try that to see if it
helps.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#144 (comment)

@jaredsburrows
Copy link
Contributor

@AndroidDeveloperLB
Please use the maven plugin.

  1. git clone https://github.com/yahoo/squidb
  2. cd squidb
  3. gradlew install
  4. Add mavenLocal() to your dependencies
  5. In your project add the gradle dependency: compile "com.yahoo.squidb:squidb-annotations:<version>"

@sbosley
Copy link
Contributor

sbosley commented Jun 16, 2016

@AndroidDeveloperLB @jaredsburrows when I encountered this once and dug into it, I think it's the same kind of issue that some users of LeakCanary reported (see this issue). The fixes suggested in that thread resolved the issue for me without the need for any mavenLocal or gradlew install steps.

@AndroidDeveloperLB
Copy link
Author

@jaredsburrows I meant if there is a solution to use gradle files (only) to have the 3.x version of squidb.

@jaredsburrows
Copy link
Contributor

@AndroidDeveloperLB What do you mean "gradle files only"? Also there is a PR to merge 3.x here: #180.

@AndroidDeveloperLB
Copy link
Author

@jaredsburrows Meaning I won't have to clone anything. Just edit the gradle files to use this library.

@jaredsburrows
Copy link
Contributor

@AndroidDeveloperLB Yes, so skip all the steps in my previous message and add compile "com.yahoo.squidb:squidb-annotations:<version>" to the dependencies block like this:

dependencies {
   compile "com.yahoo.squidb:squidb-annotations:2.1.0"
}

@AndroidDeveloperLB
Copy link
Author

I'm talking about version 3. What do I put exactly in the gradle files to
use version 3 ?

On Thu, Jun 16, 2016 at 5:03 PM, Jared Burrows notifications@github.com
wrote:

@AndroidDeveloperLB https://github.com/AndroidDeveloperLB Yes, so skip
all the steps in my previous message and add compile
"com.yahoo.squidb:squidb-annotations:" to the dependencies block
like this:

dependencies {
compile "com.yahoo.squidb:squidb-annotations:2.1.0"
}


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#144 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AFG_1n6vNXxGiIVgiOYgRF1V-m1iw0l2ks5qMVeygaJpZM4Hw6hH
.

@jaredsburrows
Copy link
Contributor

Just change the version number.
On Jun 16, 2016 8:19 AM, "AndroidDeveloperLB" notifications@github.com
wrote:

I'm talking about version 3. What do I put exactly in the gradle files to
use version 3 ?

On Thu, Jun 16, 2016 at 5:03 PM, Jared Burrows notifications@github.com
wrote:

@AndroidDeveloperLB https://github.com/AndroidDeveloperLB Yes, so skip
all the steps in my previous message and add compile
"com.yahoo.squidb:squidb-annotations:" to the dependencies block
like this:

dependencies {
compile "com.yahoo.squidb:squidb-annotations:2.1.0"
}


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#144 (comment), or
mute
the thread
<
https://github.com/notifications/unsubscribe/AFG_1n6vNXxGiIVgiOYgRF1V-m1iw0l2ks5qMVeygaJpZM4Hw6hH

.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#144 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/ABqMSLGLlkjAEbXjP-yGTeHH13PDka-Qks5qMWlXgaJpZM4Hw6hH
.

@sbosley
Copy link
Contributor

sbosley commented Jun 16, 2016

Version 3 has not officially been published as a stable release, but we did upload some beta artifacts recently. You can use this:

dependencies {
    compile 'com.yahoo.squidb:squidb-annotations:3.0.0-beta.1'
    compile 'com.yahoo.squidb:squidb:3.0.0-beta.1'
    apt 'com.yahoo.squidb:squidb-processor:3.0.0-beta.1'
}

@jaredsburrows
Copy link
Contributor

@sbosley We might want to add that to front README.md so users can easily find and understand how to install the library into their project.

@sbosley
Copy link
Contributor

sbosley commented Jun 16, 2016

@jaredsburrows it's already in the README; the first section is a link to the wiki page entitled "Adding squidb as a dependency" that explains in more detail how to use the apt plugin, etc.

@jaredsburrows
Copy link
Contributor

@sbosley I know. I am saying add the block of code instead of the link so users can know this answer right away. Look at all of Squares and Jake Wharton's README.mds, https://github.com/JakeWharton/butterknife. Also, can we close this issue?

@sbosley
Copy link
Contributor

sbosley commented Jun 16, 2016

@AndroidDeveloperLB has the question you raised in this issue originally been sufficiently resolved? Can we close this issue?

@AndroidDeveloperLB
Copy link
Author

AndroidDeveloperLB commented Jun 19, 2016

@sbosley I tried to add this into the dependencies of the build.gradle file of "app" :

    compile 'com.yahoo.squidb:squidb-annotations:3.0.0-beta.1'
    compile 'com.yahoo.squidb:squidb:3.0.0-beta.1'
    apt 'com.yahoo.squidb:squidb-processor:3.0.0-beta.1'

But then I get this error:

Error:(207, 0) Gradle DSL method not found: 'apt()'
Possible causes:

Trying to add the lines into one of the modules that the app uses, I get this error:

Error:(207, 1) A problem occurred evaluating project ':app'.

Could not find method apt() for arguments [com.yahoo.squidb:squidb-processor:3.0.0-beta.1] on project ':app'.

I tried it on the library module, because currently I have the next lines there (which were replaced by the lines you told me), as I've cloned the squidb module:

    compile project(':squidb')
    compile project(':squidb-android')
    compile project(':squidb-annotations')
    compile project(':squidb-processor')
    apt project(':squidb-processor')

However, I've succeeded replacing what's possible, and now this works :

    compile project(':squidb-android')
    compile 'com.yahoo.squidb:squidb-annotations:3.0.0-beta.1'
    compile 'com.yahoo.squidb:squidb:3.0.0-beta.1'
    apt 'com.yahoo.squidb:squidb-processor:3.0.0-beta.1'

In "squidb-android" module, I had to change the gradle file to have :

compile 'com.yahoo.squidb:squidb:3.0.0-beta.1'

So I think the only thing left is the "squidb-android" module to be in the gradle file of the app.

So, it's not resolved. I still don't get how to properly use this repo in the project.

@sbosley
Copy link
Contributor

sbosley commented Jun 19, 2016

@AndroidDeveloperLB Sounds like you forgot to add the android-apt plugin to your app build.gradle. And you should have just replaced compile project(:'squidb-android') with compile 'com.yahoo.squidb:squidb-android:3.0.0-beta.1'

Try adding the following in both your library and your app's build.gradle:

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        ...
    }
}

repositories {
    jcenter()
}

apply plugin: 'com.neenbedankt.android-apt'

dependencies {
    compile 'com.yahoo.squidb:squidb:3.0.0-beta.1'
    compile 'com.yahoo.squidb:squidb-annotations:3.0.0-beta.1'
    compile 'com.yahoo.squidb:squidb-android:3.0.0-beta.1'
    apt 'com.yahoo.squidb:squidb-processor:3.0.0-beta.1'
}

@AndroidDeveloperLB
Copy link
Author

@sbosley Using this was enough (instead of what I used) :

compile 'com.yahoo.squidb:squidb-android:3.0.0-beta.1'

So, now it's resolved. Please do update the main page of this repo, so that all people could use the beta version using gradle.

@sbosley
Copy link
Contributor

sbosley commented Jun 20, 2016

@AndroidDeveloperLB glad this is resolved. We'll be updating the readme and documentation when we release stable versions of the 3.0 artifacts, probably later this week.

@AndroidDeveloperLB
Copy link
Author

Thank you. Wish I could be notified about repo-updates.

@sbosley
Copy link
Contributor

sbosley commented Jun 21, 2016

@AndroidDeveloperLB In fact, it's easy to watch and be notified pretty much any project or repository that publishes its artifacts to jcenter. The page for squidb is found here: https://bintray.com/yahoo/maven/squidb/view. There's a "watch" button there that should allow you to be notified when new versions are published. And of course you can use the github "watch" button to be notified of things like pull requests, etc.

@AndroidDeveloperLB
Copy link
Author

AndroidDeveloperLB commented Jun 21, 2016

Nice. I hope other repos websites will support this.

@AndroidDeveloperLB
Copy link
Author

AndroidDeveloperLB commented Jun 27, 2016

Say, the bintray website shows just this:

compile 'com.yahoo.squidb:squidb:3.0.0'

Is it now just one line to add to gradle file? If so, this doesn't work.

EDIT: This is how it should probably be:

compile 'com.yahoo.squidb:squidb:3.0.0'
compile 'com.yahoo.squidb:squidb-android:3.0.0'
compile 'com.yahoo.squidb:squidb-annotations:3.0.0'
apt 'com.yahoo.squidb:squidb-processor:3.0.0'

@sbosley
Copy link
Contributor

sbosley commented Jun 27, 2016

Bintray only generates samples to add a single module at a time. That's why we include different instructions in our documentation. Anything on the bintray page is generated by them and may not be correct or complete for squidb.

@AndroidDeveloperLB
Copy link
Author

Can I at least assume the number there is correct and should be the exact same one as in the instructions? And that it will get updated when you upload a new version?

@sbosley
Copy link
Contributor

sbosley commented Jun 27, 2016

Yep! We always keep the version number in sync for all modules, so you can always use the latest version number it shows there for everything.

@AndroidDeveloperLB
Copy link
Author

Thank you. You are great.

On Mon, Jun 27, 2016 at 5:35 PM, Sam Bosley notifications@github.com
wrote:

Yep! We always keep the version number in sync for all modules, so you can
always use the latest version number it shows there for everything.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#144 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AFG_1mql_yf3RSIMcMHGOtWAga85gjTSks5qP9-ZgaJpZM4Hw6hH
.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants