Trouble building with Android Studio #11

Open
opened 1 year ago by jahway603 · 5 comments
jahway603 commented 1 year ago
Collaborator

Android Studio Version: 2021.3.1 Patch 1

When I try to build, I first get the following as the code is default to Java 1.8 as seen here and here.

Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
Your current JDK is located in /usr/lib/jvm/java-8-openjdk/jre

Alright, then I change it to Java 11 in Android Studio, as Android Gradle plugin requires it. Then building this complains that it needs Java 1.8.

I then tried looking online to specify a specific version of gradle, but could not find one. Any idea how to fix this build issue?

This gradle support matrix makes me think that any gradle version greater than 2.0 will work with Java 1.8, so not sure what's happening.

Android Studio Version: 2021.3.1 Patch 1 When I try to build, I first get the following as the code is default to Java 1.8 as seen [here](https://git.hush.is/hush/SilentDragonAndroid/src/branch/main/buildSrc/build.gradle.kts#L13) and [here](https://git.hush.is/hush/SilentDragonAndroid/src/branch/main/app/build.gradle#L89). ``` Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. Your current JDK is located in /usr/lib/jvm/java-8-openjdk/jre ``` Alright, then I change it to Java 11 in Android Studio, as Android Gradle plugin requires it. Then building this complains that it needs Java 1.8. I then tried looking online to specify a specific version of gradle, but could not find one. Any idea how to fix this build issue? This [gradle support matrix](https://docs.gradle.org/current/userguide/compatibility.html) makes me think that any gradle version greater than 2.0 will work with Java 1.8, so not sure what's happening.
fekt commented 1 year ago
Collaborator

@jahway603 Sounds weird. This is usually just an issue with Android Studio environment. I think by default it may be trying to use a different version of Java on your system based on path or whatever is in gradle-wrapper.properties file. I have always set it to the version directly in the Android Studio install. For my install, that's 11.0.13.

In Android Studio it can be set here:
File > Settings > Build, Execution, Depployment > Gradle
Under Gradle JDK set to Android Studio/jre path.

I also have a system variable for JAVA_HOME that points to that same path.

I am currently running Android Studio Dolphin | 2021.3.1 Patch 1

@jahway603 Sounds weird. This is usually just an issue with Android Studio environment. I think by default it may be trying to use a different version of Java on your system based on path or whatever is in gradle-wrapper.properties file. I have always set it to the version directly in the Android Studio install. For my install, that's 11.0.13. In Android Studio it can be set here: File > Settings > Build, Execution, Depployment > Gradle Under Gradle JDK set to Android Studio/jre path. I also have a system variable for JAVA_HOME that points to that same path. I am currently running Android Studio Dolphin | 2021.3.1 Patch 1
Poster
Collaborator

I setup the version in Android Studio & my initially reported error which I had above went away. I didn't have to set the JAVA_HOME env variable & not sure if this is necessary or not (I know it use to be).

Now I have the following error message, which relates to the SDK not building

Could not determine the dependencies of task ':app:compileZcashmainnetDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:zcashmainnetDebugCompileClasspath'.
   > Could not find cash.z.ecc.android:zcash-android-sdk:1.9.0-beta01-SNAPSHOT.
     Required by:
         project :app

I'll have to refer to chat where you replied how to fix this new error.

I setup the version in Android Studio & my initially reported error which I had above went away. I didn't have to set the JAVA_HOME env variable & not sure if this is necessary or not (I know it use to be). Now I have the following error message, which relates to the SDK not building ``` Could not determine the dependencies of task ':app:compileZcashmainnetDebugJavaWithJavac'. > Could not resolve all task dependencies for configuration ':app:zcashmainnetDebugCompileClasspath'. > Could not find cash.z.ecc.android:zcash-android-sdk:1.9.0-beta01-SNAPSHOT. Required by: project :app ``` I'll have to refer to chat where you replied how to fix this new error.
Poster
Collaborator

Android Studio Version: 2022.2.1.20-1

Same error above of

Could not determine the dependencies of task ':app:compileZcashmainnetDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:zcashmainnetDebugCompileClasspath'.
   > Could not find cash.z.ecc.android:zcash-android-sdk:1.9.0-beta01-SNAPSHOT.
     Required by:
         project :app

@fekt , what was the fix for this?

Android Studio Version: 2022.2.1.20-1 Same error above of ``` Could not determine the dependencies of task ':app:compileZcashmainnetDebugJavaWithJavac'. > Could not resolve all task dependencies for configuration ':app:zcashmainnetDebugCompileClasspath'. > Could not find cash.z.ecc.android:zcash-android-sdk:1.9.0-beta01-SNAPSHOT. Required by: project :app ``` @fekt , what was the fix for this?
Collaborator

@jahway603 Do you have the latest source code for the SDK and app? In my Dependencies.kt it is set to the following but I think your main problem may be not compiling the SDK locally first:

const val SDK = "hush.android:hush-android-sdk:1.9.0-beta01-SNAPSHOT"

The app uses a local build of the SDK, so the fix for you may be to first clone the SDK and then run these commands from where you cloned it:

./gradlew clean
./gradlew build
./gradlew build publishToMavenLocal

That will create a local build of the SDK where it should be found when compiling the app, provided you have the latest code with correct SDK const val too.

The build is a two step process:

  1. Compile SDK with commands above
  2. Compile app

For the app source, clone latest main branch from here as I forgot a minor fix for the split builds before release and didn't merge it yet: https://git.hush.is/fekt/hush-android-wallet

Eventually, it would be best to have the SDK dependency published somewhere so that it does not need to rely on a local build. I tried using https://jitpack.io/ originally, but it wasn't able to compile Rust on their end. I looked briefly into trying to use Gitea and bookmarked this doc, which seems to support Maven and Gradle packages. It would likely require some config on the Gitea server and installing Maven or Gradle.

@jahway603 Do you have the latest source code for the SDK and app? In my Dependencies.kt it is set to the following but I think your main problem may be not compiling the SDK locally first: ``` const val SDK = "hush.android:hush-android-sdk:1.9.0-beta01-SNAPSHOT" ``` The app uses a local build of the SDK, so the fix for you may be to first clone the [SDK](https://git.hush.is/fekt/hush-android-wallet-sdk.git) and then run these commands from where you cloned it: ``` ./gradlew clean ./gradlew build ./gradlew build publishToMavenLocal ``` That will create a local build of the SDK where it should be found when compiling the app, provided you have the latest code with correct SDK const val too. The build is a two step process: 1) Compile SDK with commands above 2) Compile app For the app source, clone latest `main` branch from here as I forgot a minor fix for the split builds before release and didn't merge it yet: https://git.hush.is/fekt/hush-android-wallet Eventually, it would be best to have the SDK dependency published somewhere so that it does not need to rely on a local build. I tried using https://jitpack.io/ originally, but it wasn't able to compile Rust on their end. I looked briefly into trying to use Gitea and bookmarked [this doc](https://docs.gitea.com/next/usage/packages/maven), which seems to support Maven and Gradle packages. It would likely require some config on the Gitea server and installing Maven or Gradle.
Poster
Collaborator
Related to Issue https://git.hush.is/hush/hush-android-wallet-sdk/issues/4
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.