question

cdcilley avatar image
cdcilley asked cdcilley published

CloverGo remote-pay-android-go Gradle error during integration into my Android Studio project

I've written a standalone POS Android application. I am now working up integrating Clover Go with my app. I have followed the instructions at GitHub remote-pay-android-go, both for trying to get it to work...
+ Option 1. Clone the remote-pay-android-go repository and add a new module for your app into the project
OR
+ Option 2. Clone the remote-pay-android-go repository and copy the necessary modules into your own android project
(I won't go into the tweaking I had to do to get Option 1 close - the project settings.gradle is wrong for this integration).

For Option 2, the first error I got was:
Error:(49, 0) Could not get unknown property 'cloverGoSDKVersion' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
File:D:\AndroidStudioProjects\SPRemote\remote-pay-android-connector\build.gradle

remote-pay-android-connector\build.gradle has the lines:
compile "com.firstdata.clovergo:data:$cloverGoSDKVersion-SNAPSHOT:QaRelease@aar"
compile "com.firstdata.clovergo:domain:$cloverGoSDKVersion-SNAPSHOT"
compile "com.firstdata.clovergo:reader:$cloverGoSDKVersion-SNAPSHOT@aar

From working in Option 1 I had seen "300.05" as a value. When I put that in I got the errors:
Error:Failed to resolve: com.firstdata.clovergo:data:300.05-SNAPSHOT
    File:D:/AndroidStudioProjects/SPRemote/app/build.gradle
Error:Failed to resolve: com.firstdata.clovergo:domain:300.05-SNAPSHOT
    File:D:/AndroidStudioProjects/SPRemote/app/build.gradle
Error:Failed to resolve: com.firstdata.clovergo:reader:300.05-SNAPSHOT
    File:D:/AndroidStudioProjects/SPRemote/app/build.gradle
Interestingly, I got to the exact same place with this same error when I worked my way through Option 1 importing my project into the fresh GitHub imported remote-pay-android-go project.

Please, how can I resolve this?
Clover GoRemote Pay Android
2 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

cdcilley avatar image cdcilley commented ·

Tried again with Option 1...

Cloned project - Gradle build successful. Able to compile and install the remote-pay-android-example-pos module.

Imported my current project as a module, modified the project build.gradle to include a maven repository I'm using - Gradle build successful.

Added compile project(':remote-pay-android-connector') to my module's build.gradle "dependencies" section - Gradle build failed. Same error as above about "Failed to resolve: com.firstdata.clovergo:data:300.05-SNAPSHOT" in my module's build.gradle.

I've followed the instructions exactly on the GitHub page, but can't get past this error...

0 Likes 0 ·
cdcilley avatar image cdcilley commented ·

Tried again with a clean clone from GitHub and simply added a basic "Phone/Tablet" application module. Got the same build error after adding

compile project(':remote-pay-android-connector')

to build.gradle.

0 Likes 0 ·
cdcilley avatar image
cdcilley answered
Okay, after some back-and-forth with @kedar.deo, we've got it working. Here's the answer...

I originally followed the Initial Setup -> Option 1 instructions on remote-pay-android-go on GitHUb. These are what worked for me to get a generic app working.
Environment : Windows, Android Studio 3.0.1
  1. Start up Android Studio
  2. Check out project from Version Control : GitHub
    1. Give the URL https://github.com/CloverGo/remote-pay-android-go
  3. During the install I just picked the defaults for build and import
  4. To confirm things installed correctly, I did a test build and APK install of remote-pay-android-example-pos application.
  5. Added a new module : File->New->New Module...
    1. Phone & Tablet Module
    2. Used the defaults: "My Application", MinSDK=17, Basic Activity
    3. Unselected directory hierachy to "Add Files to Git"
  6. Initial Gradle returns a bunch of errors - select "Add Google Maven repository and sync project" in the error listing to fix.
  7. Modify the default generated myapplication:build.gradle file to look like this, changes marked "// Added":
apply plugin: 'com.android.application'

// Added
repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}

android {
    compileSdkVersion 26

    defaultConfig {
        applicationId "bjccproductionsltd.com.myapplication"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
	// Added
        multiDexEnabled true

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    // Added
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    // Added
    compile project(':remote-pay-android-connector')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:26.1.0'
    // Added
    compile 'com.android.support:multidex:1.0.1'
    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'
}
You can now "Run" myapplication. It should build and install the APK and you'll see the "Hello World"!

I have not tested a version of this on the Option 2 (added CloverGo to your app).
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

kedardeo avatar image
kedardeo answered
Is it possible for you to show what dependencies you have in your build.gradle file for myapplication and remote-pay-android-connector?
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

kedardeo avatar image
kedardeo answered
Also - can you confirm that you have the following in your myapplication gradle file as well...

maven { url “https://oss.sonatype.org/content/repositories/snapshots” }
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

cdcilley avatar image
cdcilley answered cdcilley edited
I noticed some of the GitHub files were updated 6 days ago. I grabbed a fresh clone, but still got the same errors, @kedar.deo.

myapplication:build.gradle
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':remote-pay-android-connector')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:26.1.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'
}

