Android Studio - No such property: baseName for class - android

I am trying to add Dexguard to Android Studio. I have followed the guidelines so my build.gradle is the following:
buildscript {
repositories {
mavenCentral()
flatDir { dirs '/Users/XXXX/Desktop/DexGuard5.3.00/lib' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.4'
classpath ':dexguard:'
}
}
apply plugin: 'dexguard'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
proguardFile plugin.getDefaultDexGuardFile('dexguard-debug.pro')
proguardFile 'dexguard-project.txt'
proguardFile 'proguard-project.txt'
}
release {
proguardFile plugin.getDefaultDexGuardFile('dexguard-release.pro')
proguardFile 'dexguard-project.txt'
proguardFile 'proguard-project.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.0.1'
compile 'com.android.support:appcompat-v7:19.0.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Then I try to build the project and I get the following error:
Error:A problem occurred configuring project ':XXXX'.
No such property: baseName for class: com.android.build.gradle.internal.variant.ApplicationVariantData
Has anyone experienced such problem again?
Thank you in advance!

The Gradle plugin for DexGuard 5.3.00 is compatible with the Android plugin 0.5.1, so you should adapt the class path at the top of the file.
You probably want to install the latest version of the Gradle plugin though. At this time of writing, the Gradle plugin for DexGuard 5.5 is compatible with the Android plugin 0.9.0.
As a reference, you can always find working sample projects with build files in DexGuard's samples directory.

First you can try to add nexusUsername=123 nexusPassword=123 in the "project/maven_push.gradle"
Then if it report "Error:Could not find property 'allJava' on source set main."
you can try this:
task androidJavadocs(type: Javadoc) {
// comment it if you find
//source = android.sourceSets.main.allJava
}
task androidJavadocsJar(type: Jar) {
classifier = 'javadoc'
//basename = artifact_id
// comment it if you find
//from android.sourceSets.main.allSource
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
//basename = artifact_id
////comment it if you find
//from android.sourceSets.main.allSource
}
Last it‘s not my answer ,I found it in an small blog~~~Thanks to the authoer ,it sloved my problems~
Good luck to you ~

Related

DexArchiveMergerException only on release

I developed an app that uses a swagger-generated Java client. The client is in a project called "api", while the app is in a project called "app".
When I build the app via Build/Make Project everything works fine. Also, when I try to run the app on an emulated or physical device Run/Run 'app'. Running with debugger works as well. Even when I build the project via Buid/Generate Signed Bundle/APK and choose the debug option, it works.
Now. The build fails when I try to create a signed release build. The following messages show:
Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: [...]\app\build\intermediates\transforms\dexBuilder\release\54, [...]\app\build\intermediates\transforms\externalLibsDexMerger\release\0, [...]\app\build\intermediates\transforms\dexBuilder\release\52.jar, [...]\app\build\intermediates\transforms\dexBuilder\release\53.jar
Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: [...]\app\build\intermediates\transforms\dexBuilder\release\54, [...]\app\build\intermediates\transforms\externalLibsDexMerger\release\0, [...]\app\build\intermediates\transforms\dexBuilder\release\52.jar, [...]\app\build\intermediates\transforms\dexBuilder\release\53.jar
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: io.swagger.client.ApiCallback
I am pretty new to developing with Android Studio and Gradle. I tried some solutions on Stack Overflow that already suggested to add some libraries but so far none of them worked with my problem.
To me, its especially suspicious that the last error message points to io.swagger.client.ApiCallback.
Could it have anything to do with the fact that both settings.gradle for "api" and "app" have the same content? Both look like this:
rootProject.name = "swagger-java-client". This is the only line in the file, but as far as I know, the settings.gradle for "app" already hat that content. I cant remember changing it so its odd to me that it shows "swagger-java-client". Is that normal?
Update 1
ProGuard has been mentioned in the comments to might be a problem. This is the only occurrence I could find, referencing it. In my build.gradle for the "app"-project, there is this part:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
However, removing it did not change anything.
Update 2
When searching for "io.swagger" AS only finds this:
When searhing for "io.swagger.client.ApiCallback" AS only finds this:
Update 3
As suggested, I tried adding
android {
defaultConfig {
multiDexEnabled true
}
}
and adding android.enableD8 = false but that didn't help either.
Here are my build.gradle-Files (the first ones that caused the problems, without the suggested corrections I've tried so far.)
build.gradle (Module: api) (generated by Swagger):
apply plugin: 'idea'
apply plugin: 'eclipse'
group = 'io.swagger'
version = '1.0.0'
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}
repositories {
jcenter()
}
if(hasProperty('target') && target == 'android') {
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 25
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
// Rename the aar correctly
libraryVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.aar')) {
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
dependencies {
provided 'javax.annotation:jsr250-api:1.0'
}
}
afterEvaluate {
android.libraryVariants.all { variant ->
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
task.description = "Create jar artifact for ${variant.name}"
task.dependsOn variant.javaCompile
task.from variant.javaCompile.destinationDir
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
artifacts.add('archives', task);
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
artifacts {
archives sourcesJar
}
} else {
apply plugin: 'java'
apply plugin: 'maven'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
install {
repositories.mavenInstaller {
pom.artifactId = 'swagger-java-client'
}
}
task execute(type:JavaExec) {
main = System.getProperty('mainClass')
classpath = sourceSets.main.runtimeClasspath
}
}
dependencies {
compile 'io.swagger:swagger-annotations:1.5.21'
compile 'com.squareup.okhttp:okhttp:2.7.5'
compile 'com.squareup.okhttp:logging-interceptor:2.7.5'
compile 'com.google.code.gson:gson:2.8.2'
compile 'org.threeten:threetenbp:1.3.5'
testCompile 'junit:junit:4.12'
}
build.gradle (Module: app):
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "projectName"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "0.1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation fileTree(dir: '../api/build/libs', include: ['*.jar'])
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.okhttp:okhttp:2.7.5'
api project(path: ':api')
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.8'
implementation 'org.jetbrains:annotations-java5:15.0'
}
Here are some workaround :
Can you please make sure you have multiDexEnabled set to true as shown below in your gradle settings:
android {
defaultConfig {
multiDexEnabled true
}
}
Try android.enableD8 = false in grade.properties
Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: io.swagger.client.ApiCallback
Means there are multiple dependencies contain this class, maybe different versions, so you need to exclude them.
Press shift twice, search io.swagger, then record the found jar files.
If these jar files are simply duplicated, keep 1 in build.gradle.
If these jar files are modules of other dependency, enter gradlew -q app:dependencies in the terminal, find the root dependency names.
In build.gradle, choose 1 dependency to keep, for others add exclude command.
For example change
implementation 'xxx:xxx'
to
implementation ('xxx:xxx') { exclude module 'module-name-to-be-excluded' }
UPDATE
Some options to try:
Change build variants of both modules to release, then Build\Build APK
If success, copy the text from Gradle Console.
Next Build\Generate Signed APK...
Compare the text in Gradle Console with the above one to check the difference.
I've found the answer to my question:
What I did was to create the swagger client, move the created folder into my project, adjust the settings.gradle file and the build.gradle file accordingly.
What went wrong
The way I configured things, gradle would build the ´api´ project and then the app project.
For some reason, when I configured things as release, the app project referenced the code of the api project, as well as the resulting .jar file. Thats where the Program type already present came from.
How I fixed it
Exclude the api project from the app project
Build api seperately
Take the resulting .jarfile and put it in a folder inside your app folder called libs
Put this line in your gradle dependencies for your build.gradle (Module: app): implementation fileTree(dir: 'libs', include: ['*.jar'])
This included the finished .jarfile in the appproject and now I can build release. This should be done regardless, because the swagger client shouldnt be edited anyway, as it is generated code. So even just to not always build that part of the project, this should be done.
However, I still dont fully understand why there is this difference between the releaseand the debugbuild. Would be glad for any insight to that.
EDIT: ADDITIONAL INFORMATION
I just found out: if, for some reason, I would have wanted to keep the Module: api in my project I could have done so by removing the two dependencies in my Module: appthat start with implementation fileTree.
The api-project is already included by the dependency api project(path: ':api'). The filetree-lines were the ones causing the problem here, since they were redundant.
However, still no idea why there is a difference between debug and release

Could not find com.android.support:appcompat-v7:25.3.1

I suddenly started getting this error when trying to build. This was all working a few weeks ago with no changes that I know of. The issue seems to be related to react-native-fbsdk, but looking through its build.gradle it does not list support.appcompat-v7.25.x. Any advice?
A problem occurred configuring project ':app'.
> A problem occurred configuring project ':react-native-fbsdk'.
> Could not resolve all dependencies for configuration ':react-native-fbsdk:_debugCompile'.
> Could not find com.android.support:appcompat-v7:25.3.1.
Searched in the following locations:
file:/Users/a/.m2/repository/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.pom
file:/Users/a/.m2/repository/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.jar
https://jcenter.bintray.com/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.pom
https://jcenter.bintray.com/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.jar
build.gradle
apply plugin: "com.android.application"
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
import com.android.build.OutputFile
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "___"
minSdkVersion 16
targetSdkVersion 23
versionCode 22
versionName "1.5.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
manifestPlaceholders = [manifestApplicationId: "___",
onesignal_app_id: "___",
onesignal_google_project_number: "___"]
multiDexEnabled true
renderscriptTargetApi 19
renderscriptSupportModeEnabled true
}
signingConfigs {
release {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile project(':react-native-device-info')
compile project(':react-native-code-push')
compile project(':react-native-image-crop-picker')
compile project(':react-native-image-picker')
compile project(':react-native-fs')
compile project(':react-native-vector-icons')
compile project(':react-native-material-kit')
compile project(':react-native-config')
compile project(':react-native-onesignal')
compile project(':react-native-push-notification')
compile project(':react-native-android-permissions')
compile project(':react-native-android-keyboard-adjust')
compile project(':react-native-fbsdk')
compile (project(':react-native-fbads')) {
exclude group: 'com.google.android.gms'
}
compile 'com.facebook.android:audience-network-sdk:4.18.+'
compile 'com.google.ads.mediation:facebook:4.18.+'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-crash:10.2.0'
compile 'com.google.firebase:firebase-ads:10.2.0'
compile project(':react-native-billing')
compile project(':react-native-blur')
compile project(':instabug-reactnative')
compile project(':mobile-center-analytics')
compile project(':mobile-center-crashes')
compile (project(':react-native-appodeal')) {
exclude group: 'com.facebook.ads'
exclude (group: 'javax.inject', module: 'javax.inject')
}
compile project(':cheetah')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile "com.facebook.fresco:animated-gif:0.12.0"
compile "com.android.support:multidex:1.0.1"
}
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
I've had the same problem (appcompat-v7:25.3.1), on an android project, but not using react.
I first tried to clean the gradle cache (~/.gradle/caches), like explained here, but it didn't help.
Then I looked at the SDK Manager.
Android Support libraries are normally installed via sdkmanager.
The libraries are then stored in a local maven repository : <SDK_HOME>/sdk/extras/android/m2repository/.
For example, for appcompat-v7 the list of versions installed is in <SDK_HOME>/sdk/extras/android/m2repository/com/android/support/appcompat-v7/maven-metadata.xml.
So, for the Android Support Repository (revision: 47.0.0), the last version was normally 25.3.1.
To fix my problem, I had to uninstall the Android Support Repository via the SDK Manager, then reinstall it.
I also found another way to fetch support libraries : remotely.
After reading here (https://developer.android.com/topic/libraries/support-library/setup.html#add-library) and modifying <PROJECT_ROOT>/build.gradle like this :
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Then I tried to use a newer version of appcompat-v7:25.4.0 that was not in my local maven repository, and it worked !
The list of this Google Maven repository's versions of this library can be seen there : https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/maven-metadata.xml.
Follow the steps,
Add google maven in project gradle (Project: build.gradle),
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Remove existing gradle cache with below command
rm -fr ~/.gradle/caches/
Have a clean build and run
My case was that this is react-native-fbsdk build.gradle (https://github.com/facebook/react-native-fbsdk/blob/master/android/build.gradle):
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.facebook.react:react-native:+' // support react-native-v0.22-rc+
compile('com.facebook.android:facebook-android-sdk:4.+')
}
I am using React Native 0.37, so this is the line that broke for me:
compile('com.facebook.android:facebook-android-sdk:4.+')
Had to change to this for compatibility:
compile('com.facebook.android:facebook-android-sdk:4.18.+')
For this, try one of the following option:
1. Update your SDK manager > Go to build menu > clean project > then build project
or
2. Right click on project folder > open module setting > libraries > add com.android.support:appcompat-v7:25.3.1 > sync the project
3. Click on file menu > open project structure > and file the libraries
To solve this problem:
Open package.json and edit the react version to:
"react": "16.0.0-alpha.3",
"react-native": "0.43.1",
Delete node_modules directory
And re-install npm with the command npm install
In Addition: If you get a app:compileDebugJava ERROR, run react-native upgrade
(Got the solution from this github page and it worked for me)
Since gradle doesn't support declaring repositories on a per-artifact basis yet.
I modified my build.gradle (not app/build.gradle) to force all dependency to react-native to specific version:
allprojects {
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.facebook.react' && details.requested.name == 'react-native') {
def file = new File("$rootDir/../node_modules/react-native/package.json")
def version = new groovy.json.JsonSlurper().parseText(file.text).version
details.useVersion version
}
}
}
}
}
This seems to be an issue with react-native itself.
There is no official fix for this (yet), however some people have reported upgrading to have solved their problem. You can check more details here
Update 1:
Hi #roachman, this is the exact error I got which pointed me to search for above. There is another ticket logged #14225 for same(cannot post link for some reason). I was just able to resolve it by including exact version of react-native version in build.gradle dependencies line compile "com.facebook.react:react-native:0.xx.y" instead of compile 'com.facebook.react:react-native:+' You might want to try that for all projects that use that setting or a more elegant settings suggested in above in issue #14223 by user david50407
Update 2
This is officially fixed now have a look https://github.com/facebook/react-native/issues/14225#issuecomment-305073392 (had to remove earlier link for issue 14223 as I cannot post more than 2 links)
If you upgraded react-native-fbsdk from 0.5 to 0.6 versions and have this issue then open your android project (pathToYourApp/android) in Android Studio and it automatically offers you to update dependencies. Now It should work fine!

