Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use for some reason #85

Closed
AndroidDeveloperLB opened this issue Apr 21, 2016 · 31 comments
Closed

Can't use for some reason #85

AndroidDeveloperLB opened this issue Apr 21, 2016 · 31 comments

Comments

@AndroidDeveloperLB
Copy link

I get this error:
Error:Could not find com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.0.
Searched in the following locations:
file:/C:/Program Files/Android/android-studio/gradle/m2repository/com/getkeepsafe/dexcount/dexcount-gradle-plugin/0.5.0/dexcount-gradle-plugin-0.5.0.pom
file:/C:/Program Files/Android/android-studio/gradle/m2repository/com/getkeepsafe/dexcount/dexcount-gradle-plugin/0.5.0/dexcount-gradle-plugin-0.5.0.jar
https://maven.fabric.io/public/com/getkeepsafe/dexcount/dexcount-gradle-plugin/0.5.0/dexcount-gradle-plugin-0.5.0.pom
https://maven.fabric.io/public/com/getkeepsafe/dexcount/dexcount-gradle-plugin/0.5.0/dexcount-gradle-plugin-0.5.0.jar

@jaredsburrows
Copy link
Collaborator

Show your entire build.gradle. It looks like you did not apply the correct repository. Gradle is only looking in your mavenLocal and fabric.io repositories.

@benjamin-bader
Copy link
Collaborator

@jaredsburrows is correct; in your buildscript repositories you'll need to have at least one of mavenCentral() or jcenter(). The readme shows an example of what this should look like.

@AndroidDeveloperLB
Copy link
Author

But I did as the website said.
Also, about publishing the gradle file, I can't, as it's of the company (unless I do this in private email, but this I can do only in about 7 days or so).
I've now tried in a new project, and I've succeeded, but only when putting the lines of the manual in different places than what's written:

This line:

classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.0'

should be in the project's gradle file, while the others should be in the other gradle file.

Also, it there a better way to show the number of method&fields in Android-Studio?
I had to write the command "gradlew assembleDebug" within its terminal.

I got this output in the end:
Total methods in app-debug.apk: 20146 (30.74% used)
Total fields in app-debug.apk: 10373 (15.83% used)
Methods remaining in app-debug.apk: 45389
Fields remaining in app-debug.apk: 55162

It seems a bit odd. Is this how many methods a totally new project take?

@jaredsburrows
Copy link
Collaborator

What dependencies do you have?
On Apr 22, 2016 3:58 AM, "AndroidDeveloperLB" notifications@github.com
wrote:

But I did as the website said.
Also, about publishing the gradle file, I can't, as it's of the company
(unless I do this in private email, but this I can do only in about 7 days
or so).
I've now tried in a new project, and I've succeeded, but only when putting
the lines of the manual in different places than what's written:

This line:

classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.0'

should be in the project's gradle file, while the others should be in the
other gradle file.

Also, it there a better way to show the number of method&fields in
Android-Studio?
I had to write the command "gradlew assembleDebug" within its terminal.

I got this output in the end:
Total methods in app-debug.apk: 20146 (30.74% used)
Total fields in app-debug.apk: 10373 (15.83% used)
Methods remaining in app-debug.apk: 45389
Fields remaining in app-debug.apk: 55162

It seems a bit odd. Is this how many methods a totally new project take?


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

@AndroidDeveloperLB
Copy link
Author

Default ones when creating a new project, as this is what I wrote... :)

@jaredsburrows
Copy link
Collaborator

jaredsburrows commented Apr 22, 2016

@benjamin-bader Alright. Well, I guess you can close this now.

@AndroidDeveloperLB
Copy link
Author

Why ? I still haven't tested it well at the office

@benjamin-bader
Copy link
Collaborator

@AndroidDeveloperLB The error you posted shows that, at build time, the buildscript repository set doesn't include either mavenCentral() or jcenter(). You can see that it is looking for .jar or .pom files first on your local filesystem, next in Fabric's own Maven repo.

My suggestion is to find the build.gradle file where you have a repositories section containing the string "maven.fabric.io", then immediately above that line, add mavenCentral() on its own line. This will ensure that Gradle knows where it can find the Dexcount plugin. Does that make sense?

@benjamin-bader
Copy link
Collaborator

benjamin-bader commented Apr 22, 2016

Also, I just realized that your follow-up comment shows method count output, meaning that at least some version of the plugin is running. Are you still seeing problems related to dexcount?

And yes, that initial method count is totally realistic. Projects are not Proguarded by default, and so you probably have the full Android SDK and one or more support libraries (not to mention Crashlytics) all contributing their full bulk. If you enabled Proguard you would see a much smaller number.

As of this moment, building via the command line is the best and most direct way to see dexcount output. You can also see it in Android Studio when building; check the Messages or Gradle Console windows.

@benjamin-bader
Copy link
Collaborator

@AndroidDeveloperLB Have you had a chance to test and see if your issue is resolved?

@benjamin-bader
Copy link
Collaborator

Closing this out due to a combo of what seems to be trivial user error and no response. If you continue seeing an issue, please re-open.

@AndroidDeveloperLB
Copy link
Author

@benjamin-bader What no response? I wrote "I can do only in about 7 days or so" .
I can't test it again till I go to the office again.

@benjamin-bader
Copy link
Collaborator

My mistake; I missed that.

@AndroidDeveloperLB
Copy link
Author

AndroidDeveloperLB commented May 1, 2016

