TelemetryDeck / FlutterSDK

Flutter SDK for TelemetryDeck, a privacy-conscious analytics service for apps and websites.
https://telemetrydeck.com/
MIT License
3 stars 2 forks source link

Unable to build on Android #1

Open glemartret opened 8 months ago

glemartret commented 8 months ago

When I run my app on Android I get the following build error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find any matches for com.github.TelemetryDeck:KotlinSDK:+ as no versions of com.github.TelemetryDeck:KotlinSDK are available.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/github/TelemetryDeck/KotlinSDK/maven-metadata.xml
       - https://repo.maven.apache.org/maven2/com/github/TelemetryDeck/KotlinSDK/maven-metadata.xml
       - https://storage.googleapis.com/download.flutter.io/com/github/TelemetryDeck/KotlinSDK/maven-metadata.xml
     Required by:
         project :app > project :telemetrydecksdk

And when I add maven { url 'https://jitpack.io' } to build.gradle I get the following:



* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve com.github.TelemetryDeck:KotlinSDK:+.
     Required by:
         project :app > project :telemetrydecksdk
      > Could not resolve com.github.TelemetryDeck:KotlinSDK:2.0.1.
         > Could not get resource 'https://jitpack.io/com/github/TelemetryDeck/KotlinSDK/2.0.1/KotlinSDK-2.0.1.module'.
            > Could not GET 'https://jitpack.io/com/github/TelemetryDeck/KotlinSDK/2.0.1/KotlinSDK-2.0.1.module'.
               > Read timed out```
roygroothulze commented 8 months ago

I got the same issue.

novas1r1 commented 8 months ago

I've got the same issue for Android, for iOS everything works.

Here's my flutter doctor: `[✓] Flutter (Channel stable, 3.19.2, on macOS 14.2.1 23C71 darwin-arm64, locale de-DE) • Flutter version 3.19.2 on channel stable at /Users/verenazaiser/development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 7482962148 (3 weeks ago), 2024-02-27 16:51:22 -0500 • Engine revision 04817c99c9 • Dart version 3.3.0 • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/verenazaiser/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15E204a • CocoaPods version 1.14.3

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] VS Code (version 1.87.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.84.0`

kkostov commented 8 months ago

The Flutter plugin wraps the native KotlinSDK and so it requires that build.gradle in the flutter app be extended to include the jitpack repository:

./android/build.gradle:

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://www.jitpack.io' }
    }
}
...

It seems that the maven repository over at jitpack.io is intermittently very slow to respond and causing a timeout when Gradle attempts to build the app. When this happens, the following error appears in the log:

...
> Could not resolve com.github.TelemetryDeck:KotlinSDK:2.0.1.
         > Could not get resource 'https://jitpack.io/com/github/TelemetryDeck/KotlinSDK/2.0.1/KotlinSDK-2.0.1.module'.
            > Could not GET 'https://jitpack.io/com/github/TelemetryDeck/KotlinSDK/2.0.1/KotlinSDK-2.0.1.module'.
               > Read timed out

I will prepare a PR allowing the KotlinSDK to be published to Maven Central in order to avoid the connectivity issues related to jitpack (and also simplify the steps needed to run it on Android).

In the meantime, while testing I noticed that adding jitpack with https://www.jitpack.io instead of https://jitpack.io made it so gradle was able to download the dependency successfully. Another work-around would be to increase the gradle timeout for your app by adapting the gradle.properties.

kkostov commented 4 months ago

@winsmith I recall our discussion that we'd continue using Jitpack for the time being, though it does seem to belong to the papercut label as it is recurring from time to time (e.g. #13).

Publishing to central will simplify the client side story as maven central is usually already added to every project. One could also consider a self-hosting the repository (so the publishing process will be simpler than Sonatype) - For example, a mirror of this repository can be setup using https://forgejo.org/ (or alternative) to provide a public Maven source e.g.:

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://code.telemetrydeck.com' } <--- instead of jitpack
    }
}