hashgraph / hedera-sdk-java

Hedera™ Hashgraph SDK for Java
https://docs.hedera.com/guides/docs/sdks
Apache License 2.0
203 stars 113 forks source link

driod API 33, ContractFunctionResult using Stream ? tripping up. java.lang.NoSuchMethodError: No interface method toList()Ljava/util/List; in class Ljava/util/stream/Stream #1833

Open johnda98 opened 1 month ago

johnda98 commented 1 month ago

Description

yeah.. kinda at a Client impasse now @Datadamus as unable to use HH SDK to read the Wallet Users profile SC and Query and Execution seem to use Stream dependency and it seems to not get sucked into emulator runtime yet compile build is fine.

" ContractFunctionResult result_1 = new ContractCallQuery() .setGas(30000) .setContractId(existing) .setFunction("getfname") // .setMaxQueryPayment(new Hbar(1)) .execute(USER_ACCOUNT);"

digging deeper .. droid studio, 1.8 compat, compiling for API33.. droid 13.. HH SDK and gRPC is checked - as per github for droid..ok

droid does support java 8 from version 7 Nougat and Stream was in 8. . noted API26 hedera SDK min.

ContractFunctionResult using Stream ? Studio config looks ok. later in thread - copy of gradles.

Process: com.mvp.olarawallet, PID: 10463 java.lang.NoSuchMethodError: No interface method toList()Ljava/util/List; in class Ljava/util/stream/Stream; or its super classes (declaration of 'java.util.stream.Stream' appears in /apex/com.android.art/javalib/core-oj.jar) at com.hedera.hashgraph.sdk.ContractFunctionResult.(ContractFunctionResult.java:152) at com.hedera.hashgraph.sdk.ContractCallQuery.mapResponse(ContractCallQuery.java:246) at com.hedera.hashgraph.sdk.ContractCallQuery.mapResponse(ContractCallQuery.java:48) at com.hedera.hashgraph.sdk.Executable$GrpcRequest.mapResponse(Executable.java:929) at com.hedera.hashgraph.sdk.Executable.execute(Executable.java:463) at com.hedera.hashgraph.sdk.Query.execute(Query.java:51) at com.hedera.hashgraph.sdk.Executable.execute(Executable.java:364) at com.hedera.hashgraph.sdk.Query.execute(Query.java:51) at com.mvp.olarawallet.HederaServices.getacontract(HederaServices.java:357) at com.mvp.olarawallet.MainActivity$LogonThread.run(MainActivity.java:251) 2024-06-02 11:29:15.501 10463-10497 Process com.mvp.olarawallet I Sending signal. PID: 10463 SIG: 9

ContractFunctionResult result_1 = new ContractCallQuery() .setGas(5000000) .setContractId(ContractId.fromString(existingcontractid)) .setFunction("getfname") .setMaxQueryPayment(new Hbar(5)) .execute(USER_ACCOUNT);

    if (result_1.errorMessage!= null) {
        System.out.println("Error calling Contract " + result_1.errorMessage);
        return runitdetails;
    }

    String queryout = result_1.getString(0);

Steps to reproduce

droid build. no probs

Additional context

No response

Hedera network

testnet

Version

sdk and gPRC as in the Hedera repo READme - for droid for java sdk

Operating system

None

johnda98 commented 1 month ago

stuffed big gas in there.. but its tripping up on result .. anyone help with this build ? all loosk to be correct to the repo's instructions. Java 8 supported and all other project parms look ok.

thenswan commented 1 month ago

Hello @johnda98, thanks for submitting this issue 👍🏻
We are aware of Android issues (like this one) and investigating them currently 👀

johnda98 commented 1 month ago

yeah I'm setup for API 33 - google playstore minimum.

                                                                                                java.lang.NoSuchMethodError: No interface method toList()Ljava/util/List; in class Ljava/util/stream/Stream; or its super classes (declaration of 'java.util.stream.Stream' appears in /apex/com.android.art/javalib/core-oj.jar)