How to use Gradle to generate JavaDoc in Android Studio?

I can not find any documentation on how to configure my Gradle file to create the JavaDoc for my project. I already tried some snippets from SO and blog articles but none of them seem to work or they do not provide context.
This is my Gradle file. What do I need to do to add a task to generate JavaDoc?
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
In our projects we added the following to the app's build.gradle:
android.applicationVariants.all { variant ->
task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
description "Generates Javadoc for $variant.name."
source = variant.javaCompile.source
ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)
options.links("http://docs.oracle.com/javase/7/docs/api/");
options.links("http://d.android.com/reference/");
}
}
This will add tasks to the build of the form generate<build_variant>Javadoc. So let's say you have a free and a pro version of your app, this would add tasks like:
generateFreeDebugJavadoc
generateFreeReleaseJavadoc
generateProDebugJavadoc
generateProReleaseJavadoc
Hope this helps
In android studio, write a gradle task of type Javadoc :
task createJavadocs (type: Javadoc)
{
source = project.android.sourceSets.main.java.srcDirs
options.linkSource true
classpath += project.files(project.android.getBootClasspath().join(File.pathSeparator))
failOnError false
}
Simply execute this task will create javadocs.

"provided" scope not working - android studio with gradle

I need to prevent gradle from exporting a certain shared library.
I´ve read that using the provided scope should do the trick, but it seems that it was only working with older gradle versions.
Is there any other way to exclude dependencies from the build process to not get them into the final apk?
I have found solution here: https://stackoverflow.com/a/10406184/310760
But for Gradle 2.0 it has small changes:
configurations{
provided
}
sourceSets {
main {
compileClasspath += configurations.provided
}
test {
compileClasspath += configurations.provided
}
}
sourceSets.main.compileClasspath += configurations.provided
idea {
module{
scopes.PROVIDED.plus += [configurations.provided] // for Gradle 2.0
}
}
I have the same problem, and I found some solutions.But I don't understand.
http://www.sinking.in/blog/provided-scope-in-gradle/
Solved thie problem by using the android-apt gradle plugin.
see https://bitbucket.org/hvisser/android-apt/overview
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "org.ligboy.test.card.module1"
minSdkVersion 14
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations {
apt
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
apt 'com.android.support:support-v4:21.+'
apt 'com.google.code.gson:gson:2.2.+'
apt 'com.android.support:cardview-v7:+'
apt 'com.android.support:recyclerview-v7:+'
}
Fought with this for a while and found:
"provided" is part of gradle 1.3.0, but doesn't work properly.
"provided" works properly in gradle 1.5.0!
FYI: I had to delete my build directory after upgrading to 1.5.0 to remove the lib file from the .aar.

Gradle can't find library

I am trying to include Otto library in my project, but am getting this error:
> Could not resolve all dependencies for configuration ':maptest:_debugCompile'.
> Could not find com.squareup:otto:1.3.4.
I have tried cleaning project, running Tools -> android -> sync project with gradle files but that gives me the same error.
My build.gradle is the following:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:19.0.1'
compile 'com.google.android.gms:play-services:4.1.32'
compile 'com.squareup:otto:1.3.4'
}
You should add maven central repository, so gradle know where so search for library.
repositories {
mavenCentral()
}
Did you import Otto library into Android Private Libraries? Try clean project this way: Project -> Clean...
You may check this out.

Categories

Resources