Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jitpack build #558

Closed
nshmyrev opened this issue May 27, 2021 · 21 comments
Closed

Add jitpack build #558

nshmyrev opened this issue May 27, 2021 · 21 comments

Comments

@nshmyrev
Copy link
Collaborator

So we can distribute things for F-droid, see

https://forum.f-droid.org/t/google-voice-foss-replica/13629/8

@k3b
Copy link

k3b commented May 28, 2021

For details see https://jitpack.io/docs/ANDROID/ and https://jitpack.io/docs/BUILDING/

I am currently experimenting how to create a gradle only android lib that includes ndk and downloading the c++ source modules without the need for a bash script

@k3b
Copy link

k3b commented May 29, 2021

@nshmyrev i have created https://github.com/k3b/vosk-api-jitpack.io as an attempt to create the lib in gradle only without any bash script.

  • I have granted you write support there so i hope that we together can solve this issue there.
  • The goal is to make the lib compatible with android.
  • the project can be opened with android studio.

Note that i have never worked before with android-ndk and cmake. the last time i programmed in c++ was 20 years ago (windows-3.0)


what i have done so far:

Created a new android project with a ndk subproject "vosk-api"

  • has a gradle step to download 'https://github.com/xianyi/OpenBLAS.git' to vosk-api/libs/OpenBLAS
  • in vosk-api/build.gradle there is the commented out section externalNativeBuild/cmake marked with !!! that tries to compile OpenBLAS/CMakeLists.txt
    • when removing the comment compile failed with "When cross compi"ling, a TARGET is required."
      • for android every native code has to go to "native-lib"
      • I assume that "OpenBLAS/CMakeLists.txt" need somthing like
        • if (ANDROID)
          • target_link_libraries(native-lib SHARED ?????)
        • endif ()

can you help me solving that issue

@nshmyrev
Copy link
Collaborator Author

can you help me solving that issue

Hi, thank you for starting this. Some notes:

  1. I wanted to look a bit later on that too
  2. I don't think a separate project is needed, you can do it within vosk-api. I believe you can specify the build command in jitpack.yml so it will pick the right folder.
  3. I don't think you need to rework everything with cmake. You just add build-kaldi script to gradle as a task and it will be invoked on build. I hope jitpack allows build of a bigger c++ project.

@k3b
Copy link

k3b commented May 29, 2021

Thanks for reply.

The seperate project is just an experiment where i can play and learn without polluting the original.

I already learned about

  • gradle plugin com.alexvasilkov.git-dependencies to clone git repositories
  • android studio with ndk

I agree that building using jitpack.yml is probably much less effort than recreating the build in native gradle.

"jitpack.yml" is provider specific so it will not work with travis or under windows where there is no bash-shell.

I will try to learn more about android c++ integration.

Can you help me what should be put into OpenBLAS/CMakeLists.txt to android specific target lib.

if (???ANDROID???)
    target_link_libraries(native-lib SHARED ?????)
endif ()

@nshmyrev
Copy link
Collaborator Author

Can you help me what should be put into OpenBLAS/CMakeLists.txt to android specific target lib.

I don't think you need to put something specific. It is already there:

https://github.com/xianyi/OpenBLAS/blob/42f048cf6c04e51de6c7a3ade5af71b0c4dcea0d/CMakeLists.txt#L190

@k3b
Copy link

k3b commented May 29, 2021

thanks.

i already found the solution. the error with missing "target" was a missing environment variable. i go on learning ....

@k3b
Copy link

k3b commented May 30, 2021

I finally stopped trying to create a gradle-native-build because
config.h is not generated in vosk-api/src/main/cpp/clonedRepositories/OpenBLAS/Makefile.system

I cannot do this without a coderewrite.

I hope that nshmyrev -s jitpack.yml aproach will work

@k3b
Copy link

k3b commented May 31, 2021

I tried with jitpack.yml but it does not compile

publishing:

consumig as

@nshmyrev
Copy link
Collaborator Author

but it does not compile

The log says you need to define ANDROID_NDK_HOME, probably also in jitpack.yml

@k3b
Copy link

k3b commented Jun 1, 2021

The log says you need to define ANDROID_NDK_HOME, probably also in jitpack.yml

i thought that would be done with sdkmanager --install "ndk;21.3.6528147"

@nshmyrev
Copy link
Collaborator Author

nshmyrev commented Jun 1, 2021

@k3b jitpack doesn't define ANROID_NDK_HOME, but it defines ANDROID_HOME. You can probably modify build-vosk.sh script like this:

  ANDROID_NDK_HOME?=$ANDROID_HOME/ndk-bundle

and it should go forward

@k3b
Copy link

k3b commented Jun 8, 2021

@nshmyrev have you tried to upload your aar lib via https://central.sonatype.org/publish/ ? it is among the trusted maven repos

@nshmyrev
Copy link
Collaborator Author

nshmyrev commented Jun 8, 2021

Yeah, we had bad experience with sonatype before. I'd better go with jitpack. But I'm sorry I didn't had time to check yet.

@Stypox
Copy link

Stypox commented Sep 14, 2021

Is anyone still working on this? I'd like to publish the Dicio assistant on F-Droid but that needs this issue to be resolved. If nobody is working on it I might try myself, though I don't have much experience with build scripts and NDK.

@nshmyrev
Copy link
Collaborator Author

Is anyone still working on this?

No, I don't think so

I'd like to publish the Dicio assistant on F-Droid but that needs this issue to be resolved.

Cool app!

Please try and let me know if you need any help. If it doesn't work, maybe I'll register to sonatype in the end, not sure.

@nshmyrev
Copy link
Collaborator Author

nshmyrev commented Nov 6, 2021

I decided to go ahead with sonatype. Created an issue at https://issues.sonatype.org/browse/OSSRH-74850

@nshmyrev
Copy link
Collaborator Author

nshmyrev commented Nov 7, 2021

@nshmyrev
Copy link
Collaborator Author

nshmyrev commented Nov 7, 2021

We are on mavencentral already

https://repo1.maven.org/maven2/com/alphacephei/vosk-android/

@nshmyrev nshmyrev closed this as completed Nov 7, 2021
@Stypox
Copy link

Stypox commented Nov 7, 2021

Thank you very much :-D

Stypox added a commit to Stypox/dicio-android that referenced this issue Nov 7, 2021
Stypox added a commit to Stypox/dicio-android that referenced this issue Nov 7, 2021
@nshmyrev
Copy link
Collaborator Author

nshmyrev commented Nov 7, 2021

Thank you @Stypox, your patch was extremely helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants