本机活动和“无法加载本机库" [英] Native activity and "unable to load native library"

查看:99
本文介绍了本机活动和“无法加载本机库"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试基于Android NDK文件夹中的"native-activity"示例项目构建Android-10 NDK本机活动.但是,当我打开Eclipse并为项目选择运行方式-> Android应用程序"时,我的本机活动因以下运行时异常而崩溃:

I am attempting to build an Android-10 NDK native activity based on the "native-activity" sample project from the Android NDK folder. However, my native activity crashes with the following runtime exception when I open Eclipse and select "Run As -> Android Application" for my project:

02-09 03:02:12.599:E/AndroidRuntime(881):java.lang.RuntimeException:无法启动活动ComponentInfo {com.example.native_activity/android.app.NativeActivity}:java.lang.IllegalArgumentException:无法加载本机库:/data/app-lib/com.example.native_activity-1/[库名称] .so

02-09 03:02:12.599: E/AndroidRuntime(881): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.native_activity/android.app.NativeActivity}: java.lang.IllegalArgumentException: Unable to load native library: /data/app-lib/com.example.native_activity-1/[library name].so

但是,我已经确认"libs/armeabi"(等)路径中已经存在文件"lib [library name] .so".我的本机活动最终需要加载三个".so"文件,但是无论我尝试加载一个".so"文件还是全部三个".so"文件,此错误仍然存​​在.我的"AndroidManifest.xml"文件如下:

However, I have confirmed that the file "lib[library name].so" already exists in the "libs/armeabi" (etc.) paths. My native activity eventually needs to load three ".so" files, but this error persists whether I am attempting to load one ".so" file or all three ".so" files. My "AndroidManifest.xml" file is as follows:

<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.native_activity"
    android:versionCode="1"
    android:versionName="1.0">

<!-- This is the platform API where NativeActivity was introduced. -->
<uses-sdk android:minSdkVersion="9" />

<!-- This .apk has no Java code itself, so set hasCode to false. -->
<application android:label="@string/app_name" android:hasCode="false">

    <!-- Our activity is the built-in NativeActivity framework class.
         This will take care of integrating with our NDK code. -->
    <activity android:name="android.app.NativeActivity"
            android:label="@string/app_name"
            android:configChanges="orientation|keyboardHidden">
        <!-- Tell NativeActivity the name of or .so -->
        <meta-data android:name="android.app.lib_name"
            android:value="[library name]" />
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest> 
<!-- END_INCLUDE(manifest) -->

要解决此运行时异常需要做什么?

What needs to be done to fix this runtime exception?

推荐答案

在您的JNI文件夹中,"设置为什么?应将"[库名称]"名称设置为您要构建的软件包的名称.

In your JNI folder what is the "" set to ? "[library name]" name should be set as the name the package you are building.

这篇关于本机活动和“无法加载本机库"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