remote-pay-android-connector:build.gradle
dependencies {
    compile project(':clover-remote-interface')
    compile project(':clover-android-sdk')
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.neovisionaries:nv-websocket-client:1.31'
    testCompile 'junit:junit:4.12'
    //CloverGo Depenencies
    compile 'com.google.android.gms:play-services-gcm:10.2.6'
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.9'
    compile "com.firstdata.clovergo:data:$cloverGoSDKVersion-SNAPSHOT@aar"
    compile 'com.squareup.okhttp3:okhttp:3.5.0'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-jackson:2.1.0'
    compile "com.firstdata.clovergo:domain:$cloverGoSDKVersion-SNAPSHOT"
    compile 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'
    compile 'io.reactivex.rxjava2:rxjava:2.0.6'
    compile 'com.google.dagger:dagger:2.9'
    compile "com.firstdata.clovergo:reader:$cloverGoSDKVersion-SNAPSHOT@aar"
    compile project(':roam')
}
I did not have the snapshots repository in myapplication:build.gradle. After I added it the sync build worked fine - I did not see the earlier errors. However, when I went to "Run" the application on my device, I got 4 Gradle errors:
Information:Gradle tasks [:myapplication:assembleDebug]
  1. Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process D:\Users\Xtopher\.gradle\caches\modules-2\files-2.1\com.firstdata.clovergo\domain\300.06-SNAPSHOT\c51eb7ec0ab7150cf89c58c86a32ba16c3ea5401\domain-300.06-SNAPSHOT.jar
  2. Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing com/firstdata/clovergo/domain/usecase/LogoutEmployee.class
  3. Error:com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
  4. Error:Execution failed for task ':myapplication:transformClassesWithDexBuilderForDebug'.> com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process D:\Users\Xtopher\.gradle\caches\modules-2\files-2.1\com.firstdata.clovergo\domain\300.06-SNAPSHOT\c51eb7ec0ab7150cf89c58c86a32ba16c3ea5401\domain-300.06-SNAPSHOT.jar
So, progress?...
1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

cdcilley avatar image cdcilley commented ·

After the above changes/testing, if I comment out compile project(':remote-pay-android-connector') in myapplication:build.gradle and hit "Run", it compiles and installs the APK just fine.

0 Likes 0 ·
kedardeo avatar image
kedardeo answered cdcilley commented
Can you confirm in your build.gradle file that you have added the following maven repo under repositories?
maven { url “https://oss.sonatype.org/content/repositories/snapshots” }
1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

cdcilley avatar image cdcilley commented ·

@kedar.deo , as I mentioned in the answer above, the maven snapshots repository was *not* in the original myapplication:build.gradle. After adding it, the original errors went away, however I got the 4 build errors I detail above.

0 Likes 0 ·
kedardeo avatar image
kedardeo answered
Have you set in your build.gradle file
compileOptions {       
sourceCompatibility JavaVersion.VERSION_1_8       
targetCompatibility JavaVersion.VERSION_1_8   
}
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

cdcilley avatar image
cdcilley answered cdcilley published
@kedar.deo, I added the compileOptions in myapplication:build.gradle
(I had to post as an Answer since it was too much text for a Comment)

I got the following build error:
Information:Gradle tasks [:myapplication:assembleDebug] Error:The number of method references in a .dex file cannot exceed 64K. Learn how to resolve this issue at https://developer.android.com/tools/building/mult... Error:com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536 Error:at com.android.dx.merge.DexMerger$8.updateIndex(DexMerger.java:565) Error:at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:276) Error:at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:574) Error:at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:166) Error:at com.android.dx.merge.DexMerger.merge(DexMerger.java:198) Error:at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61) Error:at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36) Error:at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424) Error:at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) Error:at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) Error:at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) Error:at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) Error:Execution failed for task ':myapplication:transformDexArchiveWithDexMergerForDebug'. > com.android.build.api.transform.TransformException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536 Information:BUILD FAILED in 36s

Of course if you go to https://developer.android.com/tools/building/mult... the page returns a 404 Page Not Found error. :-)
Still, it seems like continued progress...

If it helps, here is my current myapplication:build.gradle
apply plugin: 'com.android.application'

repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}

android {
    compileSdkVersion 26
    
    defaultConfig {
        applicationId "bjccproductionsltd.com.myapplication"
        minSdkVersion 17
        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'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':remote-pay-android-connector')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:26.1.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'
}
1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

cdcilley avatar image cdcilley commented ·

I searched for the error on Google and found this page : The number of method references in a .dex file cannot exceed 64k API 17

The build.gradle modifications in the accepted answer worked! I can "Run" myapplication and it builds and installs the APK.

  • Add multiDexEnabled true to "defaultConfig"
  • Add compile 'com.android.support:multidex:1.0.1' to "dependencies"

This was starting from a fresh clone of CloverGo and a default "basic" activity. @kedar.deo, perhaps you can test and write up all the changes into a complete answer for future users...

0 Likes 0 ·

Welcome to the
Clover Developer Community