Mopub Android Setup: 'Could not find moat-mobile-app-kit' - java

Expected
Building the Android mopub library successfully with the configuration outlined in the Getting Started documentation under the jcenter implementation.
Setup
build.gradle (project)
Included the jcenter and moat-sdk-builds libraries.
buildscript {
ext.kotlin_version = '1.3.11'
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://maven.google.com' }
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha09"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gralde (app)
Included the library mopub-sdk:5.4.1#aar.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "androidx.navigation.safeargs"
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "app.coinverse"
minSdkVersion 27
targetSdkVersion 28
versionCode 15
versionName "0.15"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
sourceSets {
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".staging"
debuggable true
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
}
dataBinding.enabled = true
}
dependencies {
def lifecycle_version = "2.0.0"
def paging_version = "2.0.0"
def nav_version = "1.0.0-alpha09"
def nav_testing_version = "1.0.0-alpha08"
def room_version = "2.0.0"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.cardview:cardview:1.0.0'
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle_version"
implementation "androidx.paging:paging-runtime:$paging_version"
implementation "androidx.paging:paging-rxjava2:$paging_version"
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.firebase:firebase-client-android:2.5.2'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-firestore:17.1.5'
implementation 'com.google.firebase:firebase-functions:16.1.3'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.firebaseui:firebase-ui-firestore:4.2.0'
implementation 'com.firebaseui:firebase-ui-auth:4.2.1'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.4'
implementation 'com.google.firebase:firebase-config:16.1.2'
implementation 'com.jjoe64:graphview:4.2.2'
implementation 'com.google.android.exoplayer:exoplayer-core:2.9.2'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.9.2'
implementation files('libs/YouTubeAndroidPlayerApi.jar')
implementation 'io.reactivex.rxjava2:rxjava:2.2.4'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation "android.arch.navigation:navigation-fragment-ktx:$nav_version"
implementation "android.arch.navigation:navigation-ui-ktx:$nav_version"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-rxjava2:$room_version"
implementation "androidx.room:room-guava:$room_version"
implementation 'com.github.bumptech.glide:glide:4.8.0'
kapt 'com.github.bumptech.glide:compiler:4.8.0'
implementation('com.mopub:mopub-sdk:5.4.1#aar') {
transitive = true
}
// Testing
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
testImplementation "androidx.arch.core:core-testing:$lifecycle_version"
androidTestImplementation "android.arch.navigation:navigation-testing:$nav_testing_version"
testImplementation "androidx.room:room-testing:$room_version"
testImplementation "android.arch.persistence.room:testing:$room_version"
}
Result
The result is the following error when building
Could not find com.moat.analytics.mobile.mpub:moat-mobile-app-kit:2.4.5.
Searched in the following locations:
file:/Users/adamhurwitz/Library/Android/sdk/extras/m2repository/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.pom
file:/Users/adamhurwitz/Library/Android/sdk/extras/m2repository/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.jar
file:/Users/adamhurwitz/Library/Android/sdk/extras/google/m2repository/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.pom
file:/Users/adamhurwitz/Library/Android/sdk/extras/google/m2repository/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.jar
file:/Users/adamhurwitz/Library/Android/sdk/extras/android/m2repository/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.pom
file:/Users/adamhurwitz/Library/Android/sdk/extras/android/m2repository/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.jar
https://dl.google.com/dl/android/maven2/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.pom
https://dl.google.com/dl/android/maven2/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.jar
https://jcenter.bintray.com/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.pom
https://jcenter.bintray.com/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.jar
Attempted Solution
When transitive = true is commented out in Gradle the app builds, runs, and the mopub library is present under the external libraries section.
Does transitive = trueneed to be enabled? If so, how can I resolve the Could not find com.moat.analytics.mobile.mpub:moat-mobile-app-kit error?
implementation('com.mopub:mopub-sdk:5.4.1#aar') {
//transitive = true
}

