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.
Related
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
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.
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' }
}
//
}
project gradle
// 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:3.0.0-alpha3'
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 {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.arun4fms.efix"
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
}
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'
})
compile 'com.google.firebase:firebase-database:10.2.0'
compile 'com.google.firebase:firebase-crash:10.2.0'
compile 'com.google.firebase:firebase-auth:10.2.0'
compile 'com.chabbal:slidingdotsplash:1.0.2'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Error:A problem occurred configuring root project 'webapp'.
Could not resolve all dependencies for configuration ':classpath'.
Could not find com.android.tools.build:gradle:3.0.0-alpha3.
Searched in the following locations:
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.pom
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.jar
Required by:
project :
As already answered here:
Google have new maven repo, so it could be the reason.
https://android-developers.googleblog.com/2017/05/android-studio-3-0-canary1.html
section Google's Maven Repository
https://developer.android.com/studio/preview/features/new-android-plugin-migration.html
https://developer.android.com/studio/build/dependencies.html#google-maven
Add Google’s Maven Repository to the buildscript repositories section to fix it like #KG87 did here.
buildscript {
repositories {
jcenter()
maven { url "https://maven.google.com" } // Add this line to fix it
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
...
}
}
As explained here:
The repositories in the buildScript block are used to fetch the
dependencies of your buildScript dependencies. These are the
dependencies that are put on the classpath of your build and that you
can refer to from your build file. For instance, extra plugins that
exist on the internet.
The repositories on the root level are used to fetch the dependencies
that your project depends on. So all the dependencies you need to
compile your project.
And here:
The buildScript block determines which plugins, task classes, and
other classes are available for use in the rest of the build script.
Without a buildScript block, you can use everything that ships with
Gradle out-of-the-box. If you additionally want to use third-party
plugins, task classes, or other classes (in the build script!), you
have to specify the corresponding dependencies in the buildScript
block.
As announced here:
The Android Gradle Plugin 3.0.0-alpha3 was also released through
maven.google.com.
So, try to fix it by adding Google’s Maven Repository.
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Also add the repository here for other dependencies like the support libraries like this:
Make sure that the repositories section includes a maven section with
the "https://maven.google.com" endpoint. For example:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
The difference is explained here
The "buildscript" block only controls dependencies for the buildscript
process itself, not for the application code, which the top-level
"dependencies" block controls.
For instance, you could define dependencies in "buildscript/classpath"
that represent Gradle plugins used in the build process. Those plugins
would not be referenced as dependencies for the application code.
As commented here by #lugegege, this version doesn't exist in Bintray JCenter:
com.android.tools.build.gradle
latest version is 2.5.0-alpha-preview-02, there is no 3.0.0-alpha3
com.android.tools.build.gradle latest version is 2.5.0-alpha-preview-02, there is no 3.0.0-alpha3
Use this.. This may work because this worked in my case:
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
}
and put this at the end of the app-level build.gradle file (after the dependencies).
apply plugin: 'com.google.gms.google-services'
I have no clue why putting this at the end (and not at the beginning ) solves the error.
Ok… So trying to put an end to all problems you guys have faced with my solution
This is my final app level gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "your-app-name"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
repositories {
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:design:23.1.1'
compile 'com.mcxiaoke.volley:library:1.0.6#aar'
}
apply plugin: 'com.google.gms.google-services'
and this is my final project level gradle
// 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:2.0.0-alpha3'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Compare this with your own gradle files, and add or modify any values which are different from what I've written.
I had the same problem this morning !
As Vishal said, there is no gradle-3.0.0-alpha3..
I am sure that, since I downloaded "Android studio 3.0 Canary (Alpha3)", I was on on the same version of gradle (3.0.0 alpha3), and it worked ! (Since today).
So I've put : classpath 'com.android.tools.build:gradle:2.3.2' to compile.
EDIT : I have two versions of Android studio, When I used Android Studio 3.0, it changes gradle to gradle 3.0.0-alpha3 !
write these gradles..
compile 'com.android.support:appcompat-v7:25.0.2'
compile 'com.android.support:design:25.0.2'
classpath 'com.android.tools.build:gradle:2.2.3'
I'm developing an Android library, and want to use the new Android Room persistence library inside it. However, when launching I got this error :
Caused by: java.lang.RuntimeException: cannot find implementation for
MyLibraryName.Database.QSDatabase. QSDatabase_Impl does not exist
at android.arch.persistence.room.Room.getGeneratedImplementation(Room.java:90)
which means that the annotationProcessor is not generating the extra code during compilation.
Btw, everything is working fine when I put my #Database code inside the app module.
My gradle file (library module) :
apply plugin: 'com.android.library'
apply plugin: 'groovyx.android'
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'org.codehaus.groovy:groovy-android-gradle-plugin:1.1.0'
}
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.0'
}
}
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { java.srcDirs = ['src/main/java', 'src/main/groovy'] } }
}
dependencies {
// google Room persistence library
compile "android.arch.persistence.room:runtime:1.0.0-alpha1"
annotationProcessor "android.arch.persistence.room:compiler:1.0.0-alpha1"
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'
})
// google location service
compile 'com.google.android.gms:play-services-location:10.2.4'
androidTestCompile 'junit:junit:4.12'
// Http
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
compile 'com.squareup.retrofit2:converter-scalars:2.1.0'
// groovy
compile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.4.4'
}
This can happen when you use annotationProcessor in a kotlin project.
if so, do these
apply plugin: 'kotlin-kapt'
and use kapt instead of annotationProcessor
#stevenwood It seems you're right about groovy/
I had the same project structure. But in my case, I had no real Groovy code inside groovy/. Only plain old Java code. Hence, perhaps it was easier for me to get the project working again by making the following changes
Removing / commenting-out classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.8' from the project's build.gradle
Removing / commenting-out apply plugin: 'groovyx.grooid.groovy-android' from the module's build.gradle
git mv groovy/ java/
Thereafter at least, I stopped getting the missing Database_Impl message from Room.