How to get gradle to compile local version of picasso

I have an Android project that uses the local version of picasso library , which I changed in several ways. However, when I try to create my project from the command line using gradle build , I always get an error message that Picasso does not exist:

 $ ./gradlew build :compileLint :copyDebugLint UP-TO-DATE :mergeDebugProguardFiles UP-TO-DATE :preBuild UP-TO-DATE :preDebugBuild UP-TO-DATE :checkDebugManifest :prepareDebugDependencies :compileDebugAidl UP-TO-DATE :compileDebugRenderscript UP-TO-DATE :generateDebugBuildConfig UP-TO-DATE :generateDebugAssets UP-TO-DATE :mergeDebugAssets UP-TO-DATE :generateDebugResValues UP-TO-DATE :generateDebugResources UP-TO-DATE :packageDebugResources UP-TO-DATE :processDebugManifest UP-TO-DATE :processDebugResources UP-TO-DATE :generateDebugSources UP-TO-DATE :processDebugJavaRes UP-TO-DATE :compileDebugJavaWithJavac /Users/me/project/src/com/example/myproject/MyView.java:30: error: package com.squareup.picasso does not exist import com.squareup.picasso.Picasso; 

Also, when I start with --info , I see that it collects tasks, but at the end picasso:check and picasso:build are put at the end:

Tasks to be executed: [task ':compileLint', task ':copyDebugLint', task ':mergeDebugProguardFiles', task ':preBuild', task ':preDebugBuild', task ':checkDebugManifest', task ':prepareDebugDependencies', task ':compileDebugAidl', task ':compileDebugRenderscript', task ':generateDebugBuildConfig', task ':generateDebugAssets', task ':mergeDebugAssets', task ':generateDebugResValues', task ':generateDebugResources', task ':packageDebugResources', task ':processDebugManifest', task ':processDebugResources', task ':generateDebugSources', task ':processDebugJavaRes', task ':compileDebugJavaWithJavac', task ':packageDebugJar', task ':compileDebugNdk', task ':packageDebugJniLibs', task ':packageDebugLocalJar', task ':packageDebugRenderscript', task ':bundleDebug', task ':compileDebugSources', task ':assembleDebug', task ':copyReleaseLint', task ':mergeReleaseProguardFiles', task ':preReleaseBuild', task ':checkReleaseManifest', task ':prepareReleaseDependencies', task ':compileReleaseAidl', task ':compileReleaseRenderscript', task ':generateReleaseBuildConfig', task ':generateReleaseAssets', task ':mergeReleaseAssets', task ':generateReleaseResValues', task ':generateReleaseResources', task ':packageReleaseResources', task ':processReleaseManifest', task ':processReleaseResources', task ':generateReleaseSources', task ':processReleaseJavaRes', task ':compileReleaseJavaWithJavac', task ':packageReleaseJar', task ':compileReleaseNdk', task ':packageReleaseJniLibs', task ':packageReleaseLocalJar', task ':packageReleaseRenderscript', task ':bundleRelease', task ':compileReleaseSources', task ':assembleRelease', task ':assemble', task ':lint', task ':preDebugUnitTestBuild', task ':prepareDebugUnitTestDependencies', task ':processDebugUnitTestJavaRes', task ':compileDebugUnitTestJavaWithJavac', task ':compileDebugUnitTestSources', task ':mockableAndroidJar', task ':assembleDebugUnitTest', task ':testDebugUnitTest', task ':preReleaseUnitTestBuild', task ':prepareReleaseUnitTestDependencies', task ':processReleaseUnitTestJavaRes', task ':compileReleaseUnitTestJavaWithJavac', task ':compileReleaseUnitTestSources', task ':assembleReleaseUnitTest', task ':testReleaseUnitTest', task ':test', task ':check', task ':build', task ':android-autofittextview:assemble', task ':android-autofittextview:check', task ':android-autofittextview:build', task ':picasso:assemble', task ':picasso:check', task ':picasso:build']

I would think that :picasso:(assemble|check|build) needs to be run before :compileDebugJavaWithJavac , with which it does not work, especially considering my compile project(':picasso') directive compile project(':picasso') in the dependencies section of my build.gradle file.

Here is my build.gradle file:

 buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:1.3.+' } } apply plugin: 'android-library' android { compileSdkVersion 19 buildToolsVersion '23.0.1' sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } } } dependencies { repositories { mavenCentral() } compile project(':picasso') compile project(':android-autofittextview') compile 'org.apache.httpcomponents:httpmime:4.2.3' } 

And here is my settings.gradle file:

 include ':myproject' include ':picasso' project(':picasso').projectDir = \ new File(settingsDir, '../../../Lib/picasso') include ':android-autofittextview' project(':android-autofittextview').projectDir = \ new File(settingsDir, '../../../Interface/android-autofittextview') 

Here is my version of gradle:

 $ gradle --version ------------------------------------------------------------ Gradle 2.7 ------------------------------------------------------------ Build time: 2015-09-14 07:26:16 UTC Build number: none Revision: c41505168da69fb0650f4e31c9e01b50ffc97893 Groovy: 2.3.10 Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013 JVM: 1.8.0_51 (Oracle Corporation 25.51-b03) OS: Mac OS X 10.10.5 x86_64 

Please note that I do not think this is relevant to Picasso itself, because I am seeing the same problem trying to compile a local version of android-autofittextview too.

Can someone tell me how can I get gradle to compile and enable my local version of picasso correctly?


A shot in the dark, but I wonder if this is due to the fact that my projects in the android library are building . aar files and not .jar files, and therefore somehow gradle does not recognize them as valid dependencies?

+5
source share
1 answer

Finally, I was able to successfully build. Picasso has a project structure, where there is a root directory, and then many subdirectories, each of which represents a different project (Picasso, Picasso-sample, Picasso-Polixor). I installed projectDir as the picasso root directory instead of the actual library subdirectory. So I changed my settings.gradle file as follows:

 project(':picasso').projectDir = \ new File(settingsDir, '../../../Lib/picasso') 

to that

 project(':picasso').projectDir = \ new File(settingsDir, '../../../Lib/picasso/picasso') 

I did a similar thing in one of my other dependencies. Thus, instead of:

 project(':android-autofittextview').projectDir = \ new File(settingsDir, '../../Interface/android-autofittextview') 

I have done this:

 project(':android-autofittextview').projectDir = \ new File(settingsDir, '../../Interface/android-autofittextview/library') 

This is difficult because in this last example, the build.gradle file in the library directory had dependencies on the parent build.gradle, which I had to copy to the child. It seems like I should be able to create a dependency on a parent project that understands what I mean by the child / library.

But in the end, I managed to get him to compile this approach.

0
source

Source: https://habr.com/ru/post/1234072/


All Articles