i have downloaded image cropper example from following link
https://github.com/edmodo/cropper
and when i try to import it in a android studio i am getting following error.
here is the error , i am quite new to this so m not aware how i resolve.
Have tried by importing project as gradle but same error
inside master
buildscript {
repositories {
mavenCentral()
}
dependencies {
// Plug-in release notes: http://tools.android.com/tech-docs/new-build-system
classpath 'com.android.tools.build:gradle:0.11.+'
compile 'com.edmodo:cropper:1.0.1'
}
}
task wrapper(type: Wrapper) {
// See latest Gradle version: http://www.gradle.org/downloads
gradleVersion = '1.12'
}
inside cropper
apply plugin: 'android'
dependencies {
compile project(':cropper')
}
android {
compileSdkVersion 19
buildToolsVersion "19.1"
defaultConfig {
minSdkVersion 7
targetSdkVersion 19
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
You can import it in two ways.
First method:
build.gradle
apply plugin: 'com.android.application'
android {
...
}
repositories {
mavenCentral()
}
dependencies {
...
compile 'com.edmodo:cropper:1.0.1'
}
Second one:
Download cropper.
Put cropper folder inside projectname directory.
Edit settings.gradle:
include ':app', ':cropper'
Edit build.gradle:
apply plugin: 'com.android.application'
android {
...
}
dependencies {
...
compile project(':cropper')
}
Library Project:
If you would like to use cropper as library project you need to do:
Clone cropper.
Import project (Eclipse ADT ...) using Android Studio.
Known error will appear after sync fail:
Error:(47, 0) No such property: sonatypeRepo for class: org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer
Inside project root directory create gradle.properties with:
sonatypeUsername=
sonatypePassword=
sonatypeRepo=
Fix plugin version:
Error:The project is using an unsupported version of the Android Gradle plug-in (0.11.2). The recommended version is 1.1.0. Fix plugin version and re-import project
Now you will be able to run CropperSample project. Since cropper is now working you can do whatever you want with it.
You should not put your application specific dependencies in the "master" build file. In your case, the master build.gradle
file buildscript block should look like this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
}
}
And then append this to the build.gradle
file of the app where you want to use Cropper, in this case the CropperSample project:
dependencies {
compile 'com.edmodo:cropper:1.0.1'
}
I noticed you added compile project(':cropper')
to the build.gradle
file of the Cropper project. This will not work because you are basically making the Cropper project depend on itself. If you want to download the code and use that instead of Maven Central, then you should add the dependency to CropperSample and remove that line from the Cropper project's build file.
1] Download Cropper from https://github.com/edmodo/cropper
Unzip
cropper-master.zip
2] Go to Android Studio File --> New --> Import Module
Import Only ../cropper-maste/cropper folder
In Android Studio Project check cropper module added.
3] Goto cropper module's buld.gradle
Add comment or remove
uploadArchives {
/* repository(url: sonatypeRepo) {
authentication(userName: sonatypeUsername,
password: sonatypePassword)
}*/
}
4] Goto Android Studio Project's build.gradle
Add dependencies
dependencies {
compile project(':cropper')
}
5] Rebuild, Sync Gradle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With