I am trying to build a simple android project on the command line using
android create project
I am following this tutorial, and using android-sdk tools version 25.2.5 which still includes the above command. However, my gradle version is 4.8.1 and java 10.0.1.
First, I cd into my project folder and use the android command to create a project:
android create project -p . -a MainActivity -k com.test.firstapp -t "android-22" -g -v 2.3.0
This gives me a project frame. I chose the android gradle plugin version 2.3.0 based on this web page, hoping it would support all newer versions of gradle as well.
Then I try to build the project with
./gradlew build
and get my first error:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '10.0.1'.
So I reckoned there must be a mismatch with the gradle version and the gradle plugin version I am using because gradle 4.8.1 should definitely support java 10.0.1. I then went and looked at my build.gradle file in the project directory and changed the android plugin version to 3.1.0, as follows:
classpath 'com.android.tools.build:gradle:3.1.0'
also adding google() to the repositories. I still got the same java version error. Now, I had a look at gradle/wrapper/gradle-wrapper.properties and saw that the distributionUrl was for gradle 1.12, so I changed it to my actual version:
distributionUrl=http\://services.gradle.org/distributions/gradle-4.8.1-all.zip
After changing the gradle version in the wrapper, I call:
gradle wrapper --gradle-version 4.8.1
as advised here. Running this, I first get a warning and and error:
Configure project :
WARNING: The specified Android SDK Build Tools version (22.0.1)
is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.0.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '22.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
File /home/user/.android/repositories.cfg could not be loaded.
Checking the license for package Android SDK Build-Tools 27.0.3 in /opt/android-sdk/licenses
License for package Android SDK Build-Tools 27.0.3 accepted.
Preparing "Install Android SDK Build-Tools 27.0.3 (revision: 27.0.3)".
Warning: Failed to read or create install properties file.
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
FAILURE: Build failed with an exception.
* Where:
Build file '/home/user/dev/android/firstapp/build.gradle' line: 18
* What went wrong:
A problem occurred evaluating root project 'firstapp'.
> Could not find method runProguard() for arguments [false] on BuildType_Decorated{name=release, debuggable=false, testCoverageEnabled=false, jniDebuggable=false, pseudoLocalesEnabled=false, renderscriptDebuggable=false, renderscriptOptimLevel=3, minifyEnabled=false, zipAlignEnabled=true, signingConfig=null, embedMicroApp=true, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}} of type com.android.build.gradle.internal.dsl.BuildType.
I'm sure it's a mismatch of versions but could someone point out what the right combination is if I want to keep working with android-sdk tools 25.2.5?
I'm doing this on Ubuntu 16.04.
Thanks.
In the end, the combination that works for me was the following:
android sdk tools 25.2.5
android build tools 26.0.2
platform-tools 28.0.0 (uncritical in any case...)
java 8 (indeed had to downgrade)
gradle 4.8.1
android gradle plugin 3.0.1
With this combination I was able to create a project using 'android create project' and build with './gradlew build':
> android create project -p . -a MainActivity -k com.test.firstapp -t "android-22" -g -v 3.0.1
> Created directory ....
The android tool still creates some deprecated input into build.gradle, such as proguard instead of minifyEnabled, and leaves out some repositories (google(), jcenter()) that I need to find the newer gradle plugin version, among other things. Also, the gradle-wrapper.properties sill contain an outdated gradle version url but that can be changed as shown in my original question. I'm a lot closer to automating project creation from the command line than before even if it's not perfect.
Related
after adding react-native-vision-camera and 2 other packages, I got this error
The Android Gradle plugin supports only kotlin-android-extensions Gradle plugin version 1.6.20 and higher.
The following dependencies do not satisfy the required version:
project ':react-native-gesture-handler' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20
I know that I need to add kotlin_version = '1.6.20' but I have to do it only at the android folder of the react-native-vision-camera package. It solves the probleme but everytime I run ./gradlew clean I have to reset it !
how can I set the kotlin_version = '1.6.20' globally for 'all' node_module's packages ?
When I try to build the project:
5:33 pm Gradle sync started
5:33 pm Gradle sync failed: Could not determine java version from '11.0.8'.
The project uses Gradle version which is incompatible with Studio running on Java 10 or newer.
See details at https://github.com/gradle/gradle/issues/8431
Possible solution:
- Upgrade Gradle wrapper to 4.8.1 version and re-import the project
(2 s 910 ms)
5:33 pm Android Studio is using the following JDK location when running Gradle:
/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
Using different JDK locations on different processes might cause Gradle to
spawn multiple daemons, for example, by executing Gradle tasks from a terminal
while using Android Studio.
More info...
Select a JDK from the File System
Do not show this warning again
When I press the link to upgrade Gradle:
Could not determine java version from '11.0.8'.
The project uses Gradle version which is incompatible with Studio running on Java 10 or newer.
See details at https://github.com/gradle/gradle/issues/8431
Possible solution:
- Upgrade Gradle wrapper to 4.8.1 version and re-import the project
It is saying I have Java 11.0.8 when the JDK location is very clearly pointing at Java 8, and changing the Gradle version fails.
The steps I took to fix this were to make sure JDK was < 10 which it states it has to be. Since JDK = 8, this should be fulfilled.
Thanks for any advice.
I am trying to setup Android Studio For Offline builds, using latest gradle.
System - Windows 10 64 Bit.
What i have done so far?
Downloaded and Installed Android Studio 4.0.1 Windows 64 Bit from official website. Android SDK and AVD also selected during installation. (Internet Install)
Downloaded Offline components.
Android Gradle Plugin.
Google Maven Dependencies.
From -https://developer.android.com/studio#downloads
And setup according to docs for offline setup.
Downloaded Latest Complete Gradle zip file from :
https://gradle.org/releases.
Gradle version 6.5.1 (gradle-6.5.1-all.zip)
Pasted Gradle zip into .gradle/wrapper/dists/
And extracted it their.
And changed the path From File-> Settings->Build Tools->Gradle to above extracted folder.
When i tried to build, i got following errors:
Could not find com.android.tools.build:gradle:4.0.1 Searched in the following locations: - file:/C:/Users/Xevns/.android/manual-offline-m2/gmaven_stable/.../gradle-4.0.1.pom
Once inspected the offline components achieve, i think it uses Old Android Gradle plugin v3.5.0 beta and Old maven dependecy. But in project its using Gradle plugin 4.0.1 and Gradle 6.5.1.
Please help, where find it latest and setup.
The so called: latest versions of the Android Gradle plugin link does not contain the latest version. You have to select one that is in that package:
Grandle Scripts -> build.grandle :
classpath 'com.android.tools.build:gradle:3.4.0'
The Android Grandle Plugin package does not contain library versions that are needed for that "tools.build:grandle" version - (download manualy from repos?)
Other dependencies (appcompat,constraint-layout, ...) the same problem, requested versions are not included in downloaded Google Maven package.
****While configuring
ChatCamp
SDK with my project with compileSdkVersion 25 I get sync error****
Error:(33, 0) Gradle DSL method not found: 'implementation()'
Possible causes:The project 'ChatCamp' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 2.3.1 and sync projectThe project 'ChatCamp' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper fileThe build file may be missing a Gradle plugin.
Apply Gradle plugin
with compile sdk 26
Error:(33, 0) Gradle DSL method not found: 'implementation()'
Possible causes:The project 'ChatCamp' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 2.3.1 and sync projectThe project 'ChatCamp' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper fileThe build file may be missing a Gradle plugin.
Apply Gradle plugin
***When import
Sample Project*** in
Android Studio 2.3.1
sample project gradle version 4.1
Android Plugin |Version 3.0.1
Error:This Gradle plugin requires a newer IDE able to request IDE model level 3. For Android Studio this means version 3.0+
If changes > Sample App
gradle version 4.1 to 3.4.1 and android plugin version 3.0.1 to 2.3.1
then I get-
Error:(6, 0) Gradle DSL method not found: 'google()'
Possible causes:The project 'ChatCamp-Android-Example-master' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 2.3.1 and sync projectThe project 'ChatCamp-Android-Example-master' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper fileThe build file may be missing a Gradle plugin.
Apply Gradle plugin
You are facing this problem because the sample https://github.com/ChatCamp/ChatCamp-Android-Example is using gradle version greater than 3.0.0. There were some breaking changes in Gradle 3.0.0. You can take a look at how to migrate to new version of gradle here .
If you want to run this sample in older version of gradle you just need to replace implementation with compile, testImplementation with testCompile and androidTestImplementation with androidTestCompile.
I am trying to build the Java project located at here: https://github.com/garlicPasta/dotServer
I'm new to Gradle. I downloaded the latest Gradle now (v4.0). I added the bin folder of Gradle (which includes gradle.bat) to the path so I can run gradle command everywhere. Looks like the project requires Google protobuf which it downloads automatically. But when I start the command gradle build, I get the following error:
> Configure project :
You are using Gradle 4.0: This version of the protobuf plugin works with Gradle version 2.12+
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'dotServer'.
> No signature of method: org.gradle.api.internal.tasks.DefaultTaskInputs.source() is applicable for argument types: (com.google.protobuf.gradle.ProtobufSourceDirectorySet_Decorated) values: [main Proto source]
Possible solutions: collect(), use([Ljava.lang.Object;)
Where is the problem coming from? Can someone try to build the project and let me know?
I just upgraded to Android Studio 3 and had the same problem when I upgrade Gradle and it's plugin.
We use Google's Protobuf which was included in build.gradle with version 0.7.6. I just changed to 0.8.3 and it builds now.
buildscript {
...
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3'
}
}