ok, I've tested it at the office, and it took 26 minutes to re-build :(
(it's a very large project)
Then nothing of the plugin was shown, so my guess was that it didn't even work.
Ran re-build again, and this showed:

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

Plugin with id 'com.getkeepsle afe.dexcount' not found.
Information:BUILD FAILED

Since it takes so much time to build and I'm tight on schedule, I will try it out again later.

@benjamin-bader
Copy link
Collaborator

Looks like a typo in the plugin id.

@AndroidDeveloperLB
Copy link
Author

it was copy-paste.
Say, maybe I could send you the gradle files, so that you could inspect them?
But please keep them confidential.

@jaredsburrows
Copy link
Collaborator

Say, maybe I could send you the gradle files, so that you could inspect them?
But please keep them confidential.

It's a trap!

This conversation is so strange, just post your build.gradle files here with different packagenames and things removed.

@AndroidDeveloperLB
Copy link
Author

AndroidDeveloperLB commented May 1, 2016

Why a trap? And of what?
I work at a company, and code is closed sourced, and since there are multiple gradle files with lots of information in them, it is also considered closed sourced.
I've already shared the same files with another Github repo:
yahoo/squidb#144

@jaredsburrows
Copy link
Collaborator

@AndroidDeveloperLB I was joking. I fully understand, just "anonymize" your build.gradle files.

@AndroidDeveloperLB
Copy link
Author

It's a lot of files, and are quite complex. Plus for this I prefer to send via email. Please.

@jaredsburrows
Copy link
Collaborator

Your most root build.gradle must contain:
https://github.com/jaredsburrows/android-gradle-java-app-template/blob/master/build.gradle#L16

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' } // Mirrors jcenter() and mavenCentral()
    }

    dependencies {
        // Android gradle plugin
        classpath 'com.android.tools.build:gradle:2.1.0'
        // Dex method count
        classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.0'
    }
}

allprojects {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' } // Mirrors jcenter() and mavenCentral()
    }
}

Any build.gradle you want to have the "dex count" tasks applied, you must apply the plugin:
https://github.com/jaredsburrows/android-gradle-java-app-template/blob/master/build.gradle#L39

apply plugin: 'com.getkeepsafe.dexcount'

This is from my example https://github.com/jaredsburrows/android-gradle-java-app-template/blob/master/build.gradle.

@AndroidDeveloperLB
Copy link
Author

AndroidDeveloperLB commented May 3, 2016

Can't I have the "dex count" applied on all gradle files, without really write it in each?

Also, I've done as you wrote. Syncing (and also "make project") didn't show anything of the methods count in the messages window.
Trying the terminal command ("gradlew assembleDebug"), it had, again, build for a very long time (11 minutes).
It did show the results, but not in the end. It showed them somewhere in the middle.

In addition, it showed something weird:

Total methods in ...apk: 103995 (158.69% used)
Total fields in ...apk: 69793 (106.50% used)

What's with the >100% ?

Also, the apk file that it has checked is one of the "flavors" of the app, which we usually don't use (it tested a "lite" version of it, instead of the normal one).

@benjamin-bader
Copy link
Collaborator

benjamin-bader commented May 3, 2016

I think theoretically you could apply the plugin within allprojects, but I've never tried it; that would apply the plugin globally. I've found it most useful to only apply it to "final" projects, i.e. those that produce a shippable APK.

The percentage is weird, but I can see it happening (I haven't capped it at 100%). I'm aware of a few reasons that will cause it. It will happen if you are Multidexing, and also if you are using Instant Run.

Placement of the output isn't guaranteed to be at the end of the output - it comes right after the assemble task for whatever project you applied it to.

If you aren't using proguard or multidex or instant run, then I'm not sure what would be giving you these large (over 65k) method counts. As you say, your build is complex; if you have any insight into what might be happening (and are not multidexing or instant-running), I'd appreciate hearing about it.

I'm glad to see that the plugin is now at least running for you.

@benjamin-bader
Copy link
Collaborator

Agreed that the flavor behavior is odd. We examine each distinct variant, but I'm not sure that that will account for all flavors.

@AndroidDeveloperLB
Copy link
Author

The code has multidex, because it has a lot of libraries to handle. instant-run is enabled, but it doesn't help at all (even though Google praises it all the time).

@benjamin-bader
Copy link
Collaborator

OK, then that explains it. You have > 100% of the 65K method limit because you actually do have over 65K methods :)

Glad to see that things are working. I'll open a separate issue to investigate flavors; this one has gotten quite long and non-specific. Thanks for bringing it to my attention!

@AndroidDeveloperLB
Copy link
Author

Is it possible though, to show the situation of all libraries, and be able to see it without really to try to find it in all of the long output ?
And, is it possible to do it all without a full re-build of the project?

@benjamin-bader
Copy link
Collaborator

Yes, apply the plugin to each project you want counted. You need to at least ./gradlew assemble (or some variant thereof) because, as I mentioned, we add a Gradle task that runs after assemble. If you don't build, nothing gets counted.

@AndroidDeveloperLB
Copy link
Author

but is there an easier&faster way to do it, and avoid the need to search for the results in the huge amount of output?
I mean, it took 11 minutes, and I had a lot of text being printed...

@benjamin-bader
Copy link
Collaborator

No; this sounds like something you'll need to address in your own build.

There are other projects out there that will count independently of your build process, including one linked in this project's README.

@AndroidDeveloperLB
Copy link
Author

I don't see other projects being mentioned, but I've found this cool tool, which does it too (though its main use is for automatic UI performance measurement ) :

http://blog.nimbledroid.com/2016/04/25/problems-with-libraries-and-sdks.html
https://nimbledroid.com/

Anyway, thank you for the help.

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

No branches or pull requests

3 participants