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

How to run the example project? #9

Closed
akbarxie opened this issue Jul 24, 2017 · 13 comments
Closed

How to run the example project? #9

akbarxie opened this issue Jul 24, 2017 · 13 comments

Comments

@akbarxie
Copy link

akbarxie commented Jul 24, 2017

我使用的是android studio,不知道你的example project是基于什么平台开发的,怎样才能把它加入到android project中?

@akbarxie akbarxie changed the title How to run zhe example project? How to run the example project? Jul 24, 2017
@nihui
Copy link
Member

nihui commented Jul 24, 2017

导入 ant 工程

@dangbo
Copy link

dangbo commented Jul 24, 2017

@dodola 安装失败

@lijian8454088
Copy link

@dodola 直接下载失败

@nihui
Copy link
Member

nihui commented Jul 24, 2017

首先编译好 ncnn,或者用 releases 里头编译好的 ncnn android lib
jni 目录里调整 Android.mk 里头的路径 NCNN_INSTALL_PATH,ndk-build
工程目录里 ant debug

@lybvinci
Copy link

最最开始,按照up主文档,编译.a文件。
然后用android studio 导入功能example,导入Eclipse工程类似项目的那个选项,等待生成完毕。在app目录下的build.gradle 安卓中括号里面配置如下:
sourceSets.main {
jniLibs.srcDirs = ["src/main/libs"]
jni.srcDirs=[]
}
手动打开到jni目录,用命令行执行 ndk-build 没有问题,应该就编译安卓so到libs目录下。再run到设备上。

@telefire
Copy link

telefire commented Jul 25, 2017

hi, 最新的Android SDK的tools里已经没有 ant了,所以 ant debug编译不了。。。
lybvinci的方法直到 ndk-build都是没有问题的, libs 文件夹会被编译到 ncnn/examples/squeezencnn 下,但是运行 Android Studio project会报错

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.tencent.squeezencnn-2/base.apk"],nativeLibraryDirectories=[/data/app/com.tencent.squeezencnn-2/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "libsqueezencnn.so"

sourceSets.main {
jniLibs.srcDirs = ["src/main/libs"]
jni.srcDirs=[]
}

改成

sourceSets.main {
jniLibs.srcDirs = ["libs"]
jni.srcDirs=[]
}

libsqueezencnn.so 还是找不到,不知道如何解决这个lib引用不到的问题。。。。

@akbarxie
Copy link
Author

@lybvinci ,我按照你的方法试了一下,android studio生产了一个squeezencnn的项目,不过
image
Error:error: ld returned 1 exit status
在编译的时候还是有出现链接不成功的问题。不知道你有没有遇到,有什么解决方法

@akbarxie
Copy link
Author

一行一行的检查之后,我找到了问题是这一行导致的
static ncnn::Net squeezenet;(squeezencnn_jni.cpp)
是这一行导致的

@ccnuxjg
Copy link

ccnuxjg commented Jul 26, 2017

image

编译出错?是我的姿势出错了么?

@nihui
Copy link
Member

nihui commented Jul 26, 2017

libncnn.a 的架构和 app 的不一样,比如 libncnn.a 并没有编译 android x86 的版本

@ccnuxjg
Copy link

ccnuxjg commented Jul 27, 2017

@nihui 去掉x86的版本就可以了,谢谢

@akbarxie
Copy link
Author

akbarxie commented Jul 27, 2017

我也说一下我的问题吧,用@lybvinci 的方法可以实现构造ncnn的例子。只需要在build.gradle(app)在defaultConfig下加上这么一句:
ndk {
moduleName "ncnn"
abiFilters 'armeabi-v7a'
}
估计@ccnuxjg 也要加上这么一句就可以跑了

@dangbo
Copy link

dangbo commented Jul 29, 2017

https://github.com/dangbo/ncnn-mobile use ncnn in Android and iOS

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

No branches or pull requests

7 participants