Problems in Android repository Flutter TensorFlow-lite by Bintray 502

1,593

I can confirm this is working fix.Already upvoted your answer.

This is tflite build gradle plugin that i modified for my tensorflow-lite project

group 'sq.flutter.tflite'
version '1.0-SNAPSHOT'

buildscript {
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
    }
}

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

apply plugin: 'com.android.library'

android {
    compileSdkVersion 30

    defaultConfig {
        minSdkVersion 21
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    lintOptions {
        disable 'InvalidPackage'
    }

    dependencies {
        implementation 'org.tensorflow:tensorflow-lite:2.3.0'
        implementation 'org.tensorflow:tensorflow-lite-gpu:2.3.0'
    }
}

This is my current build gradle. I changed all jcenter to mavencentral to make it work. My project now work both offline and online.

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()  // Google's Maven repository
        mavenCentral()  // removed jcenter add this
    }

    dependencies {
        classpath 'com.google.gms:google-services:4.3.4'
        classpath 'com.android.tools.build:gradle:4.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()  // Google's Maven repository
        mavenCentral() // removed jcenter add this
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

By the im using TFlite plugin version 1.1.1

Gradle wrapper version

distributionUrl = https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
Share:
1,593
Nautilus
Author by

Nautilus

Updated on January 02, 2023

Comments

  • Nautilus
    Nautilus over 1 year

    When I compile my Android Flutter application I get this error

    Could not determine the dependencies of task ':app:processDebugResources'.
    > Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
       > Could not resolve org.tensorflow:tensorflow-lite:+.
         Required by:
             project :app > project :tflite
          > Failed to list versions for org.tensorflow:tensorflow-lite.
             > Unable to load Maven meta-data from https://google.bintray.com/exoplayer/org/tensorflow/tensorflow-lite/maven-metadata.xml.
                > Could not get resource 'https://google.bintray.com/exoplayer/org/tensorflow/tensorflow-lite/maven-metadata.xml'.
                   > Could not GET 'https://google.bintray.com/exoplayer/org/tensorflow/tensorflow-lite/maven-metadata.xml'. Received status code 502 from server: Bad Gateway
    

    Bintray is down for this https://google.bintray.com/exoplayer/org/tensorflow/tensorflow-lite/maven-metadata.xml

    Error 502 Server Bintray

    After this problem try to change the repository in android/build.gradle from Jcenter() to mavenCentral()

    my android/build.gradle

    buildscript {
        repositories {
            mavenCentral()
            google()
            //jcenter()
        }
    
        dependencies {
            //classpath 'com.android.tools.build:gradle:3.5.0'
            classpath 'com.android.tools.build:gradle:3.5.4'
            //classpath 'com.google.gms:google-services:4.3.5'
            classpath 'com.google.gms:google-services:4.3.4'
        }
    }
    
    allprojects {
        repositories {
            mavenCentral()
            //google()
            //jcenter()
        }
    }
    
    rootProject.buildDir = '../build'
    subprojects {
        project.buildDir = "${rootProject.buildDir}/${project.name}"
    }
    subprojects {
        project.evaluationDependsOn(':app')
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    
    

    After this change, the error continues to appear since it comes from the Google Bintray repository, but I cannot remove Google in the repositories because I use some services, what should be done to solve the problem? I know that Bintray has been down for about 10 days but I want to know how mavenCentral() can be implemented correctly for the tensor-flow-lite package.

    I am totally new and I do not know if the maven-metadata can be downloaded and how to implement it, so I need to know how to solve these dependencies, it is very complex for me.

    [UPDATE]

    Problems with dependencies by Bintray in Android [502] solved. IDE Android Studio version 4.1.1 .

    After waiting for a response from bintray and contacting me by email, I realized that finally the bintray server would be blocked since Jfrog is migrating the artifacts to Artifactory, the email response was the following "As stated in the blog post, Bintray will be sunsetted indefinitely and will not be a functional tool as we migrated the Bintray toolset into Artifactory. " This is the blog post for bintray is down

    After this, it is very likely that bintray will not be available again, or although as the email response says, migrating the artifacts would take a long time if Jfrog considers lifting the bintray server.

    To solve this and it works perfectly is:

    [1.] Check what artifacts your project requires

    [2.] Import the repositories containing the artifacts to build.gradle in the repositories

    [3.] Comment (if you wish in hope that google bintray returns) the google repository ().

    [4.] Verify the correct implementation of the dependencies

    All this will make the repositories look for the dependency that was in bintray and occupy it from the raised server that you have chosen.

    Personally my artifacts were in the maven() repositories so I made this change in the build.gradle.

    Replace google () and jCenter () in repositories with maven ().

    build.gradle

    
    buildscript {
        repositories {
            mavenCentral()
            maven {
                url 'https://maven.google.com'
            }
            //mavenCentral()
            //google()
            //jcenter()
        }
    
        dependencies {
    
            //classpath 'com.android.tools.build:gradle:3.5.0'
            classpath 'com.android.tools.build:gradle:4.1.0'
    
            //classpath 'com.google.gms:google-services:4.3.5'
            classpath 'com.google.gms:google-services:4.3.4'
        }
    }
    
    allprojects {
        repositories {
            mavenCentral()
            maven {
                url 'https://maven.google.com'
            }
            //mavenCentral()
    
            //google()
            //jcenter()
        }
    }
    
    rootProject.buildDir = '../build'
    subprojects {
        project.buildDir = "${rootProject.buildDir}/${project.name}"
    }
    subprojects {
        project.evaluationDependsOn(':app')
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    
    

    This got them repositories they needed...

    Check if you have Google Play servecies installed, it solved some problems for me.

    Also check Android Studio that you have the following installed "Google Services"

    Flutter plugin

    There is a similar answer similarthat helps this, but it does not correspond to the Android IDE and this one requires a few more small steps.

    Flutter plugins (some) despite the repository changes in build.gradle by maven () in the general project, will continue to search google.bintray repositories because the plugin itself has this repository in its build.gradle, surely this error will appear if not the following is solved.

     > Unable to load Maven meta-data from https://google.bintray.com/exoplayer/org/tensorflow/tensorflow-lite/maven-metadata.xml.
    

    This is an example with flutter plugin "tflite".

    To solve this, you have to look for the flutter plugins obtained by pubspec.yaml.

    NOTE: It is important that these changes are simply a temporary trick until google fixes the problem of its storage in bintray or although, until there are versions directed to maven (), at least this allows the application to be compiled and it works, in my case it was Well, but I say again, it is a trick and should not be done.

    [1.]At the project level, look for the flutter plugins in External libraries>Flutter pluggins>Search plugging error(example tflite). Search Flutter Pluggins

    [2.]Open the plugin and modify its build.gradle, changing the repositories where the artifact is on another server, in my case it was still in maven (). build.gradle pluggin

    Change the version of the artifact in the dependencies, if a + appears, delete it, leave a fixed version.

    Note: the "includeGroup" in repository is added so that the plugging does not look for the bintray plugin again, if you delete this or the google repository (), I don't know why the plugging keeps looking for that path, so it is better to leave it excluded so that it looks in the self-specified repositories.

    build.gradle of plugging (example tflite)

    group 'sq.flutter.tflite'
    version '1.0-SNAPSHOT'
    
    buildscript {
        repositories {//Changes here ***************
            mavenCentral()
            maven {
                url 'https://maven.google.com'
            }
            google {
                content {
                    includeGroup "https://google.bintray.com/exoplayer/org/tensorflow/tensorflow-lite/0.0.1/tensorflow-lite-0.0.1.pom"
                }
            }
    
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.2'
        }
    }
    
    rootProject.allprojects {
        repositories {
            mavenCentral()
            maven {
                url 'https://maven.google.com'
            }
            google {
                content {
                    includeGroup "https://google.bintray.com/exoplayer/org/tensorflow/tensorflow-lite/0.0.1/tensorflow-lite-0.0.1.pom"
                }
            }
        }
    }
    
    apply plugin: 'com.android.library'
    
    android {
        compileSdkVersion 27
    
        defaultConfig {
            minSdkVersion 16
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        lintOptions {
            disable 'InvalidPackage'
        }
    
        dependencies {//Changes here, delete 0.0.5+ to 0.0.5 example..
            compile 'org.tensorflow:tensorflow-lite:0.0.1-gpu-experimental'
        }
    }
    
    

    Reminder: remember to check the repository well and in the dependencies delete the version that contains +, example 0.0.5+ and change it for an existing fixed version example 0.0.2.

    If your editor says that the file does not belong to your project, select "I want to edit this file anyway".

    All these changes will cause the Flutter pluggin itself to search a server that has a complement and is functional while google does not fix this or launches a new version, possibly if you update the pubspec.yaml you can revert your own changes in the pluggin, so be careful , but this should compile you for now.