PYTHON Java Together: Setup WORKING Android | 2024 Chaquopy

Поділитися
Вставка
  • Опубліковано 28 лип 2024
  • If you want Python and Java to integrate for sure and don't want to waste time guessing Gradle build and Python versions that actually work, this video may be for you. Bonus: in the video we reveal the Build Config Language that works for our project! Watch until the end for a handy tip to make Java and Python code work for Android with Chaquopy. See the SDK, Chaqoupy, Python and Java integration come to life on Android Studio!
    00:00 Intro
    00:33 Configure Project in Android Studio
    01:13 Tip to select Build Config Language
    01:35 Chaquopy config
    05:39 Python Java integration
    07:52 Python code
    08:30 Java code for calling Python function
    10:48 Python library config in Gradle
    11:27 Java Python datatype issue
    11:52 Python workaround for Java datatype
    12:09 App launches successfully
    13:15 Outro
    13:37 Gradle version used in this project
    Buy a coffee:
    www.buymeacoffee.com/longwayhome

КОМЕНТАРІ • 48

  • @denissanchezleyva8954
    @denissanchezleyva8954 4 місяці тому

    Awesome! You saved me a lot of time. Thanks a lot. I made it using Jetpack compose of course with Kotlin and works.

    • @laptopml
      @laptopml  4 місяці тому +1

      You're welcome! Great to know it worked

  • @realisnotfalsefalseisnotre3250
    @realisnotfalsefalseisnotre3250 5 місяців тому

    Wonderful, I enjoy this video..Thank you

    • @laptopml
      @laptopml  5 місяців тому

      Thank you too!

  • @mazinab3586
    @mazinab3586 5 місяців тому +2

    I needed this video, thank you so much❤

    • @laptopml
      @laptopml  5 місяців тому

      You're welcome

    • @abhiram5693
      @abhiram5693 5 місяців тому

      can you please help me to integrate python in android studio, i am having some trouble setup@@laptopml

  • @PsycoStarke
    @PsycoStarke Місяць тому

    thank you so much

  • @kvahs9545
    @kvahs9545 6 місяців тому

    thanks so much ❤❤

    • @laptopml
      @laptopml  6 місяців тому

      You're welcome 😊

  • @elias3584
    @elias3584 5 місяців тому

    Thanks so much for the explanation! I have one doubt though, how would the code be different if I wanted to call the python script in another activity instead of MainActivity?

    • @laptopml
      @laptopml  5 місяців тому

      I'm assuming the "other activity" you mentioned is implemented by a Java class and that class has a method to call the Python module. The Python wrapper code should remain similar even if you are calling the Python module from a Java method of that Java class

  • @CharishmaP-wj1yc
    @CharishmaP-wj1yc 2 місяці тому +1

    Hi Sir,
    Thank you for the video when I trying to right click on the python folder and creating new file that python file is not showing for me

    • @laptopml
      @laptopml  2 місяці тому

      Hi, if your python folder is not showing, please watch from 01:50 - 02:10 of this video ua-cam.com/video/8Bth0BuLhbs/v-deo.html I have covered this exact issue in that video.
      Hope this helps!

  • @SPEARHaris
    @SPEARHaris 2 місяці тому +1

    What if I want to apply opencv operations on a list of images passed view user or any method to python and then perform operations and then return them to show in image views.

    • @laptopml
      @laptopml  2 місяці тому

      I will post very soon a video on opencv android python. It works, I've tested it, will share the method that makes it work. Thanks for your question!

    • @laptopml
      @laptopml  2 місяці тому

      Check out OpenCV on Android Python: ua-cam.com/video/yusiw_YyVlI/v-deo.html

  • @CharishmaP-wj1yc
    @CharishmaP-wj1yc 2 місяці тому +1

    Thank you for the video sir, But when I giving right click on the python folder and I am not getting python file in the list

    • @laptopml
      @laptopml  2 місяці тому

      Hi, if your python folder is not showing, please watch from 01:50 - 02:10 of this video ua-cam.com/video/8Bth0BuLhbs/v-deo.html I have covered this exact issue in that video.
      Let us know how it goes. Hope this helps!

    • @laptopml
      @laptopml  2 місяці тому

      Created separate video on Python Source Folder creation issue: ua-cam.com/video/G1P-RiUbAfI/v-deo.html Let me know if this helps

  • @hyacinth124
    @hyacinth124 6 місяців тому

    Thanks for the video, however when i'm trying to run the mainactivity.java, this message keeps appearing
    Process 'command 'C:\Users\xxxx\python.exe'' finished with non-zero exit value 1
    Have you encountered this error while using android studio, as I haven't seen it in your video?

    • @laptopml
      @laptopml  6 місяців тому

      I would start by wrapping the Python integration code in MainActivity.java in a try catch block and see if there is an exception we can catch and examine.
      try {
      Python py = Python.getInstance();
      ...
      System.out.println("....");
      }
      catch(Exception ex) {
      System.out.println("Exception caught: " + ex.getMessage());
      }
      Hope this helps.

  • @elias7788
    @elias7788 5 місяців тому

    Thanks for the video! have one small error though: When I try to run the app, this exception appears when building: Configuration cache state could not be cached: app\build\python\env\debug\Lib does not exist

    • @laptopml
      @laptopml  5 місяців тому +2

      In your gradle.properties file, is there a line like 'org.gradle.unsafe.configuration-cache=true'
      If so, can you remove it and rebuild your project? Let me know if this line is not there, we may have to look elsewhere

    • @elias7788
      @elias7788 5 місяців тому

      @@laptopml Thanks again! That solved the problem, I'm definitely subscribing, good luck with everything!

  • @ahmadh9381
    @ahmadh9381 9 днів тому

    Hello sir, why despite installing the library numpy, it still shows Errors in your my.helper.py file (12:24)

    • @laptopml
      @laptopml  9 днів тому

      Hi, are you referring to the red underline on the numpy import statement? If so, despite that, the program executed successfully as you can tell from the logs. This tells me that numpy was installed but I guess there was a delay in syncing the studio environment to that, which caused the underline to show

  • @MariamMariam-yt9eq
    @MariamMariam-yt9eq 4 місяці тому +1

    Hello sir! Thankyou so much for the video. Can you please help me with the error i am getting when i try to sync the gradle file, it says "Gradle DSL method not found: 'python()'

    • @laptopml
      @laptopml  4 місяці тому

      Can you share your build.gradle file? We have to see if there is any config incorrectly set in a block or if a dependency is an issue

    • @MariamMariam-yt9eq
      @MariamMariam-yt9eq 4 місяці тому

      @@laptopml Thankyou so much sir for replying, but I fixed that error myself. Now after creating a file with .py extension it is asking for me to configure python interpreter, can you please help me with that?

    • @laptopml
      @laptopml  4 місяці тому

      See 04:38 in the video, I explain there the path of the python interpreter configuration in build.gradle

    • @MariamMariam-yt9eq
      @MariamMariam-yt9eq 4 місяці тому

      @@laptopml Thankyou so much. Your video was very helpful to me!!

  • @deejons5760
    @deejons5760 6 місяців тому

    Missing x86 ABI support for ChromeOS in abiFilters "arm64-v8a", "x86_64". whata hell should i do ?

    • @laptopml
      @laptopml  6 місяців тому

      Have you tried abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' ? As it says x86 (x86_32) ABI support is missing in abiFilters. Some ChromeOS devices can run x86 chips. Hope this helps.

  • @joeljoe1912
    @joeljoe1912 2 місяці тому

    Thank you sir,for thia wonderful video,how can I add installing opencv

    • @laptopml
      @laptopml  2 місяці тому

      I'll make a video on opencv shortly. Please stay tuned. Thank you!

    • @laptopml
      @laptopml  Місяць тому

      Watch OpenCV install playlist: ua-cam.com/play/PL1KT-ofSrkBmtwChLx_9dsRU6pauT-fPy.html

  • @42_jameskalam22
    @42_jameskalam22 4 місяці тому

    when creating python script that python file is not showing to me ?

    • @laptopml
      @laptopml  4 місяці тому

      Can you share a bit more details? Do you mean you can't see the python script file from the left side i.e. of Android Studio viewer?

    • @laptopml
      @laptopml  24 дні тому

      This video can help: ua-cam.com/video/G1P-RiUbAfI/v-deo.html

  • @Klymets108
    @Klymets108 Місяць тому

    I haven't an import statement on the eleven minute. What the reason?

    • @laptopml
      @laptopml  Місяць тому

      What is the import statement you're expecting?

    • @Klymets108
      @Klymets108 15 днів тому

      @@laptopml I expected "Sign in to start collecting".

  • @ReshmaBegum-ov8to
    @ReshmaBegum-ov8to 3 місяці тому

    can i use pycharm instead of anaconda?

    • @laptopml
      @laptopml  3 місяці тому

      Pycharm and Anaconda are for different requirements. Anaconda does Python installation/distribution whereas Pycharm is a Development Environment (IDE) with an editor that you can use for code development. You can use Pycharm or other tools like Jupyter to code in Python. You will still need a tool like Anaconda to install and manage Python versions.

  • @aurisarabina4446
    @aurisarabina4446 11 днів тому

    Thank youuuu, I've subscribed. I have a question.. the python folder already exists, but why can't I create a python file? whats wrong🥲(7:50)

    • @laptopml
      @laptopml  10 днів тому

      Thanks! To create the python folder and py file this video could help: ua-cam.com/video/G1P-RiUbAfI/v-deo.html If not let us know and we can troubleshoot further