Issue Fixed With Latest MoPub Version
Find the latest version of MoPub in the documentation here.
build.gradle (project)
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://maven.google.com' }
}
...
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://maven.google.com/' }
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
}
build.gradle (app)
dependencies {
def mopub_version = '+#aar'
implementation("com.mopub:mopub-sdk-native-static:$mopub_version") { transitive = true }
implementation("com.mopub:mopub-sdk-native-video:$mopub_version") { transitive = true }
implementation 'com.facebook.android:audience-network-sdk:5.1.0'
implementation 'com.mopub.mediation:facebookaudiencenetwork:5.1.0.0'
implementation 'com.flurry.android:ads:11.4.0#aar'
implementation 'com.flurry.android:analytics:11.4.0#aar'
implementation 'com.mopub.mediation:flurry:11.4.0.0'
}
Deprecated Solution
I've found the solution in the Twitter Community Forumn thanks to #wacamoe.
Step 1) In gradle-wrapper.properties, ensure you are using distributionUrl=https://services.gradle.org/distributions/gradle-4.10.2-all.zip
Step 2) Ensure that in your application’s gradle script, you have
maven { url “https://s3.amazonaws.com/moat-sdk-builds 26” } in both the buildscript and allprojects sections.

It is not recommended as per the Mopub's offical documentation.
It clearly states -
To add the mopub-sdk dependency, open your project and update the app module’s build.gradle.
repositories {
// ... other project repositories
jcenter() // includes the MoPub SDK and AVID library
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
It clearly mentions to add the dependency in the module-level as oppose to project-level.
For more information on how to add kindly check the link here
A similar issue discussion suggest to update to the latest version which is 5.8 currently and recommended.- Check here
I tried to update the MoPub sdk to the latest with recommended steps and it builds successfully.
My module level gradle is as follows.
apply plugin: 'com.android.application'
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
flatDir {
dirs 'libs-aar'
}
}
dependencies {
//MoPub
implementation('com.mopub:mopub-sdk:5.9.0#aar') {
transitive = true
// exclude module: 'moat-mobile-app-kit' // To exclude Moat
}
implementation 'com.google.ads.mediation:mopub:5.8.0.0'
}
Note: I have commented exclude module statement just to show that it is working while not using the exclude statement otherwise I have removed it from my gradle file.

Related

Failed to resolve: com.github.smrtyvz:ArchedImageProgressBar:2.01

I hope you are fine.
I have problem in android studio, hours and hours I'm trying to implement library of Loading Button or image circular progress ( such as telegram progress ), and this library one of theme, when I try to implement in android studio I get this error message:
Failed to resolve: com.github.smrtyvz:ArchedImageProgressBar:2.01
any solution or suggestion ?
this is my root build.Gradle
buildscript {
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url "https://repo.commonsware.com.s3.amazonaws.com" }
maven {url "https://maven.springframework.org/release"}
maven { url "https://maven.restlet.com" }
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0'
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.google.gms:google-services:4.3.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 28
defaultConfig {
applicationId "blocks.youtube.hichem.soft"
minSdkVersion 21
targetSdkVersion 28
versionCode 2
versionName "1.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.4.0-alpha02'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.google.firebase:firebase-database:19.7.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.android.support:design:28.0.0'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
implementation 'com.google.firebase:firebase-storage:19.2.2'
implementation platform('com.google.firebase:firebase-bom:26.3.0')
implementation 'com.google.firebase:firebase-database-ktx'
implementation 'com.google.firebase:firebase-storage:19.2.2'
implementation 'com.github.smrtyvz:ArchedImageProgressBar:2.01'
}
the Link of Library in github ;
https://github.com/smrtyvz/ArchedImageProgressBar
whats wrong ??
You forgot to add this in your root build.gradle:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Try putting
repositories {
maven { url 'https://jitpack.io' }
}
in the root of your Gradle build file (outside of the buildscript tag).

Error Installing Google Maps SDK Beta 3.1.0 Could not filnd :places-map-sdk-3.1.0-beta:

I am attempting to install the Google Maps SDK and decided to use the current beta version. I have followed all the installation instructions, but am getting the following error when rebuilding the project.
Execution failed for task ':app:checkDebugAarMetadata'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find :places-maps-sdk-3.1.0-beta:.
Required by:
project :app
The installation downloaded file places-maps-sdk-3.1.0-beta.aar has been placed in the projects app\libs folder.
[![enter image description here][1]][1]
Attached is my project level gradle build
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.grgapps.checkingin"
minSdkVersion 26
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'
}
customDebugType {
debuggable true
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.navigation:navigation-fragment:2.3.1'
implementation 'androidx.navigation:navigation-ui:2.3.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.gms:play-services-ads:19.5.0'
implementation 'com.google.firebase:firebase-ads:19.5.0'
implementation 'androidx.work:work-runtime:2.5.0-beta01'
implementation 'androidx.preference:preference:1.1.1'
//implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation "androidx.viewpager2:viewpager2:1.0.0"
implementation 'com.google.firebase:firebase-analytics:18.0.0'
implementation "com.google.firebase:firebase-messaging:21.0.0"
implementation 'com.google.android.libraries.maps:maps:3.1.0-beta'
// If you are using Places, add all of the dependencies below
implementation name:'places-maps-sdk-3.1.0-beta', ext:'aar'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
implementation 'com.google.auto.value:auto-value-annotations:1.6.5'
implementation 'com.google.maps.android:android-maps-utils-v3:2.2.0'
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation('com.mikepenz:materialdrawer:5.9.5#aar') {
transitive = true
exclude group: 'com.android.support'
}
// Room components
implementation "androidx.room:room-runtime:2.2.5"
annotationProcessor "androidx.room:room-compiler:2.2.5"
androidTestImplementation "androidx.room:room-testing:2.2.5"
// Lifecycle components
implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.archLifecycleVersion"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$rootProject.archLifecycleVersion"
// UI
implementation "com.google.android.material:material:1.2.1"
// Testing
androidTestImplementation "androidx.arch.core:core-testing:$rootProject.coreTestingVersion"
}
The following is my top level build gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.google.gms:google-services:4.3.3'
// 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
}
ext {
roomVersion = '2.2.5'
archLifecycleVersion = '2.2.0-rc03'
coreTestingVersion = '2.1.0'
materialVersion = '1.2.1'
}
I found that instead of using the line they have in their documentation for the build.gradle file:
implementation name:'places-maps-sdk-3.1.0-beta', ext:'aar'
If I use this line, it syncs up fine:
implementation group: 'com.google.android.libraries.maps', name: 'maps', version: '3.1.0-beta'
I am FAR from a Gradle expert, so I am not quite sure what the differences here are - but after changing over imports and all, my app built and seemed to operate fine.

