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

"Could not find com.chaquo.python.runtime:chaquopy_java" in Flutter plugin project #615

Closed
mhsmith opened this issue May 1, 2022 · 10 comments
Labels

Comments

@mhsmith
Copy link
Member

mhsmith commented May 1, 2022

Originally posted by @arnavpon in #94 (comment)

Hi Malcolm,

I'm building a Flutter plugin that requires chaquopy as a dependency, but having a lot of trouble correctly configuring the build.gradle file. The main issue is that there's only one build.gradle in a Flutter plugin's android module (there's no app-specific build.gradle), so I tried to add all the necessary configuration to this file. When I try to build, here's the error I'm getting:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':pydroid:bundleDebugAar'.
> Could not resolve all files for configuration ':pythonRuntimeJava'.
   > Could not find com.chaquo.python.runtime:chaquopy_java:11.0.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/chaquo/python/runtime/chaquopy_java/11.0.0/chaquopy_java-11.0.0.pom
       - https://repo.maven.apache.org/maven2/com/chaquo/python/runtime/chaquopy_java/11.0.0/chaquopy_java-11.0.0.pom
     Required by:
         project :

And the build.gradle file:

buildscript {
    repositories {
        google()
        mavenCentral()
        maven { url "https://chaquo.com/maven" }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "com.chaquo.python:gradle:11.0.0"
    }
}

rootProject.allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

apply plugin: 'com.android.library'
apply plugin: 'com.chaquo.python'

android {
    compileSdkVersion 30

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        minSdkVersion 16
        ndk {
            abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
        }
        python {
            buildPython "~/opt/anaconda3/envs/chaquopy/bin/python3.8"
            pip {
                install 'numpy'
            }
        }
    }
}

Apologies in advance if I'm making an obvious error - I'm new to Android development. Thank you!

@mhsmith
Copy link
Member Author

mhsmith commented May 1, 2022

I assume the project is https://github.com/arnavpon/pydroid? If so, can you update it with the current version of your code? You can put it on a separate branch if you prefer.

@mhsmith mhsmith changed the title "Could not find com.chaquo.python.runtime:chaquopy_java" in Flutter project "Could not find com.chaquo.python.runtime:chaquopy_java" in Flutter plugin project May 1, 2022
@arnavpon
Copy link

arnavpon commented May 1, 2022 via email

@mhsmith
Copy link
Member Author

mhsmith commented May 2, 2022

It looks like Chaquopy is confused by the way the Flutter template includes one project into another. When I built the plugin project directly, by running flutter build aar in the root directory, everything worked fine, though I needed to add the androidx.annotation dependency to the build.gradle file. But when I tried to build the example/android project, which includes the plugin as a subproject, I got the error message above.

We'll fix this in the next version of Chaquopy. Meanwhile, it looks like you can work around it by editing example/android/build.gradle so that its buildscript.repositories block includes the chaquo.com Maven repository, just as you've already done for the plugin project.

@mhsmith mhsmith added the bug label May 2, 2022
@arnavpon
Copy link

arnavpon commented May 4, 2022 via email

@mhsmith
Copy link
Member Author

mhsmith commented May 4, 2022

You can't attach images to GitHub issues over email. Do it on the GitHub website instead -- or preferably, copy and paste the text so it can be found in searches.

@arnavpon
Copy link

arnavpon commented May 5, 2022 via email

@mhsmith
Copy link
Member Author

mhsmith commented May 5, 2022

Originally posted by @arnavpon in #94 (comment)

Malcolm,

Thank you for being so responsive. I'm building a Flutter plugin that utilizes chaquopy. Configuring the module's build.gradle as well as the top-level and app-level build.gradle files in the "example" app as specified in the chaquopy docs enables a successful build. However, whenever I attempt to call any chaquopy code within the android plugin, the application crashes with the following exception:

Screen Shot 2022-05-03 at 10 03 57 PM

It's specifically the chaquopy code generating the error, as other data passed through the method channel, such as identifying the android OS build version, works as expected.

@mhsmith
Copy link
Member Author

mhsmith commented May 5, 2022

If you search for this error on Google, it returns flutter/flutter#11104, which suggests that the fix is to replace ex.getStackTrace() at PydroidPlugin.java:100 with null. So maybe this is not the correct way of passing an exception from Java to Dart. I don't know much about Flutter, so you'd have to search elsewhere for help on that.

@mhsmith
Copy link
Member Author

mhsmith commented May 12, 2022

The original issue ("Could not find com.chaquo.python.runtime:chaquopy_java") is fixed in Chaquopy 12.0.0. To upgrade, change the Chaquopy version number in your app's top-level build.gradle file.

@mhsmith mhsmith closed this as completed May 12, 2022
@arnavpon
Copy link

arnavpon commented Oct 11, 2022 via email

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

No branches or pull requests

2 participants