2017-10-11 89 views
4

沒有解決當我早上Android Studio中打開了,我得到這個錯誤時,搖籃試圖同步:Tensorflow:在gradle這個

Error:(103, 13) Failed to resolve: org.tensorflow:tensorflow-android:+ 

按指令在他們Github readme,他們使用動態版本( Android Studio警告我)。它一直在前一天工作。

我曾嘗試使用他們唯一的明確的版本:1.3.0,但這種嘗試加載其語音識別模型與他們的示例代碼時會導致另一個問題:

java.lang.RuntimeException: Failed to load model from 'file:///android_asset/conv_actions_frozen.pb' 
    [...] 
Caused by: java.io.IOException: Not a valid TensorFlow Graph serialization: Shape must be rank 1 but is rank 0 for 'Mfcc' (op: 'Mfcc') with input shapes: [16000,0,257], []. 
    at org.tensorflow.contrib.android.TensorFlowInferenceInterface.loadGraph(TensorFlowInferenceInterface.java:398) 
    at org.tensorflow.contrib.android.TensorFlowInferenceInterface.<init>(TensorFlowInferenceInterface.java:97) 

我試着搜索分別爲解決方案,但導入動態版本修復它。如果還有其他解決方法,那也可以解決我的問題。

我也越來越404當我嘗試去自述與他們包庫頁:https://bintray.com/google/tensorflow/tensorflow-android

我的build.gradle文件:

apply plugin: 'com.android.application' 
apply plugin: 'com.google.firebase.firebase-crash' 
apply plugin: 'com.google.firebase.firebase-perf' 

ext { 
    grpcVersion = '1.6.1' 
} 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.3" 
    defaultConfig { 
     applicationId [HIDDEN] 
     minSdkVersion 21 
     targetSdkVersion 25 
     versionCode 1 
     versionName "a10_10" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
     debug { 
      debuggable true 
      multiDexEnabled true 
     } 
    } 

    packagingOptions { 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/INDEX.LIST' 
     exclude 'META-INF/DEPENDENCIES' 
     exclude 'META-INF/io.netty.versions.properties' 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/NOTICE.txt' 
     exclude 'META-INF/project.properties' 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
     maven { 
      url "https://maven.google.com" 
     } 
    } 
} 

buildscript { 
    repositories { 
     jcenter() 
     maven { 
      url "https://maven.google.com" 
     } 
    } 
    dependencies { 
     classpath 'com.google.gms:google-services:3.1.1' 
     classpath 'com.google.firebase:firebase-plugins:1.1.1' 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
    exclude group: 'com.android.support', module: 'support-annotations' 
}) 

    compile 'com.android.support:appcompat-v7:25.3.1' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    compile 'com.android.support:design:25.3.1' 
    compile 'com.android.support:cardview-v7:25.3.1' 
    compile 'com.android.support:recyclerview-v7:25.3.1' 
    compile 'com.google.code.findbugs:jsr305:2.0.1' 

    compile("io.grpc:grpc-okhttp:$grpcVersion") { 
     exclude group: 'com.google.code.findbugs' 
    } 
    compile("io.grpc:grpc-stub:$grpcVersion") { 
     exclude group: 'com.google.code.findbugs' 
    } 

    compile('com.google.cloud:google-cloud-speech:0.25.0-alpha') { 
     exclude group: 'com.google.cloud', module: 'google-cloud-core-grpc' 
     exclude group: 'com.google.code.findbugs' 
     exclude group: 'org.apache.httpcomponents' 
     exclude group: 'com.google.cloud', module: 'google-cloud-core' 
    } 

    compile('com.google.cloud:google-cloud-core-grpc:1.7.0') { 
     exclude group: 'com.google.cloud', module: 'google-cloud-core' 
     exclude group: 'com.google.code.findbugs' 
     exclude group: 'org.apache.httpcomponents' 
    } 

    // OAuth2 for Google API 
    compile('com.google.auth:google-auth-library-oauth2-http:0.8.0') { 
     exclude module: 'httpclient' 
    } 

    //noinspection GradleDynamicVersion 
    compile 'org.tensorflow:tensorflow-android:+' 

    compile 'commons-io:commons-io:2.5' 
    compile 'org.apache.commons:commons-lang3:3.6' 

    compile 'com.google.firebase:firebase-crash:11.4.2' 
    compile 'com.google.firebase:firebase-perf:11.4.2' 
    compile 'com.google.firebase:firebase-auth:11.4.2' 
    compile 'com.google.firebase:firebase-storage:11.4.2' 
    compile 'com.google.firebase:firebase-database:11.4.2' 
    compile 'com.google.android.gms:play-services-auth:11.4.2' 

    testCompile 'junit:junit:4.12' 
} 

apply plugin: 'com.google.gms.google-services' 
+0

你解決了這個問題嗎? –

+0

看起來他們把他們的庫移到了maven(https://mvnrepository.com/artifact/org.tensorflow/tensorflow-android)。您可以將mavenCentral()添加到build.gradle中的存儲庫以修復該存儲庫。 – Cameron

+0

非常有趣的是,添加mavenCentral()並在動態版本中實際下載1.4.0-rc0,但加載模型文件時仍然會引發異常 –

回答

1

我得到了同樣的錯誤

java.lang.RuntimeException: Failed to load model from 'file:///android_asset/conv_actions_frozen.pb' 

使用tensorflow-android 1.3.0(在這裏找到https://mvnrepository.com/artifact/org.tensorflow/tensorflow-android/1.3.0)。

但是,我能夠使用夜間構建(http://ci.tensorflow.org/view/Nightly/job/nightly-android/286/artifact/out/tensorflow.aar)運行示例語音識別應用程序。

你必須下載.aar,將其添加到您的項目,並與.aar取代

compile 'org.tensorflow:tensorflow-android:+' 

+0

這也適用於我,沒有任何例外情況發生。這是手冊,但至少它不依賴於一個存儲庫,如果他們改變了一些東西 –

+0

你用阿拉取代你的意思是什麼?我需要添加一些東西到gradle.build? –

+0

這是一篇文章,解釋如何將aar庫添加到項目https:// stackoverflow。com/questions/16682847/how-to-manually-include-external-aar-package-using-new-gradle-android-build-syst 在添加aar之後,您需要替換 compile'org .tensorflow:tensorflow-android:+' with compile(name:'tensorflow',ext:'aar') in build.gradle。 – Cameron