3

I already added the android.gradleDep build hint with the proper "compile'....' " hint for the 3rd party library I want to integrate. (In this case, Firebase).

In the root-level build.gradle file in a Codename One Android app, how can I:

  1. add a classpath dependency to the buildscript section?
  2. add a maven dependency in the allprojects section?

EDIT: 3. Add a plugin, such as: apply plugin: 'com.google.gms.google-services'

For a visual example:

    buildscript {
         dependencies {
             classpath 'com.google.gms:google-services:3.1.0' // google-services plugin
         }
    }

    allprojects {
        dependencies {
            maven {
                url "https://maven.google.com" // Google's Maven repository
           } 
        }
    }

I have looked at CN1's page on Build hints but don't know what to do next to import this library. Without these changes, I get the following build error:

Resource missing. [HTTP GET: https://jcenter.bintray.com/com/google/firebase/firebase-
core/11.2.0/firebase-core-11.2.0.pom]
Resource missing. [HTTP HEAD: https://jcenter.bintray.com/com/google/firebase/firebase-
core/11.2.0/firebase-core-11.2.0.jar]

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'MyApp'.
> Could not resolve all dependencies for configuration ':_debugCompile'.
> Could not find com.google.firebase:firebase-core:11.2.0.
 Searched in the following locations:
     https://jcenter.bintray.com/com/google/firebase/firebase-core/11.2.0/firebase-core-11.2.0.pom
     https://jcenter.bintray.com/com/google/firebase/firebase-core/11.2.0/firebase-core-11.2.0.jar
     file:/tmp/build1801628445736809063xxx/MyApp/libs/firebase-core-11.2.0.jar
     file:/tmp/build1801628445736809063xxx/MyApp/libs/firebase-core.jar
     file:/home/ec2-user/android-sdk/extras/android/m2repository/com/google/firebase/firebase-core/11.2.0/firebase-core-11.2.0.pom
     file:/home/ec2-user/android-sdk/extras/android/m2repository/com/google/firebase/firebase-core/11.2.0/firebase-core-11.2.0.jar
     file:/home/ec2-user/android-sdk/extras/google/m2repository/com/google/firebase/firebase-core/11.2.0/firebase-core-11.2.0.pom
     file:/home/ec2-user/android-sdk/extras/google/m2repository/com/google/firebase/firebase-core/11.2.0/firebase-core-11.2.0.jar

EDIT In the .properties file, I have:

  codename1.arg.android.repositories=maven { url "https\://maven.google.com" };

  codename1.arg.android.gradleDep=compile 'com.google.gms\:google-services\:3.1.0', compile 'com.google.firebase\:firebase-core\:11.2.0'

I am getting the following error message:

FAILURE: Build failed with an exception.

* Where:
 Build file '/tmp/build1791213618910744158xxx/MyApp/build.gradle' line: 78

* What went wrong:
A problem occurred evaluating root project 'MyApp'.
 > Could not find property 'compile' on org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@59ed76e3.
Community
  • 1
  • 1
app-dev
  • 348
  • 1
  • 2
  • 12

1 Answers1

3

You can add the build-hint that points to your repo URL as well. In your case:

android.gradleDep=compile 'com.google.gms:google-services:3.1.0'
android.repositories=maven { url "https\://maven.google.com" };
Diamond
  • 7,428
  • 22
  • 37
  • Shouldn't `android.repositories` be in the format: `url "https://maven.google.com"` ? Not sure as I haven't tried it – Shai Almog Sep 13 '17 at 04:17
  • Thanks. I added the gradleDep and repositories build hints but am still getting this error: `FAILURE: Build failed with an exception.` `* Where: Build file '/tmp/build8599803583121854062xxx/MyApp/build.gradle' line: 63` * What went wrong: `A problem occurred evaluating root project 'MyApp'.` `> Could not find method https://maven.google.com() for arguments [org.gradle.api.internal.artifacts.repositories.DefaultFlatDirArtifactRepository_Decorated@45fcaf92] on root project 'MyApp'.` Any ideas? I tried with and without adding url to repositories hint. Thanks. – app-dev Sep 13 '17 at 15:09
  • Thanks @Diamond. I edited the repositories hint to `maven { url "https://maven.google.com" }` which took care of the other errors, but now I see this: `> Could not find method flatDir() for arguments [build_862rdqnp94p5hh7gqskg482ct$_run_closure2$_closure16@64afba05] on org.gradle.api.internal.artifacts.repositories.DefaultMavenArtifactRepository_Decorated@2b486e68.` What can I do to fix this? – app-dev Sep 13 '17 at 15:23
  • include the "`;`", backslash and spaces `maven { url "https\://maven.google.com" };` – Diamond Sep 13 '17 at 15:25
  • Done. `> Could not find property 'compile' on org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@59ed76e3.` ??? – app-dev Sep 13 '17 at 15:28
  • How are you adding the build-hints? If you are editing the `.properties` file directly, make sure you input this in full: `codename1.arg.android.gradleDep=compile 'com.google.gms:google-services:3.1.0'` and `codename1.arg.android.repositories=maven { url "https\://maven.google.com" };` – Diamond Sep 13 '17 at 15:31
  • Remove the second `compile` – Diamond Sep 13 '17 at 15:42
  • Thanks. I edited the question to include `apply plugin:`. Can you please point me in the right direction to handle that as well? Thanks. – app-dev Sep 25 '17 at 17:08
  • Can you ask that as a new separate question to avoid confusion? – Diamond Sep 26 '17 at 04:36
  • Sorry, I asked it as a seperate question later after I made the edit: https://stackoverflow.com/q/46416226/509557 Seems that they'll be incorporating this in the next update. Thank you. – app-dev Sep 26 '17 at 04:44