Gradle dependency error - android-studio

I am using Gradle 2.4 and Android Studio 1.3. I have tried to use AppWarp's JAR file as a dependency in a libGDX project. I have got following error during Gradle sync:
Gradle DSL method not found 'compile()'
I put code below in allprojects section.
dependencies {
compile files('libs/App42MultiPlayerGamingSDK.jar')
}

You can't put "compile" in the allprojects section because that section does not have the java plugin applied, and therefore can only accept classpath dependencies. You could put apply plugin: "java" at the top of the allprojects block, but that will only lead you to the next problem...
Isn't that jar an Android-based library anyway? It will cause your other modules to fail to compile if you put it in allprojects. It needs to go in the android section's dependencies.

AppWarpMultiPlayerGamingSDK should be added to Android Studio as a module in the core project, by right click on project.
Select Module Setting
And SDK as a module library.
Thanks to AppWarp Support Team!

Related

Gradle sync fails to get AWS Mobile Client library in Android Studio

I have a project loaded in Android Studio 3.0. Gradle sync works fine, and the project builds.
When I add implementation 'com.amazonaws.aws-android-sdk-mobile-client:2.6.+' to my build.gradle (Module:app) file, right next to all the other dependencies that are already part of this fine project, gradle fails to find that dependency. Many of the existing project dependencies are under com.amazonaws.aws-android-sdk-* and are being sync'ed just fine, for e.g. implementation 'com.amazonaws:aws-android-sdk-core:2.6.+' is fine.
So I double check that new project dependency actually exists, browsing http://repo.maven.apache.org/maven2/com/amazonaws/aws-android-sdk-mobile-client shows it exists, I don't see a typo.
Looking at my build.gradle (Project: myProject), I see the following
allprojects {
repositories {
mavenCentral()
google()
jcenter()
}
}
Yet when gradle syncs i get
Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.amazonaws.aws-android-sdk-mobile-client:2.6.+:.
Could not resolve com.amazonaws.aws-android-sdk-mobile-client:2.6.+:.
Required by:
project :app
No cached version of com.amazonaws.aws-android-sdk-mobile-client:2.6.+: available for offline mode.`
There is a typo in your dependency.
Use
implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.6.+'
instead of
implementation 'com.amazonaws.aws-android-sdk-mobile-client:2.6.+'
uncheck "Offline Work" in Android Studio / File / Settings / Build, Execution, Deployment / Gradle

Android Studio 3.0 - Unable to find method 'com.android.build.gradle.internal.variant.BaseVariantData.getOutputs()Ljava/util/List'

Trying to start a new Kotlin project with Android Studio 3.0 Canary 1 displays this error. Full trace:
Error:Unable to find method
'com.android.build.gradle.internal.variant.BaseVariantData.getOutputs()Ljava/util/List;'.
Possible causes for this unexpected error include:Gradle's
dependency cache may be corrupt (this sometimes occurs after a network
connection timeout.) Re-download dependencies
and sync project (requires network)The state of a Gradle
build process (daemon) may be corrupt. Stopping all Gradle daemons may
solve this problem. Stop Gradle build
processes (requires restart)Your project may be using a
third-party plugin which is not compatible with the other plugins in
the project or the version of Gradle requested by the
project.In the case of corrupt Gradle processes, you can
also try closing the IDE and then killing all Java processes.
I've tried the first two options and the third-party plugins are left as default.
gradle-wrapper.properties
#Thu May 18 08:36:52 BST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-milestone-1-all.zip
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.2-3'
repositories {
maven { url 'https://maven.google.com' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I haven't touched any of these values myself, they're left as default. Creating a non-Kotlin new project does not have this problem.
In my build.gradle changing
ext.kotlin_version = '1.1.2-3'
to
ext.kotlin_version = '1.1.2-4'
fixed this.
You can find the most recent version here.
It worked for me
Using the 8.4.0 version
classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0'
For Java
Just remove
classpath 'me.tatarka:gradle-retrolambda:3.7.0'
downgrade butterknifeversion to 8.4.0
classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0'
Don't forget to remove
apply plugin: 'me.tatarka.retrolambda'
from app level build gradle.
This is a known issue in Android Studio Preview 3.0:
If you see this error, it's possible you have a pre-existing version of the Kotlin plugin that is incompatible with the new Android Plugin for Gradle that's in Android Studio 3.0. The solution is to delete the old Kotlin plugin.
Open your project-level build.gradle file and locate ext.kotlin_version. It should be 1.1.2-4 (or higher). If it shows an older version, you need to delete the old Kotlin plugin so it does not obstruct the version included with Android Studio 3.0.
On Windows, it should be located at
C:\Users\user_name\AndroidStudio_version\config\plugins\Kotlin\
On Mac, look in
~/Library/Application\ Support/AndroidStudio_version/Kotlin/
In my case, the issue was caused because we were applying butterknife-gradle-plugin. Upgrading to 8.8.1 didn't fix the issue, but removing it certainly did.
The build.gradle belongs to the application, so I don't even know why we are using that plugin (I'm new to the project)
Update your kotlin version to the latest:
ext.kotlin_version = '1.1.2-4' //currently it's the latest version
Then you may face some more errors, so before syncing again, make sure that your buildToolsVersion is "26.0.2" or higher.

Where is build:gradle:2.1.0-alpha3?

I have Just installed Android Studio Version 2.1 Preview 3 (AI-143.2682553)
When I run my project I get an error, it says:
Could not find com.android.tools.build:gradle:2.1.0-alpha3.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.0-alpha3/gradle-2.1.0-alpha3.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.0-alpha3/gradle-2.1.0-alpha3.jar
When I look in the Jcenter repository it only has 2.1.0-alpha1 https://jcenter.bintray.com/com/android/tools/build/gradle/
So I get why it can't find alpha3, but when I change the build.gradle to 2.1.0-alpha1 it says:
"The projects is using an incompatible version of the android Gradle plugin.
To continue opening the project, the IDE will update the Android Gradle plugin to version 2.1.0-alpha3"
which doesn't seem to exist right ?
Android Plugin for Gradle version 1.5.0 does not support Instant Run. Please update to version 2.1.0-alpha3
I had the similar problem and I fixed it by update it in android studio,just like this!
after update ,I find out the changes of gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0-alpha3'
// classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
buildToolsVersion '24 rc1'//buildToolsVersion "23.0.2"
I had the similar issue with 2.1.0-alpha3 .. my project cannot be complied ..I used earlier version 2.1.0-alpha1 # http://tools.android.com/download/studio/builds/android-studio-2-1-preview-1
By uninstalling and installing older version.
Hope that may help.

How to use jar library from another module in Android Studio

For the past few hours I've been trying to import a rather large eclipse ADT workspace (8 projects, 1 app) into Android Studio. I've managed to fix or bypass most of the errors which have popped up so far, but now a problem's arisen which I do not know how to fix.
I have a Java Library module (Toolkit), which has a JAR library dependency (commons-io-3.3.jar, as file dependency). Alongside this module I have an Android module which requires this JAR file (located as dependency within the Java Library Module), but I get an error: Error:(31, 29) package org.apache.commons.io does not exist. However, the module dependencies from the Android module show Toolkit as a module dependency.
So my question, in short, is this: In Android Studio, how can I use a JAR library in a Java module within an Android module? Or is there something else which I am doing wrong?
Edit:
build.gradle from Toolkit
apply plugin: 'java'
dependencies {
compile files('libs/commons-io-2.4.jar')
}
build.gradle from AndroidToolkit
apply plugin: 'com.android.library'
android {
// ...Android config stuff
}
dependencies {
compile project(':toolkit')
compile 'com.android.support:support-v4:18.0.0'
}

Why do we set Gradle classpath reference in both project's and module's build.gradle?

When we create an empty Android Gradle project using Android Studio 1.1.0 (and all older versions of Android Studio), there are two references to the Gradle plugin. One reference is in the Project's build.gradle and another reference is in the module's build.gradle. And the both look exactly the same
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.x.x'
}
}
As I experienced, the version of Gradle from project's file is more important because I can set the latest Gradle in it (v 1.1.3. for Android Studio 1.1.0) while I can leave(!) older version of Gradle in the module's build.gradle. The project will compile without any errors.
So why is the module's reference there on the first place?
Let's say that the reason is so that we can use other Gradle version in some modules. Does it mean that I can remove these lines of code from module's build.gradle if I plan to use the same Gradle version through out the project? This way I have to update the same line in all modules.
We do NOT have to! It seems that this habit was present in the previous versions of Android Studio (probably before the official release).
In Android Studio v1.1.0 there is only one reference - in projet's build.gradle.
Note: this project was created on the older version of Android Studio (not sure which one) and inherited its code.

Resources