johnda98 commented 1 month ago
Screen Shot 2024-06-05 at 10 46 27 PM

yep. checked.. I have src and comp as V8 ... but I guess it doesnt pull in the depdencies correctly .. yep droid 7 for API 25 24 is supposed to support V8 .. my build is min 33 and hits 34 so way above HH minimum API as play store needs 33 minimum

johnda98 commented 1 month ago

Hello @johnda98, thanks for submitting this issue 👍🏻 We are aware of Android issues (like this one) and investigating them currently 👀

I upgraded the gRPC and HHSDK to latest - up and above whats ont he README for droid on the Java SDK from HH

Also pulled in Jetbrains 17JDK .. have the 17 source & compile set in gradle.. all seems to be coolio this end.. and at runtime still get the same .Stream puke saying its not there in the build.

complex IDE for sure... and the gradle plugin syncs etc.

well. let me know if your core teams findings can shed any light -thanks.

thenswan commented 1 month ago

Thanks for additional info @johnda98 Sure, will let you know.

johnda98 commented 1 month ago

![Uploading Screenshot 2024-06-07 at 8.55.07 AM.png…]() plugins { id 'com.android.application' }

android { compileSdk 34

defaultConfig {
    applicationId "com.mvp.olarawallet"
    minSdk 33
    targetSdk 34
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_17
    targetCompatibility JavaVersion.VERSION_17
}
namespace 'com.mvp.olarawallet'

packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/ASL2.0'
}

}

dependencies {

implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

implementation 'com.hedera.hashgraph:sdk:2.29.0'
// okhttp transport (for lighter-weight applications or Android)
implementation 'io.grpc:grpc-okhttp:1.58.0'
// https://mvnrepository.com/artifact/io.github.cdimascio/dotenv-java
implementation group: 'io.github.cdimascio', name: 'dotenv-java', version: '3.0.0'

and proj level ...

// Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { id 'com.android.application' version '8.4.1' apply false id 'com.android.library' version '8.4.1' apply false }

task clean(type: Delete) { delete rootProject.buildDir }

johnda98 commented 1 month ago

ok.. digging now.. RE: your ref - https://github.com/hashgraph/hedera-sdk-java/issues/1620

johnda98 commented 1 month ago

![Uploading Screenshot 2024-06-07 at 12.01.08 PM.png…]() I will step the build down to API27 - other threads says that resolves it.. but Google Play Store for production is min 33 ..soooooo... it needs sorting out.

johnda98 commented 1 month ago

its as if the HH java SDK for droid.. as opposed to a Kotlin or a hybrid, has to chase Google's API playstore min API - now 33 - which may not like the Java Stream object tried to back peddle to API27 - as a work around - BUT my App needs Edge to Edge and thats 1.8 droid appcompatvitiy dependency which means I have to use API 33+ ironically emulator for API34 has starting issues so API33 is my minium..

I cannot step back the build to API27 to enable Java 'Stream' object.. looks like this is a catchup between Google's API minimum and the HH java sdk evolution

johnda98 commented 1 month ago

yup.. checked all my Java17 - using Jetbrains SDK-17.0.10 dependencies(presume is compatible), in droid studio and checked other gradle parms... same deal on Stream on ContractCallQuery - which is on a Solidity string BTW.. maybe thats whats making it puke.. alot of gas - seems to accept 400M tbars then it pukes.

even stepped up to implementation 'com.hedera.hashgraph:sdk:2.34.0'. as per the droid example... .. same issue.

dont tell me I gotta not use .sol strings ? then SDK wont use Stream ? @thenswan :-)

