2017-10-28 103 views
0

我寫了一個NNAPI演示。但該應用程序崩潰的錯誤「java.lang.UnsatisfiedLinkError:dlopen失敗:無法找到符號'ANeuralNetworksModel_identifyInputsAndOutputs'」。在我刪除了包含ANeuralNetworksModel_identifyInputsAndOutputs(並保留其他關於NNAPI的行,如ANeuralNetworksModel_addOperation等)的行後,該應用程序不再崩潰。ANeuralNetworksModel_identifyInputsAndOutputs在Android 8.1預覽版NNAPI中的UnsatisfiedLinkError

我的minSdkVersion,compileSdkVersion,targetSdkVersion都是27

它是一個錯誤,或者只是我的錯嗎?你可以幫我嗎?提前致謝。


得益於優秀的解決方案之後,我寫了NNAPI包裝庫和演示,並發表了GitHub,只需要四行部署在手機的典範。我希望我的項目能夠幫助那些對NNAPI感興趣的開發人員

回答

3

不幸的是,在NDK發佈之前請求的NN API發生了一些變化,並沒有及時將其轉換爲O MR 1 Beta 1。換句話說,NDK比測試圖像更新。當下一個O測試版(或發行版?我實際上不確定時間軸是什麼)啓動時,這將自行解決。

與此同時,該功能在測試版中的名稱是ANeuralNetworksModel_setInputsAndOutputs。像下面這樣的東西應該可以工作,並且會在您可以刪除解決方法時通知您(請注意:我沒有測試過這個功能,因爲我沒有運行測試版的設備,所以可能需要稍作修改)。

// TODO: Remove when O MR1 Beta 2 is available. 
__attribute__((weak)) 
extern "C" int ANeuralNetworksModel_setInputsAndOutputs(
    uint32_t inputCount, const uint32_t* inputs, uint32_t outputCount, 
    const uint32_t* outputs); 

extern "C" int ANeuralNetworksModel_identifyInputsAndOutputs(
    uint32_t inputCount, const uint32_t* inputs, uint32_t outputCount, 
    const uint32_t* outputs) { 
    if (ANeuralNetworksModel_setInputsAndOutputs == nullptr) { 
    __android_log_print(ANDROID_LOG_ERROR, 
     "ANeuralNetworkdModel_setInputsAndOutputs not found. Remove workarounds."); 
    abort(); 
    } 
    return ANeuralNetworksModel_setInputsAndOutputs(
    inputCount, inputs, outputCount, outputs); 
} 
0

由於SDK包不正確,所以發生此問題。將SDK包更新到最新版本。 如果SDK管理器沒有顯示任何更新,那麼在Android Studio中,從File菜單中選擇Invalidate Caches and Restart選項。 完成此操作後,Android工作室將詢問是否有任何未決的SDK更新。 安裝更新後,使用AVD管理器重新創建新的虛擬設備(如果使用的是虛擬設備)。 而你的程序已經準備好去...

SDK \系統圖像\ Android的27 \ google_apis \ 86 \ source.properties

Pkg.Desc=System Image x86 with Google APIs. 
    ****Pkg.Revision=2**** 
    Pkg.Dependencies=emulator#26.1.3 
    ****AndroidVersion.ApiLevel=27**** 
    SystemImage.Abi=x86 
    SystemImage.TagId=google_apis 
    SystemImage.TagDisplay=Google APIs 
    SystemImage.GpuSupport=true 
    Addon.VendorId=google 
    Addon.VendorDisplay=Google Inc.