I started a new app in Kotlin, but when Android Studio finished to build the new project, etc.. is says that cand download the correct version of Kotlin:
Here is the build gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.4-eap-77'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta2'
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 {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and the app gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.xxxxxx.xxxxxx"
minSdkVersion 20
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.0.1'
implementation 'com.android.support:design:26.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.0'
}
How can I fix it to allow download the correct version?
To use a EAP version of the kotlin plugin you have to add the repo in the buildscript block
maven {
url 'https://dl.bintray.com/kotlin/kotlin-eap-1.1'
}
Something like:
buildscript {
ext.kotlin_version = '1.1.4-eap-77'
repositories {
google()
jcenter()
maven {
url 'https://dl.bintray.com/kotlin/kotlin-eap-1.1'
}
}
//...
}
Also you should add the same maven repo to repository block to download the kotlin dependencies.
Something like:
repositories {
google()
jcenter()
maven {
url 'https://dl.bintray.com/kotlin/kotlin-eap-1.1'
}
}
You can find more info here.
Related
I'm trying to mediate my app with MAX and I'm having trouble trying to integrating it on my Gradle file I have followed all the instructions here but I keep the error log below every time I try to build my app :
A problem occurred configuring project ':app'.
> Could not resolve all artifacts for configuration ':app:classpath'.
> Could not find com.applovin.quality:AppLovinQualityServiceGradlePlugin:.
Required by:
project :app
My Gradle file :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://artifacts.applovin.com/android' }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My Gradle App level :
buildscript {
repositories {
google()
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.7'
classpath "com.applovin.quality:AppLovinQualityServiceGradlePlugin:"
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'applovin-quality-service'
applovin {
apiKey "########JW3nelTryi1TlKCldNWG-wtTZGhEz_Tpu-ByT6bsZccJT4rABgGP9HNBQqcmywT7_rMvrl0zQvn"
}
android {
compileSdkVersion 31
defaultConfig {
applicationId "com.wallpapers_8k_Sad.app"
minSdkVersion 19
targetSdkVersion 31
versionCode 8
multiDexEnabled true
versionName "1.08"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.appcompat:appcompat:1.4.1'
compile 'com.facebook.android:audience-network-sdk:6.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'com.google.firebase:firebase-database:20.0.4'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.google.android.material:material:1.5.0'
implementation 'com.google.ads.mediation:facebook:6.8.0.0'
implementation 'com.google.android.gms:play-services-ads:20.6.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.applovin:applovin-sdk:+'
implementation 'com.onesignal:OneSignal:4.3.0'
}
My manifest meta line :
<meta-data android:name="applovin.sdk.key"
android:value="######oRQNDu54FZ1Sr7DocsC0hcs-3ZD91eX-OXTxFK75Qg_EANzzxoKr9lxTdgIh3c-G5os5ykNx2gz4Q5x"/>
N/B - The hashtags added are just added manually to hide my keys.
Found out I needed to add the applovin dependency inside the gradle top level build file adding the specific version as well
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://artifacts.applovin.com/android' }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'com.google.gms:google-services:4.3.10'
classpath "com.applovin.quality:AppLovinQualityServiceGradlePlugin:4.3.7"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have followed this link with no success to solving the issue.
and this Plugin with id 'com.google.gms.google-services' not found
A Screen shot of the error displyed
This is my build.gradle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.1"
defaultConfig {
applicationId "example.technerd.com.firebaseauthentication"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
implementation 'com.google.firebase:firebase-analytics:17.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
apply plugin: 'com.google.gms.google-services'
This is my build.gradle(Project:ProjectName)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
//google()
google() // Google's Maven repository
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
// classpath 'com.google.gms:google-services:4.3.2'
// classpath 'com.google.gms:google-services:4.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
// google()
google() // Google's Maven repository
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
What am I missing or what have I added that is incorrect?
Please help me solve This is my error.
Check the official guide:
In your top-level file you have to add the google play service plugin com.google.gms:google-services:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.google.gms:google-services:4.3.2'
}
}
I am trying to use this library for my app but as it is made in kotlin I am facing the problem . I downloaded the module of this library and imported this module in the project but in the initial state i am gettin kotlin plugin not found so i changed the gradel as this
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
resourcePrefix "yal_ms_"
}
buidscript {
ext.kotlin_version = '1.0.1-2'
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.0.1-2'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:26.1.0"
compile "com.android.support:recyclerview-v7:26.1.0"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
repositories {
mavenCentral()
jcenter()
}
I am trying to use the kotlin library for the first time and I dont know any thing much about kotlin any advice how to use this library will be helpful .
Try Importing this library by gradle
Add maven { url "https://jitpack.io" } to the repositories of project gradle. So it will be like this
build.gradle(Project)
buildscript {
ext.kotlin_version = '1.1.60'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
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 {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and add compile 'com.github.yalantis:multi-selection:v0.1' to dependencies in build.gradle(app)
This may create Manifest Merge Conflicts error while building project to remove that add tools:replace="android:label" under <application> tag in Manifest
I am trying to create a simple Android application. I have the latest version of Android Studio and i think both my gradle build files are correct.
I have placed
implementation 'com.google.android.gms:play-services-maps:11.2.0'
in app gradle dependencies.
Due to this I get the following error:
Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.google.android.gms:play-services-maps:11.2.0.
I have looked at various links and tried out proposed solutions but none have worked for me.
Below are both my gradle build files.
project build.gradle:
//Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://repo.situm.es/artifactory/libs-release-local" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "demo.situm.situmapp"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
//testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
matchingFallbacks = ['release', 'debug']
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services-maps:11.2.0'
//testImplementation 'junit:junit:4.12'
//androidTestImplementation 'com.android.support.test:runner:1.0.1'
//androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'
}
//apply plugin: 'com.google.gms.google-services'
Hope you can help.
Thanks,
Kabir
try this i found:
Failed to resolve com.google.android.gms play-services-auth:11.2.0
Add maven to your root level build.gradle file
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
This maven repo is required starting from 11.2.0.
Or add google() repository to your "build.gradle" file. This gradle method is equivalent to
maven { url "https://maven.google.com" }.
repositories {
jcenter()
google()
}
I'm trying to use Kotlin in a library module without using it in the app module. The app module only uses Java and does not use any Kotlin classes from the library. Gradle won't compile hoever:
Error:(2, 1) A problem occurred evaluating project ':<Library>'.
> Plugin with id 'kotlin-android' not found.
Changes I made to include Kotlin:
{library root} / build.gradle
buildscript {
ext.kotlin_version = '1.1.3-2'
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
...
}
allprojects {
repositories {
jcenter()
}
}
{library root} / {library module} / build.gradle
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
...
dependencies{
...
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
When I add the same to the app module, the project compiles without issue, but I'd like to avoid adding it in the app module because I'd like to use this library in multiple apps without making code changes to those apps
Gradle version used : 3.3
android gradle plugin version: 2.3.3
Edit: #Jushua's answer works, but it still requires to update the project root build.gradle. I was hoping for a solution where only the dependency on the library would have to be added to make the whole thing work.
I am able to do that without any problem.
build.gradle (Project)
buildscript {
ext.kotlin_version = "1.1.4"
repositories {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:2.3.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
build.gradle (app)
apply plugin: "com.android.application"
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
}
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
androidTestCompile("com.android.support.test.espresso:espresso-core:2.2.2", {
exclude group: "com.android.support", module: "support-annotations"
})
compile "com.android.support:appcompat-v7:26.0.1"
testCompile "junit:junit:4.12"
compile project(path: ":library")
}
build.gradle (library)
apply plugin: "com.android.library"
apply plugin: "kotlin-android"
apply plugin: "kotlin-android-extensions"
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
minSdkVersion 17
targetSdkVersion 26
versionCode 13
versionName "1.1.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
}
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
androidTestCompile("com.android.support.test.espresso:espresso-core:2.2.2", {
exclude group: "com.android.support", module: "support-annotations"
})
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile "com.android.support:appcompat-v7:26.0.1"
testCompile "junit:junit:4.12"
}
You just need to add in your module build:
buildscript {
// (Optional) ext.kotlin_version = '1.1.4-3'
repositories {
google()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
and you could either declare the kotlin_version variable in that specific build, or declaring it in the project root build file, since the kotlin version could be updated from other modules:
buildscript {
ext.kotlin_version = '1.1.4-3'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta3'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
You can add buildscript section with kotlin plugins only in your library:
buildscript {
ext.kotlin_version = '1.1.4-2'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: "kotlin-android"
apply plugin: "kotlin-android-extensions"
And now you can include library to application, without modification of root build.gradle
compile project(path: ":library")