这是一个普通的问题,但我在stackoverflow中找不到任何类似的问题来讨论Android SDK/NDK最近版本的解决方案。
我的目的是将Android NDK打包为apk文件。
所以:
/opt/android-ndk/ndk-build [arm64-v8a] Gdbserver : [aarch64-linux-android-4.9] libs/arm64-v8a/gdbserver [arm64-v8a] Gdbsetup : libs/arm64-v8a/gdb.setup [x86_64] Gdbserver : [x86_64-4.9] libs/x86_64/gdbserver [x86_64] Gdbsetup : libs/x86_64/gdb.setup [mips64] Gdbserver : [mips64el-linux-android-4.9] libs/mips64/gdbserver [mips64] Gdbsetup : libs/mips64/gdb.setup [armeabi-v7a] Gdbserver : [arm-linux-androideabi-4.8] libs/armeabi-v7a/gdbserver [armeabi-v7a] Gdbsetup : libs/armeabi-v7a/gdb.setup [armeabi] Gdbserver : [arm-linux-androideabi-4.8] libs/armeabi/gdbserver [armeabi] Gdbsetup : libs/armeabi/gdb.setup [x86] Gdbserver : [x86-4.8] libs/x86/gdbserver [x86] Gdbsetup : libs/x86/gdb.setup [mips] Gdbserver : [mipsel-linux-android-4.8] libs/mips/gdbserver [mips] Gdbsetup : libs/mips/gdb.setup [arm64-v8a] Compile : hello-jni libs/arm64-v8a/libhello-jni.so [x86_64] Compile : hello-jni libs/x86_64/libhello-jni.so [mips64] Compile : hello-jni libs/mips64/libhello-jni.so [armeabi-v7a] Compile thumb : hello-jni libs/armeabi-v7a/libhello-jni.so [armeabi] Compile thumb : hello-jni libs/armeabi/libhello-jni.so [x86] Compile : hello-jni libs/x86/libhello-jni.so [mips] Compile : hello-jni libs/mips/libhello-jni.so
/opt/Android-SDK-Linux/tools/Android update项目路径。-目标android-21
Buildfile: /opt/android-ndk/samples/hello-gl2/build.xml -set-mode-check: -set-debug-files: -check-env: [checkenv] Android SDK Tools Revision 24.1.2 [checkenv] Installed at /opt/android-sdk-linux -setup: [echo] Project Name: GL2JNIActivity [gettype] Project Type: Application -set-debug-mode: -debug-obfuscation-check: -pre-build: -build-setup: [getbuildtools] Using latest Build Tools: 22.0.1 [echo] Resolving Build Target for GL2JNIActivity... [gettarget] Project Target: Android 5.0.1 [gettarget] API level: 21 [echo] ---------- [echo] Creating output directories if needed... [mkdir] Created dir: /opt/android-ndk/samples/hello-gl2/bin/rsObj [mkdir] Created dir: /opt/android-ndk/samples/hello-gl2/bin/rsLibs [echo] ---------- [echo] Resolving Dependencies for GL2JNIActivity... [dependency] Library dependencies: [dependency] No Libraries [dependency] [dependency] ------------------ [echo] ---------- [echo] Building Libraries with 'debug'... [subant] No sub-builds to iterate on -code-gen: [mergemanifest] No changes in the AndroidManifest files. [echo] Handling aidl files... [aidl] No AIDL files to compile. [echo] ---------- [echo] Handling RenderScript files... [echo] ---------- [echo] Handling Resources... [aapt] No changed resources. R.java and Manifest.java untouched. [echo] ---------- [echo] Handling BuildConfig class... [buildconfig] Generating BuildConfig class. -pre-compile: -compile: [javac] Compiling 6 source files to /opt/android-ndk/samples/hello-gl2/bin/classes -post-compile: -obfuscate: -dex: [dex] input: /opt/android-ndk/samples/hello-gl2/bin/classes [dex] Found modified input file [dex] Converting compiled files and external libraries into /opt/android-ndk/samples/hello-gl2/bin/classes.dex... -crunch: [crunch] Crunching PNG Files in source dir: /opt/android-ndk/samples/hello-gl2/res [crunch] To destination dir: /opt/android-ndk/samples/hello-gl2/bin/res [crunch] Crunched 0 PNG files to update cache -package-resources: [aapt] Creating full resource package... package: [apkbuilder] Current build type is different than previous build: forced apkbuilder run. [apkbuilder] Creating GL2JNIActivity-debug-unaligned.apk and signing it with a debug key... [apkbuilder] Found duplicate file for APK: AndroidManifest.xml [apkbuilder] Origin 1: /opt/android-ndk/samples/hello-gl2/bin/GL2JNIActivity.ap_ [apkbuilder] Origin 2: /opt/android-ndk/samples/hello-gl2/AndroidManifest.xml BUILD FAILED /opt/android-sdk-linux/tools/ant/build.xml:963: The following error occurred while executing this line: /opt/android-sdk-linux/tools/ant/build.xml:974: The following error occurred while executing this line: /opt/android-sdk-linux/tools/ant/build.xml:313: com.android.sdklib.build.DuplicateFileException: Duplicate files at the same path inside the APK at com.android.sdklib.build.ApkBuilder.doAddFile(ApkBuilder.java:821) at com.android.sdklib.build.ApkBuilder.addFile(ApkBuilder.java:507) at com.android.sdklib.build.ApkBuilder.processFileForResource(ApkBuilder.java:872) at com.android.sdklib.build.ApkBuilder.addSourceFolder(ApkBuilder.java:623) at com.android.sdklib.build.ApkBuilder.addSourceFolder(ApkBuilder.java:605) at com.android.ant.ApkBuilderTask.execute(ApkBuilderTask.java:356) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68) at com.android.ant.IfElseTask.execute(IfElseTask.java:124) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68) at com.android.ant.IfElseTask.execute(IfElseTask.java:124) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:435) at org.apache.tools.ant.Target.performTasks(Target.java:456) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393) at org.apache.tools.ant.Project.executeTarget(Project.java:1364) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1248) at org.apache.tools.ant.Main.runBuild(Main.java:851) at org.apache.tools.ant.Main.startAnt(Main.java:235) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109) Total time: 2 seconds
如何克服上述编译错误?
谢谢
首先,看起来你构建了hello-jni
的本机端,然后构建并打包了hello-gl2
。这是两个不同的示例。你能确保你保持在同一个示例文件夹中吗?
我还强烈建议您将/opt/android-ndk-r10e
、/opt/android-sdk-linux/tools
和/opt/android-sdk-linux/Platform-tools
添加到您的PATH环境变量。只需将此行添加到您的~/. profile
,然后重新启动您的终端。
export PATH=${PATH}:/opt/android-ndk-r10e;/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools"
通过这种方式,您应该能够访问任何android工具,如ndk build
、adb
和android
,而无需指定它们的绝对路径。
如果这没有帮助,请尝试用蚂蚁清洁来清理和重建样品
< li >斌/ < li>gen/ < li>libs/ < li>obj/ < li>build.xml < li>local.properties < li>proguard-project.xml
然后重试:
ndk-build NDK_DEBUG=1
android update project --path . --target android-21
ant debug
一切都应该正常。如果它仍然不起作用,我建议启动
android
(无参数)以启动Android SDK管理器。确保您是最新的,并确保您安装了适用于API级别21的SDK Platform,如果这是您要使用的API级别。截至今天的最新Android SDK工具应该是版本24.2。确保您也拥有最新的android-ndk。截至今天的最新版本应该是r10e。
祝你好运
我试图建立FFMPEG库为我的Android应用程序使用NDK。我已经从它的网站上下载了源代码,我想我构建了它(这是我第一次尝试使用NDK和ffmpeg)。我已经创建了一个文件,我正在使用它从Mac OS X上的命令行执行它。 首先,我知道我需要Android。mk文件,所以我可以在我的应用程序中使用构建的库,但我不知道如何做到这一点,原因我在上面告诉过你。在我运行android文件夹中有一些文件
我在回答中使用了https://softwareengineering.stackExchange.com/A/400492/42195 方法返回一个返回委托流的调用。但这又是如何翻译成的呢?
我刚刚通过自制完成了python最新稳定版本的安装。 安装python3 一切正常。我想安装包,例如PyMongo。我没有pip。 $pip-bash:pip:未找到命令 没有自制公式: $brew安装PyMongo brew安装PyMongo错误:没有可用的公式用于PyMongo搜索公式。。。正在搜索点击。。。 当Python通过自制软件安装时,你知道在OS X上安装Pymango的最佳方式是什
问题内容: 我的应用程序中有一个响应式flexbox框,其中包含动态呈现的卡片(每个api调用呈现1-10张卡片)。除了包裹的方式外,它几乎可以完全满足我的要求。 假设我渲染了10张卡片,如果我调整屏幕大小,使其变成例如4-4-2,则最后2张卡片居中,我希望将其包裹起来,以便最后2张卡片从左侧开始并以相等的间距从上方开始。你该怎么做? 编辑以进一步说明:假设我将尺寸进一步调整为1-1-1-1-1-
Windows说明要求从下载安装程序http://www.lfd.uci.edu/~gohlke/pythonlibs/ 我的版本的链接显示为“形状1.5.13 cp27-无win_amd64.whl”。 然而,它实际上是一个zip文件,包含两个文件夹,两个文件夹都不包含. whl文件或安装程序。 请注意,问题不在于如何安装。whl文件,但为什么我看不到。whl文件。 我如何安装这个?