Could not find matching constructor for: org.gradle.api.internal.artifacts.ivyservice.ivyresolve.VersionInfo(java.lang.String)

I'm working on an Android Studio project and today when i opened it up all of a sudden this started happening.
Could not find matching constructor for: org.gradle.api.internal.artifacts.ivyservice.ivyresolve.VersionInfo(java.lang.String)
I've already tried to change the gradle versions around but nothing works. Also, I've tried the classic "clean project", "rebuild project" and "invalidate caches and restart"
gradle.properties
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.or g/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
app level gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.25.4'
}
}
plugins {
id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.7.0'
}
apply plugin: 'com.android.application'
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
android {
dataBinding {
enabled = false
}
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.virtualflight.VirtualHub"
minSdkVersion 19
targetSdkVersion 28
versionCode 58
versionName "4.0.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
android {
vectorDrawables.useSupportLibrary = true
defaultConfig.applicationId="com.virtualflight.VirtualHub"
defaultConfig {
manifestPlaceholders = [onesignal_app_id: "977e8aef-4b31-4d36-91e4-2555572b9efe",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "REMOTE"]
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
customDebugType {
debuggable true
}
}
productFlavors {
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.1-alpha01', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//Google dependencies bellow
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.intuit.sdp:sdp-android:1.0.6'
implementation 'com.sothree.slidinguppanel:library:3.4.0'
testImplementation 'junit:junit:4.12'
//Mapbox dependencies bellow
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:6.8.1'
implementation 'com.mapbox.mapboxsdk:mapbox-android-services:2.1.0'
implementation 'com.mapbox.mapboxsdk:mapbox-java-core:2.1.0'
implementation 'com.mapbox.mapboxsdk:mapbox-java-services:2.1.0'
implementation 'com.mapbox.mapboxsdk:mapbox-java-services-rx:2.1.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-services:2.1.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-telemetry:3.5.7'
implementation 'com.mapbox.mapboxsdk:mapbox-android-ui:2.1.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true;
}
implementation files('libs/volley.jar')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.github.barteksc:android-pdf-viewer:3.1.0-beta.1'
implementation 'com.karumi:dexter:5.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha04'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha02'
implementation 'com.github.AppIntro:AppIntro:v5.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
}
project level gradle
buildscript {
ext.kotlin_version = '1.2.51'
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
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()
maven { url "https://jitpack.io" }
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I realised that OneSignal was causing the issue. I have "solved" this by removing OneSignal as a whole as I wasn't using that anymore.
Downgrade your gradle version below to 4.9

Error:(9, 0): 'google()' Gradle DSL method not found

hi after i slove my problem in this question this
after building i receive this one
Error:This Gradle plugin requires Studio 3.0 minimum
then i update gradle-wrapper.properties to 3.3
i receive this
Error:(9, 0): 'google()' Gradle DSL method not found
here is my build gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven {
url 'https://maven.google.com'
}
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
/* CHANGE to classpath 'com.android.tools.build:gradle:2.3.3' for STABLE BUILD TOOL VERSION*/
// classpath 'com.android.tools.build:gradle:3.0.0-alpha7'
// classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.0.0-beta1'
classpath 'com.google.gms:google-services:3.1.0'
// We recommend changing it to the latest version from our changelog:
// https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
classpath 'io.fabric.tools:gradle:1+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
// google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and this is build gradle module app
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven {
url 'https://maven.google.com'
}
// google()
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 25
buildToolsVersion '26.0.0'
defaultConfig {
applicationId "in.techware.lataxi"
minSdkVersion 15
targetSdkVersion 25
versionCode 5
versionName "1.0.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
/* Remove This to remove Crashlytics and Fabric */
/* compile('com.crashlytics.sdk.android:crashlytics:2.6.7#aar') {
transitive = true;
}*/
/* compile('com.digits.sdk.android:digits:2.0.6#aar') {
transitive = true;
}*/
implementation 'com.android.support:appcompat-v7:25.4.0'
implementation 'com.android.support:design:25.4.0'
implementation 'com.android.support:recyclerview-v7:25.4.0'
implementation 'com.squareup.okhttp3:okhttp:3.8.1'
implementation 'com.android.support:cardview-v7:25.4.0'
implementation 'com.github.bumptech.glide:glide:3.8.0'
implementation 'com.google.android.gms:play-services-maps:11.0.2'
implementation 'com.google.android.gms:play-services-location:11.0.2'
implementation 'com.google.android.gms:play-services-places:11.0.2'
implementation 'com.google.firebase:firebase-auth:11.0.2'
implementation 'com.google.firebase:firebase-messaging:11.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta1'
implementation 'com.google.code.gson:gson:2.8.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
The google() repo requires also gradle v4 and Android Studio 3.x.
Try to use in gradle-wrapper.properties
distributionUrl=\
https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip
In any case you can use the same maven repo using { url 'https://maven.google.com'} (it is the same).
buildscript {
repositories {
maven {
url 'https://maven.google.com'
}
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
//
}

How to organise Gradle for Spring, Android and Plain JAR?

I want to have a project with 3 submodules as follows:
proj:spring
proj:plainjava
proj:android
proj:android:app
Where plainjava is a jar that is installed in the local repository. spring + android:app are dependant on it.
Currently if I try running gradle from the root directory or import it to the ide's, it results in various errors.
Execution failed for task ':android:app:compileDebugJavaWithJavac'.
Running separate task for android builds fine.
As I have figured out I need the following tasks to execute for the whole build in the following order:
proj:plainjava:publishMavenJavaPublicationToMavenLocal
proj:spring:bootRepackage
??? Task To build android succesfully, currently builds in android studio explicitly.
For the development purposes I also need to execute each task on it's own. Running
proj:spring:bootRepackage
Somehow triggers dependency resolution for the android, app and plainjava
actual files:
proj settings.gradle
include 'commonobjects', 'server', 'android', 'android:app'
proj build.gradle, has specific custom tasks that allow ci to build artifacts.
task myCleanLibraries {}
myCleanLibraries.dependsOn ':commonobjects:clean'
task myPublishLibraries {}
myPublishLibraries.dependsOn ':commonobjects:publishToMavenLocal'
task myCleanRest {}
myCleanRest.dependsOn ':server:clean', ':android:app:clean'
task myBuildRest {}
myBuildRest.dependsOn ':server:build', ':android:app:assembleDebug'
task myLibraries {}
myLibraries.dependsOn 'myCleanLibraries', 'myPublishLibraries'
myPublishLibraries.mustRunAfter 'myCleanLibraries'
task myRest {}
myRest.dependsOn 'myCleanRest', 'myBuildRest'
myBuildRest.mustRunAfter 'myCleanRest'
task myAll {}
myAll.dependsOn 'myLibraries', 'myRest'
myRest.mustRunAfter 'myLibraries'
proj:spring build.gradle
group 'com.example'
version '0.0.VERSIONNUMBER'
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
defaultTasks 'clean', 'build'
buildscript {
ext {
springBootVersion = '1.5.1.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
jar {
baseName = 'server'
version = '0.0.9999'
}
sourceCompatibility = 1.8
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter-security'
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
compile 'org.springframework.boot:spring-boot-starter-logging'
compile 'org.projectlombok:lombok'
compile 'io.jsonwebtoken:jjwt:0.7.0'
compile 'mysql:mysql-connector-java:6.0.5'
compile 'com.example:commonobjects:0.0.9999'
testCompile 'org.springframework.boot:spring-boot-starter-test'
}
proj:commonobjects settings.gradle
rootProject.name = 'commonobjects'
proj:commonobjects build.gradle
group 'com.example'
version '0.0.9999'
apply plugin: 'java'
apply plugin: 'maven-publish'
jar {
baseName = 'commonobjects'
version = '0.0.9999'
}
repositories {
mavenCentral()
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
mavenLocal()
}
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
testCompile 'junit:junit:4.11'
}
proj:android settings.gradle
include ':app'
proj:android build.gradle
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
}
}
proj:android:app build.gradle
def ANDROID_SUPPORT_DEPENDENCY_VERSION = '25.1.0'
def DAGGER_DEPENDENCY_VERSION = '2.10'
def OK_HTTP_DEPENDENCY_VERSION = '3.7.0'
def RETROFIT_DEPENDENCY_VERSION = '2.1.0'
def RETROFIT_JACKSON_DEPENDENCY_VERSION = '2.1.0'
def BUTTER_KNIFE_DEPENDENCY_VERSION = '8.5.1'
def JAVAX_ANNOTATION_JSR250_API_DEPENDENCY_VERSION = '1.0'
def GREEN_ROBOT_EVENT_BUS_DEPENDENCY_VERSION = '3.0.0'
def RX_JAVA_DEPENDENCY_VERSION = '2.0.5'
def RX_ANDROID_JAVA_DEPENDENCY_VERSION = '2.0.1'
defaultTasks 'clean', 'assembleDebug'
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "net.ltgt.gradle:gradle-apt-plugin:0.9"
classpath "com.android.tools.build:gradle:2.3.1"
}
}
repositories {
jcenter()
mavenLocal()
mavenCentral()
}
apply plugin: "com.android.application"
apply plugin: "idea"
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "myandroidappid"
minSdkVersion 14
targetSdkVersion 25
versionCode 9999
versionName "0.0.9999"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
// debug {
// buildConfigField "String", "PARSE_APPLICATION_ID", "\"1\""
// buildConfigField "String", "PARSE_API_KEY", "\"1\""
// }
release {
minifyEnabled true
proguardFiles "android-proguard-android.txt", "proguard-rules.txt"
// buildConfigField "String", "PARSE_APPLICATION_ID", "\"1\""
// buildConfigField "String", "PARSE_API_KEY", "\"1\""
}
}
packagingOptions {
pickFirst 'META-INF/LICENSE'
}
}
dependencies {
// Add jars supplied
compile fileTree(dir: 'libs', include: ['*.jar'])
// Test related
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
androidTestCompile 'com.google.code.findbugs:jsr305:3.0.1'
androidTestCompile "com.android.support:support-annotations:${ANDROID_SUPPORT_DEPENDENCY_VERSION}"
androidTestCompile "com.android.support.test:runner:0.5"
// MYOSCA dependencies
compile('com.example:commonobjects:0.0.9999')
// Android support libraries
compile "com.android.support:appcompat-v7:${ANDROID_SUPPORT_DEPENDENCY_VERSION}"
compile "com.android.support:design:${ANDROID_SUPPORT_DEPENDENCY_VERSION}"
compile "com.android.support:support-annotations:${ANDROID_SUPPORT_DEPENDENCY_VERSION}"
// An HTTP & HTTP/2 client for Android and Java applications
compile "com.squareup.okhttp3:okhttp:${OK_HTTP_DEPENDENCY_VERSION}"
// Retrofit: A type-safe HTTP client for Android and Java
compile "com.squareup.retrofit2:retrofit:${RETROFIT_DEPENDENCY_VERSION}"
compile "com.squareup.retrofit2:converter-jackson:${RETROFIT_JACKSON_DEPENDENCY_VERSION}"
// Butterknife: Field and method binding for Android views
compile "com.jakewharton:butterknife:${BUTTER_KNIFE_DEPENDENCY_VERSION}"
annotationProcessor "com.jakewharton:butterknife-compiler:${BUTTER_KNIFE_DEPENDENCY_VERSION}"
// Dagger DI
compile "com.google.dagger:dagger:${DAGGER_DEPENDENCY_VERSION}"
annotationProcessor "com.google.dagger:dagger-compiler:${DAGGER_DEPENDENCY_VERSION}"
compile "com.google.dagger:dagger-android:${DAGGER_DEPENDENCY_VERSION}"
annotationProcessor "com.google.dagger:dagger-android-processor:${DAGGER_DEPENDENCY_VERSION}"
compile "com.google.dagger:dagger-android-support:${DAGGER_DEPENDENCY_VERSION}"
compile "com.google.dagger:dagger:${DAGGER_DEPENDENCY_VERSION}"
annotationProcessor "com.google.dagger:dagger-compiler:${DAGGER_DEPENDENCY_VERSION}"
provided "javax.annotation:jsr250-api:${JAVAX_ANNOTATION_JSR250_API_DEPENDENCY_VERSION}"
// Event bus
compile "org.greenrobot:eventbus:${GREEN_ROBOT_EVENT_BUS_DEPENDENCY_VERSION}"
// RxJava a library for composing asynchronous and event-based programs by using observable sequences.
compile "io.reactivex.rxjava2:rxjava:${RX_JAVA_DEPENDENCY_VERSION}"
compile "io.reactivex.rxjava2:rxandroid:${RX_ANDROID_JAVA_DEPENDENCY_VERSION}"
// Google Guava for preconditions
compile 'com.google.guava:guava:20.0'
}
Full solution available at: repo
Thanks for posting your build.gradle files. I believe your `settings.gradle is where you should start.
Since you want/have these modules in your current setup:
proj:spring
proj:plainjava
proj:android
proj:android:app
Let's map them to gradle modules:
proj/
|-spring/
|-build.gradle
|-plain-java/ <-- better naming conventions by separating names
|-build.gradle
|-android/
|-build.gradle
|-build.gradle <-- make sure to have root build.gradle
|-settings.gradle <-- should be root folder(proj)
Lets do the following:
rename the folder "plainjava" to "plain-java"
lets merge the "android/app" folder into just an "android"
this let's us consolidate everything down to just 3 projects
New settings.gradle:
rootProject.name = "proj"
include ":spring"
include ":plain-java"
include ":android"
Last thing, in your root directory, make move your buildscript dependencies in there so you can build from that directory.

Categories

Resources