java.lang.NoSuchMethodError: No interface method toList()Ljava/util/List; in class Ljava/util/stream/Stream; or its super classes (declaration of 'java.util.stream.Stream' appears in /apex/com.android.art/javalib/core-oj.jar) at com.hedera.hashgraph.sdk.ContractFunctionResult.(ContractFunctionResult.java:152) at com.hedera.hashgraph.sdk.ContractCallQuery.mapResponse(ContractCallQuery.java:246) at com.hedera.hashgraph.sdk.ContractCallQuery.mapResponse(ContractCallQuery.java:48) at com.hedera.hashgraph.sdk.Executable$GrpcRequest.mapResponse(Executable.java:929) at com.hedera.hashgraph.sdk.Executable.execute(Executable.java:463) at com.hedera.hashgraph.sdk.Query.execute(Query.java:51) at com.hedera.hashgraph.sdk.Executable.execute(Executable.java:364) at com.hedera.hashgraph.sdk.Query.execute(Query.java:51) at com.mvp.olarawallet.HederaServices.getacontract(HederaServices.java:383) at com.mvp.olarawallet.MainActivity$LogonThread.run(MainActivity.java:250)

thenswan commented 4 weeks ago

Hey @johnda98, really appreciate your follow ups with new details. We're actively working on supporting new hedera-services versions. Addressing the Android issue in the Java SDK is a priority for us as well and we will aim to shift our focus to this as soon as we can. I will follow up when it happens 👍🏻

johnda98 commented 3 weeks ago

Hey @johnda98, really appreciate your follow ups with new details. We're actively working on supporting new hedera-services versions. Addressing the Android issue in the Java SDK is a priority for us as well and we will aim to shift our focus to this as soon as we can. I will follow up when it happens 👍🏻

related ... https://github.com/flutter/flutter/issues/141949

related https://developer.android.com/studio/write/java8-support#groovy

-result. same yet build is clean and everything else works.. just pesky HH contractquery call - BTW I converted the SC to Bytes32 and it creates fine.. its just now being able to read it ! :-)... worked fine 2 years ago on my last droid wallet build.

" java.lang.NoSuchMethodError: No interface method toList()Ljava/util/List; in class Ljava/util/stream/Stream; or its super classes (declaration of 'java.util.stream.Stream' appears in /apex/com.android.art/javalib/core-oj.jar) "

Welcome any clues from your Core team - thanks ThenSwan. this work may need the HH SDK repo gradle build/app dependencie and min config examples - to help other teams. - thanks. welcome prompt thoughts.

Olara app level -

plugins { id 'com.android.application' }

android { compileSdk 34

defaultConfig {
    applicationId "com.mvp.olarawallet"
    minSdk 33
    targetSdk 33
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    // Flag to enable support for the new language APIs
    coreLibraryDesugaringEnabled = true
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
namespace 'com.mvp.olarawallet'

packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/ASL2.0'
}
buildToolsVersion '34.0.0'

}

dependencies {

implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.activity:activity:1.9.0'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'

implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

 implementation 'com.hedera.hashgraph:sdk:2.29.0'
//implementation 'com.hedera.hashgraph:sdk:2.34.0'
// okhttp transport (for lighter-weight applications or Android)

// implementation 'io.grpc:grpc-okhttp:1.58.0' implementation 'io.grpc:grpc-okhttp:1.58.0' implementation "io.grpc:grpc-protobuf-lite:1.50.2"

// Protobuf Lite is used to maintain easy compatibility with Android
// https://github.com/protocolbuffers/protobuf/blob/master/java/lite.md
implementation "com.google.protobuf:protobuf-javalite:3.21.9"
// https://mvnrepository.com/artifact/io.github.cdimascio/dotenv-java
implementation group: 'io.github.cdimascio', name: 'dotenv-java', version: '3.0.0'

}

and proj level.. // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { id 'com.android.application' version '8.4.1' apply false id 'com.android.library' version '8.4.1' apply false }

task clean(type: Delete) { delete rootProject.buildDir }

johnda98 commented 3 weeks ago

yeah.. kinda at a Client impasse now @Datadamus as unable to use HH SDK to read the Wallet Users profile SC and Query and Execution seem to use Stream dependency and it seems to not get sucked into emulator runtime yet compile build is fine.

" ContractFunctionResult result_1 = new ContractCallQuery() .setGas(30000) .setContractId(existing) .setFunction("getfname") // .setMaxQueryPayment(new Hbar(1)) .execute(USER_ACCOUNT);"