Moodle for mobile

Generate APK on Ubuntu 18.04 LTS

 
Picture of João Vitor Teixeira
Generate APK on Ubuntu 18.04 LTS
 
hi, i'm trying generate an APK of the moodle mobile 2, however some errors are happening [https://docs.moodle.org/dev/Setting_up_your_development_environment_for_Moodle_Mobile_2#Building_for_Android_and_iOS]]... My operational system is Ubuntu 18.04... Node: 8.10.0; Npm: 6.4.1; Ionic CLI: 4.3.1; ionic-app-scripts 3.1.9; when i tried to generate the APK this happened this: cordova-android-support-gradle-release: Android platform: V7.0.0-7.1.1 cordova-android-support-gradle-release: Wrote custom version '27.1.0' to /home/jvteix/Documentos/Desenvolvimento/TESTE/TESTE_Mobile/moodleIonic/platforms/android/app/build.gradle cordova-android-support-gradle-release: Wrote custom version '27.1.0' to /home/jvteix/Documentos/Desenvolvimento/TESTE/TESTE_Mobile/moodleIonic/platforms/android/app/cordova-android-support-gradle-release/properties.gradle Android Studio project detected cordova-android-support-gradle-release: Android platform: V7.0.0-7.1.1 cordova-android-support-gradle-release: Wrote custom version '27.1.0' to /home/jvteix/Documentos/Desenvolvimento/TESTE/TESTE_Mobile/moodleIonic/platforms/android/app/build.gradle cordova-android-support-gradle-release: Wrote custom version '27.1.0' to /home/jvteix/Documentos/Desenvolvimento/TESTE/TESTE_Mobile/moodleIonic/platforms/android/app/cordova-android-support-gradle-release/properties.gradle ANDROID_HOME=/home/jvteix/Android/Sdk JAVA_HOME=/usr/lib/jvm/java-surpriseracle studio Subproject Path: CordovaLib Subproject Path: app publishNonDefault is deprecated and has no effect anymore. All variants are now published. Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead. The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead. at build_9glb3j1j5ykoq49b1okx3blia.run(/home/jvteix/Documentos/Desenvolvimento/TESTE/TESTE_Mobile/moodleIonic/platforms/android/app/build.gradle:145) :CordovaLib:preBuild UP-TO-DATE :CordovaLib:preDebugBuild UP-TO-DATE :CordovaLib:compileDebugAidl UP-TO-DATE :CordovaLib:compileDebugRenderscript UP-TO-DATE :CordovaLib:checkDebugManifest UP-TO-DATE :CordovaLib:generateDebugBuildConfig UP-TO-DATE :CordovaLib:prepareLintJar UP-TO-DATE :CordovaLib:generateDebugResValues UP-TO-DATE :CordovaLib:generateDebugResources UP-TO-DATE :CordovaLib:packageDebugResources UP-TO-DATE :CordovaLib:platformAttrExtractor UP-TO-DATE :CordovaLib:processDebugManifest UP-TO-DATE :CordovaLib:processDebugResources UP-TO-DATE :CordovaLib:generateDebugSources UP-TO-DATE :CordovaLib:javaPreCompileDebug UP-TO-DATE :CordovaLib:compileDebugJavaWithJavac UP-TO-DATE :CordovaLib:processDebugJavaRes NO-SOURCE :CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug UP-TO-DATE :app:preBuild UP-TO-DATE :app:preDebugBuild FAILED FAILURE: Build failed with an exception. * What went wrong: Could not resolve all files for configuration ':app:debugCompileClasspath'. > Could not find play-services-basement.aar (com.google.android.gms:play-services-basement:15.0.1). Searched in the following locations: https://jcenter.bintray.com/com/google/android/gms/play-services-basement/15.0.1/play-services-basement-15.0.1.aar * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. * Get more help at https://help.gradle.org BUILD FAILED in 2s 14 actionable tasks: 1 executed, 13 up-to-date /home/jvteix/Documentos/Desenvolvimento/TESTE/TESTE_Mobile/moodleIonic/platforms/android/gradlew: Command failed with exit code 1 Error output: FAILURE: Build failed with an exception. * What went wrong: Could not resolve all files for configuration ':app:debugCompileClasspath'. > Could not find play-services-basement.aar (com.google.android.gms:play-services-basement:15.0.1). Searched in the following locations: https://jcenter.bintray.com/com/google/android/gms/play-services-basement/15.0.1/play-services-basement-15.0.1.aar * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. * Get more help at https://help.gradle.org BUILD FAILED in 2s
 
Average of ratings: -
Picture of Mark Webster
Re: Generate APK on Ubuntu 18.04 LTS
 

In your platforms/android/build.gradle file you need to move the 2 instances of jcenter() to below the maven entries. It looks for the play-services-basement.aar file in jcenter first, doesn't find it, so just fails. Moving jcenter to below maven fixes this (examples below)

Before

buildscript {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.android.tools.build:gradle:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
    //This replaces project.properties w.r.t. build settings
    project.ext {
      defaultBuildToolsVersion="25.0.2" //String
      defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
      defaultTargetSdkVersion=26 //Integer - We ALWAYS target the latest by default
      defaultCompileSdkVersion=26 //Integer - We ALWAYS compile with the latest by default
    }
}

After

buildscript {
    repositories {
        maven {
            url "https://maven.google.com"
        }
        jcenter()
    }
    dependencies {

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.android.tools.build:gradle:3.0.0'
    }
}

allprojects {
    repositories {
        maven {
            url "https://maven.google.com"
        }
        jcenter()
    }
    //This replaces project.properties w.r.t. build settings
    project.ext {
      defaultBuildToolsVersion="25.0.2" //String
      defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
      defaultTargetSdkVersion=26 //Integer - We ALWAYS target the latest by default
      defaultCompileSdkVersion=26 //Integer - We ALWAYS compile with the latest by default
    }
}
 
Average of ratings: -
Picture of João Vitor Teixeira
Re: Generate APK on Ubuntu 18.04 LTS
 

like this?



now this has occurred(file in the attachment).


 
Average of ratings: -
Picture of Mark Webster
Re: Generate APK on Ubuntu 18.04 LTS
 

In project.properties (in the same folder) change every instance of com.android.support:support-v4: and com.android.support:support-v13: to be 27.1.0.

cordova-android-support-gradle-release should take care of this in theory, but doesn't seem to. mine ended up looking like:

target=android-27
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.system.library.1=com.android.support:support-v4:27.1.0
cordova.gradle.include.1=phonegap-plugin-push/moodlemobile-push.gradle
cordova.system.library.2=com.android.support:support-v13:27.1.0
cordova.system.library.3=com.google.android.gms:play-services-gcm:15+
cordova.system.library.4=me.leolin:ShortcutBadger:1.1.14@aar
cordova.system.library.5=com.android.support:support-v4:27.1.0
cordova.system.library.6=com.android.support:support-v4:27.1.0
cordova.system.library.7=com.android.support:support-v4:27.1.0
cordova.gradle.include.2=cordova-plugin-badge/moodlemobile-badge.gradle
cordova.gradle.include.3=cordova-android-support-gradle-release/moodlemobile-cordova-android-support-gradle-release.gradle

This is because version 28 introduced some breaking changes, and every time there is a + after a version number in that file it'll grab the latest version.

I also changed my target version in config.xml (in project root) to 27, but I don't think that is related to this error.

 
Average of ratings: -
Picture of João Vitor Teixeira
Re: Generate APK on Ubuntu 18.04 LTS
 

Thank you, it was!

 
Average of ratings: -