问题描述
我从供应商处获得了一个.so文件,该文件仅支持"arm".目前,它对我的Android应用程序运行正常.我想以某种方式分离使用Android Studio模块的实现,因此我可以按照本教程 https://www.youtube.com/watch?v=1i4I-Nph-Cw .
I have a .so file from vendor which only support "arm". Currently it works perfectly fine for my Android application. Somehow I want to separate the implementation using Android Studio module, so I can export the module as Jar following this tutorial https://www.youtube.com/watch?v=1i4I-Nph-Cw.
导出JAR时,构建过程返回错误
When I export the JAR, the build process returns an error
/Users/zoom/android-ndk-r9d/toolchains/mipsel-linux-android-4.8/prebuilt/darwin-x86_64/bin/../lib/gcc/mipsel-linux-android/4.8/../../../../mipsel-linux-android/bin/ld: skipping incompatible src/main/jniLibs/armeabi/libremote_client.so when searching for -lremote_client
/Users/zoom/android-ndk-r9d/toolchains/mipsel-linux-android-4.8/prebuilt/darwin-x86_64/bin/../lib/gcc/mipsel-linux-android/4.8/../../../../mipsel-linux-android/bin/ld: cannot find -lremote_client
collect2: error: ld returned 1 exit status
:app:linkMipsDebugRemoteDesktopSharedLibrary FAILED
FAILURE: Build failed with an exception.
日志显示gradle试图针对mips进行构建,但由于库不兼容而失败,因为我只有arm库.我的问题是如何跳过针对mips的构建过程?还是有可能只针对ARM体系结构?
The logs says that gradle was trying to build against mips but failed due the incompatible library, since I only have arm library.My question how to skip the build process against mips? Or is it possible to target ARM only architecture?
build.gradle
apply plugin: 'com.android.model.library'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "22.0.1"
defaultConfig.with {
//applicationId = "com.test.remote"
minSdkVersion.apiLevel = 19
targetSdkVersion.apiLevel = 21
//versionCode = 1
//versionName = "1.0"
}
}
android.ndk {
moduleName = "remote_client"
//CFlags += "-DANDROID_NDK"
CFlags += ['-std=c99', '-fstrict-aliasing']
ldLibs += ["log", "remoted_client"]
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.pro')
}
}
android.sources {
main {
jni {
source {
srcDir 'src/main/jni'
}
}
jniLibs {
source {
srcDir 'src/main/jniLibs'
}
}
}
}
android.productFlavors {
create("arm") {
ndk.with {
abiFilters += "armeabi"
ldFlags += "-Lsrc/main/jniLibs/armeabi"
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
}
task clearJar(type: Delete) {
delete 'mylib.jar'
}
task makeJar(type: Copy) {
from('build/intermediates/bundles/release/')
into('release/')
include('classes.jar')
rename ('classes.jar', 'mylib.jar')
}
makeJar.dependsOn(clearJar, build)
推荐答案
最后我做到了.这是禁用特定任务的示例.将此行添加到您的build.gradle
Finally I made it.Here's an example to disable specific task.Add this line on your build.gradle
tasks.getByPath(":app:linkMipsDebugRemoteDesktopSharedLibrary").enabled = false
这篇关于如何仅使用ARM目标的NDK构建基于Android Gradle的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!