I am trying to test my ionic app in android studio. It is throwing the below error.
Gradle sync failed: Cause: compileSdkVersion is not specified.
Any solution for this ? What am I doing wrong.
Here is my build.gradle file
apply plugin: 'com.android.application'
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
// Allow plugins to declare Maven dependencies via build-extras.gradle.
allprojects {
repositories {
mavenCentral();
jcenter()
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.1.0'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:+'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:+'
implementation 'com.android.support:appcompat-v7:27.+'
}
You are using android support library of 27.+ so you will have to give sdk version 27 as compileSdkVersion and targetSdkVersion otherwise your project does not know for which platform your project should be built. These parameter should be given in android directory like this in build.gradle(app):
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.example.abc.test"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Just paste this code below apply plugin: 'com.android.application' this line
In my case , I fixed it by setting the Android gradle plugin version and gradle version to the latest.
If you are working on a old project and using latest version of Android studio then simply change
compileSdk 27
to
compileSdkVersion 27
on your app level build.gradle file. it will fix this error
Please Add Below Line in your gradle file
compileSdkVersion 26
please check below code for reference
android {
compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
applicationId ""
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Note: There was an error in my app/build.gradle, hence it was not
reading compileSDKVersion property. When I commented such a line, the
error went away:
//def enableHermes = project.ext.react.get("enableHermes", false);
Firstly I got to follow this link:
ReactNative: Building from source
Then this:
ReactNative: android-development-environment
Then you can have this added in your settings.gradle file:
//
include ':ReactAndroid'
//
project(':ReactAndroid').projectDir = new File(
rootProject.projectDir, '../node_modules/react-native/ReactAndroid')
For my ReactViro Sample project I also had to add dependencies from react-native node_modules directory:
implementation project(':arcore_client') // remove this if AR not required
implementation project(':gvr_common')
implementation project(path: ':viro_renderer')
implementation project(path: ':react_viro')
and
in my settings.gradle:
//
include ':react_viro', ':arcore_client', ':gvr_common', ':viro_renderer'
project(':arcore_client').projectDir = new File('../node_modules/react-viro/android/arcore_client')
project(':gvr_common').projectDir = new File('../node_modules/react-viro/android/gvr_common')
project(':viro_renderer').projectDir = new File('../node_modules/react-viro/android/viro_renderer')
project(':react_viro').projectDir = new File('../node_modules/react-viro/android/react_viro')
//
In my case, the error was coming from my own plugin and I fixed it by adding the following line to my plugin.xml file: (which I found simpler than updating the plugin's gradle file)
<platform name="android">
<preference name="android-compileSdkVersion" value="30" />
...
In my case, I resolved the issue by replacing the old plugin applying syntax:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
with the new plugins DSL in all my build.gradle files:
plugins {
id "com.android.application"
id "kotlin-android"
}
Updating required Package.json libraries worked for me try it out. Most of the error will get resolved.
Remove Jcenter() from build.gradle.
Add this below mention code to your android/build.gradle
First, Save your code and uninstall your Android Studio and install again.
Add this line in your android/build.gradle .
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
allprojects {
configurations.all {
resolutionStrategy {
// Remove this override in 0.66, as a proper fix is included in react-native itself.
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
You don't need to specify android.buildToolsVersion from Build Tools For buildToolsVersion in version 27.0.3 or higher there's no need to specify buildToolsVersion.
Build Tools 27.0.3 or higher. Keep in mind, you no longer need to
specify a version for the build tools using the
android.buildToolsVersion property—the plugin uses the minimum
required version by default.
Source (developer.android.com)
Related
I want to add to my app some ads using AdMob, the site says I need to add Google Services to the dependencies to use this functionality. So with Android Studio I went to File->Project Structure->app->Dependencies, I clicked on the "+" button e searched for "play-services". What I found was "com.google.android.gms:play-services:9.4.0" so I added it to the dependencies. During the gradle sync however Android Studio sends some errors and stops the gradle sync.
This is the log I get form the sync: http://pastebin.com/ZpN4RUcm
Here some data that might be useful:
Compile SDK Version: API 17
Build Tools Version: 23.0.1
Android
Studio 2.1.2
This is my main gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
repositories {
jcenter()
}
}
And this is my app gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:17'
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "com.serpenssolida.glowdodger"
minSdkVersion 10
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:17.0.0'
compile files('libs/processing-core.jar')
compile project(':facebook')
compile 'com.google.android.gms:play-services:9.4.0'
}
How can I get rid of all the errors?
Change your app gradle file as below and try again:
apply plugin: 'com.android.application'
android {
compileSdkVersion '24'
buildToolsVersion '24.0.2'
...
}
Got the problem after updating Android Studio, SDK and tools:
Error:(19, 0) Gradle DSL method not found: 'android()'
Please help to fix it:
Top build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
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
}
}
allprojects {
repositories {
jcenter()
}
}
android {
compileSdkVersion 16
// buildToolsVersion '22.0.1' //23.02.2
}
dependencies {
}
The other one build.gradle (Module:app)file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 16
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.mateuyabar.android.pillownfc"
minSdkVersion 10
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'])
compile 'com.android.support:appcompat-v7:23.0.0'
}
Here is the Error Messages Gradle Sync:
Error:(19, 0) Gradle DSL method not found: 'android()'
Possible causes:
The project 'pillowNFC-master' may be using a version of Gradle that does not contain the method.
-Open Gradle wrapper file
The build file may be missing a Gradle plugin.
-Apply Gradle plugin
Event Log:
11:20:46 Gradle sync started
11:20:48 Gradle sync failed: Gradle DSL method not found: 'android()'
Consult IDE log for more details (Help | Show Log)
I know, this problem was asked before, but I didn't find solution in anothe discussions =(
It would be nice if somebody can help, I'm quite new in programming.
You are using the wrong build.gradle file
In your top-level file you can't use the android block.
Check also this post.
Just remove this part from the first build.gradle
android {
compileSdkVersion 16
// buildToolsVersion '22.0.1' //23.02.2
}
dependencies {
}
Also pay attention.
Since you are using the appcompat v23, you have to compile with API 23.
In your module/build.gradle change the compileSdkVersion to 23
compileSdkVersion 23
I am using https://github.com/wasabeef/richeditor-android library in my android project. I tried adding it into my project by "compile 'jp.wasabeef:richeditor-android:0.3.0'" as mentioned on its page and it works perfectly in my project.
I wish to do some custom changes in that library. So I tried cloning the sample project over there and it is working fine.
But when I try to add the "richeditor" project folder from the sample code in my code and add "compile project('libs:richeditor')" in my app build.gradle and also add "include ':app:libs:richeditor'" in settings.gradle, it throws me an error "Error:Plugin with id 'com.jfrog.bintray' not found.".
P.S. I have put the richeditor project in app/libs/ folder.
How to solve this error or is there any other way I could make some custom changes to the above library?
build.gradle (app)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 17
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
repositories {
mavenCentral()
maven { url 'http://clinker.47deg.com/nexus/content/groups/public' }
jcenter()
}
dependencies {
compile files('libs/isoparser-1.0.2.jar')
compile project('libs:richeditor')
compile('com.fortysevendeg.swipelistview:swipelistview:1.0-SNAPSHOT#aar') {
transitive = true
}
compile 'com.android.support:support-v4:23.0.1'
compile 'com.github.satyan:sugar:1.3'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-plus:8.1.0'
}
build.gradle (richeditor)
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 17
targetSdkVersion 22
}
}
android.libraryVariants.all { variant ->
if (variant.buildType.isDebuggable()) {
return; // Skip debug builds.
}
task("javadoc${variant.name.capitalize()}", type: Javadoc) {
description "Generates Javadoc for $variant.name."
source = variant.javaCompile.source
ext.androidJar = System.getenv("ANDROID_HOME") + "/platforms/${android.compileSdkVersion}/android.jar"
classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)
}
task("bundleJavadoc${variant.name.capitalize()}", type: Jar) {
description "Bundles Javadoc into zip for $variant.name."
classifier = "javadoc"
from tasks["javadoc${variant.name.capitalize()}"]
}
}
apply from: 'android-artifacts.gradle'
apply from: 'central-publish.gradle'
apply from: 'bintray-publish.gradle'
#Jay there is issue on classpath
see the file bintrya-public.gradle
the file apply the plugin 'com.jfrog.bintray'
whose classpath is defined in the file build.gradle
(whose scope is outside of the project/module 'richeditor')
Solution -
Import the module, then
Add
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.3.1'
into the build.gradle file of project under dependencies
Add the below lines into gradle.properties file of project
VERSION_NAME=1.0.0 VERSION_CODE=16 GROUP=jp.wasabeef
ARTIFACT_ID=richeditor-android COMPILE_SDK_VERSION=23
BUILD_TOOLS_VERSION=23.0.2 TARGET_SDK_VERSION=23 MIN_SDK_VERSION=14
POM_DESCRIPTION=RichEditor for Android is a beautiful Rich Text
WYSIWYG Editor POM_URL=https://github.com/wasabeef/richeditor-android
POM_SCM_URL=git#github.com:wasabeef/richeditor-android.git
POM_SCM_CONNECTION=git#github.com:wasabeef/richeditor-android.git
POM_SCM_DEV_CONNECTION=scm:git#github.com:wasabeef/richeditor-android.git POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo POM_DEVELOPER_ID=wasabeef
POM_DEVELOPER_NAME=Wasabeef
POM_DEVELOPER_EMAIL=dadadada.chop#gmail.com
POM_DEVELOPER_URL=wasabeef.jp
ISSUE_URL=https://github.com/wasabeef/richeditor-android/issues
SUPPORT_PACKAGE_VERSION=23.0.1
now, sync the project and enjoy the import
Change from "compile 'jp.wasabeef:richeditor-android:0.3.0'" to compile 'jp.wasabeef:richeditor-android:1.0.0' in build.gradle
See this link: https://github.com/wasabeef/richeditor-android#gradle
I updated android studio from version 1.0 to 1.2.1 and when I started my first application the this appears.
Error:Execution failed for task ':app:compileDebugAidl'.
aidl is missing
I have made sure that all sdk are up to date. This is my gradle build code.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc1"
defaultConfig {
applicationId "com.example.william.myapplication"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
compileSdkVersion 21
}
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:22.2.0'
}
It seems that AndroidStudio-1.3-Preview is using an unexpected version of the gradle plugin. (at least when you create a fresh new project)
Similarly, if you open an existing project using:
an older version of the plugin. (<1.3.0-beta1)
latest build tools (23.0.0-rc1)
compileSDK 22
---> you will probably have this strange error : "aidl is missing" (even in projects not using aidl !)
Solution:
Be sure to use the latest android-gradle-plugin (in the root build.gradle) :
classpath 'com.android.tools.build:gradle:1.3.0-beta1'
under buildscript-->dependencies.
Example :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0-beta1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
and the latest build tools (in module build.gradle):
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc1"
... }
BE AWARE that with this config you are using the latest build tools -not released yet- and the preview of Android-M ---> things can be unstable
I had the same error. I changed the build tools version in the gradle script to my actual sdk build tool version found in sdk manager and that did the trick.
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
...
Just to start I'm very new to android development/android studio/gradle so forgive me if I'm asking a stupid question.
My team has been working on a project with the beta version of android studio, I've just installed the new version (1.0) and i've imported our project from the github remote repo.
When trying to sync the project with gradle i get the error: Gradle version 2.1 is required. Current version is 2.2.1. It recommends that I change the distributionUrl in gradle-2.1 but when I do I get the error that the gradle plugin requires 2.2.1.
The question is why is my project requiring 2.1 and where can I change this?
Here is my gradle.build:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
applicationId "com.<teamName>.<projectName>"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
buildscript{
dependencies{
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
in the gradle-wrapper.properties use the following
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
in build.gradle use
dependencies {
classpath 'com.android.tools.build:gradle:1.0.+'
also replace
runProguard false
with
minifyEnabled true
I hope this can help
I was having the same issue that you were and had made the exact same updates as described in the Google docs.
The error I was making was editing my app module's build.gradle, and not the project's build.gradle in the root of the project folder for the com.android.tools.build version.
Here's the updated PROJECT's build.gradle file that I'm using that works.
// Top-level build file where you can add configuration options common to all sub- projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
ext {
compileSdkVersion = 21
buildToolsVersion = "20.0.0"
minSdkVersion = 15
targetSdkVersion = 21
}
allprojects {
repositories {
jcenter()
}
}
To change the gradle distribution used go to this file: {Project folder}/gradle/wrapper/graddle-wrapper.properties.
Then change the distributionUrl to use 2.1:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip