FireFly RK3399呼叫官方FireflyAPI實現Android時導包的問題
阿新 • • 發佈:2019-01-02
這裡使用了官方給的API進行功能開發。官網在這:http://wiki.t-firefly.com/zh_CN/FireflyApi/FireflyApi.html#ru-he-zai-eclipse-zhong-shi-yong-fireflyapi
此處記錄一下存在的問題。
首先導包,按照官網的說法是先進行導包,進入官網下載的demo下的libs資料夾下,裡面包含所有的依賴包。
官網說的是用如下的方法新增:
注意官網寫的是用armeabi-v7a這個包!!,所以我就只添加了這個,但是RK3399是cortex-A72,是屬於arm64-v8a的。因此需要把這個導進去!!
把上述檔案複製到自己的工程的APP/libs目錄下,按照常規方法匯入其中的jar包,對於裡面的.so檔案也要匯入!!!
匯入方法如下:開啟如下的build.gradle檔案。
之後新增如下內容:
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
以及
task nativeLibsToJar(type: Zip, description: "create a jar archive of the native libs") { destinationDir file("$projectDir/libs") baseName "Native_Libs2" extension "jar" from fileTree(dir: "libs", include: "**/*.so") into "lib" }
上面的內容直接複製即可!
但是一定要注意位置關係!!參考下面的整體檔案!!
apply plugin: 'com.android.application' android { compileSdkVersion 28 defaultConfig { applicationId "com.example.cz.rk3399test" minSdkVersion 25 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } sourceSets { main { jniLibs.srcDirs = ['libs'] } } } task nativeLibsToJar(type: Zip, description: "create a jar archive of the native libs") { destinationDir file("$projectDir/libs") baseName "Native_Libs2" extension "jar" from fileTree(dir: "libs", include: "**/*.so") into "lib" } tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn(nativeLibsToJar) } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation files('libs/firefly-api.jar') }
之後重建專案,可以發現專案的libs資料夾之下多了一個jar檔案
這應該就是上述task把.so檔案打包成了一個jar包,可以使用了!!!!!
此處主要參考了兩個帖子:
https://blog.csdn.net/anhenzhufeng/article/details/78913341?tdsourcetag=s_pcqq_aiomsg中的方法二。
https://blog.csdn.net/growing_tree/article/details/51979706