我曾尝试按照许多指南创建Android Native Activity,但我无法运行我的应用程序。相反,我从LogCat中获得以下内容:
05-15 07:39:21.337 I/ActivityManager( 857): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.bigdavedev.opengl/.MainActivity} from pid 1450
05-15 07:39:21.377 D/dalvikvm(23970): Late-enabling CheckJNI
05-15 07:39:21.387 I/ActivityManager( 857): Start proc com.bigdavedev.opengl for activity com.bigdavedev.opengl/.MainActivity: pid=23970 uid=10221 gids={50221, 1028}
05-15 07:39:21.507 W/Adreno-EGL( 320): <qeglDrvAPI_eglMakeCurrent:2843>: EGL_BAD_MATCH
05-15 07:39:21.507 E/libEGL ( 320): eglMakeCurrent:671 error 3009 (EGL_BAD_MATCH)
05-15 07:39:21.517 I/ActivityManager( 857): Config changes=1480 {1.0 240mcc8mnc en_GB ldltr sw360dp w598dp h335dp 480dpi nrml land finger -keyb/v/h -nav/h s.19 skinPackageSeq.1}
05-15 07:39:21.527 I/InputReader( 857): Reconfiguring input devices. changes=0x00000004
05-15 07:39:21.527 I/InputReader( 857): Device reconfigured: id=9, name='clearpad', size 1080x1920, orientation 1, mode 1, display id 0
05-15 07:39:21.577 D/dalvikvm(21541): GC_CONCURRENT freed 767K, 77% free 2600K/11244K, paused 2ms+2ms, total 32ms
05-15 07:39:21.607 D/QualcommSoftapCmd( 316): Got softap getStaList command we are passing on
05-15 07:39:21.607 D/SomcSoftapController( 316): Got info: dc:85:de:16:fc:89
05-15 07:39:21.627 D/AndroidRuntime(23970): Shutting down VM
05-15 07:39:21.627 W/dalvikvm(23970): threadid=1: thread exiting with uncaught exception (group=0x415828b0)
05-15 07:39:21.627 E/AndroidRuntime(23970): FATAL EXCEPTION: main
05-15 07:39:21.627 E/AndroidRuntime(23970): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bigdavedev.opengl/com.bigdavedev.opengl.MainActivity}: java.lang.IllegalArgumentException: Unable to find native library: main
05-15 07:39:21.627 E/AndroidRuntime(23970): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2266)
05-15 07:39:21.627 E/AndroidRuntime(23970): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2316)
05-15 07:39:21.627 E/AndroidRuntime(23970): at android.app.ActivityThread.access$600(ActivityThread.java:150)
05-15 07:39:21.627 E/AndroidRuntime(23970): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1298)
05-15 07:39:21.627 E/AndroidRuntime(23970): at android.os.Handler.dispatchMessage(Handler.java:99)
05-15 07:39:21.627 E/AndroidRuntime(23970): at android.os.Looper.loop(Looper.java:213)
05-15 07:39:21.627 E/AndroidRuntime(23970): at android.app.ActivityThread.main(ActivityThread.java:5225)
05-15 07:39:21.627 E/AndroidRuntime(23970): at java.lang.reflect.Method.invokeNative(Native Method)
05-15 07:39:21.627 E/AndroidRuntime(23970): at java.lang.reflect.Method.invoke(Method.java:525)
05-15 07:39:21.627 E/AndroidRuntime(23970): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
05-15 07:39:21.627 E/AndroidRuntime(23970): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
05-15 07:39:21.627 E/AndroidRuntime(23970): at dalvik.system.NativeStart.main(Native Method)
05-15 07:39:21.627 E/AndroidRuntime(23970): Caused by: java.lang.IllegalArgumentException: Unable to find native library: main
05-15 07:39:21.627 E/AndroidRuntime(23970): at android.app.NativeActivity.onCreate(NativeActivity.java:172)
05-15 07:39:21.627 E/AndroidRuntime(23970): at com.bigdavedev.opengl.MainActivity.onCreate(MainActivity.java:11)
05-15 07:39:21.627 E/AndroidRuntime(23970): at android.app.Activity.performCreate(Activity.java:5133)
05-15 07:39:21.627 E/AndroidRuntime(23970): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
05-15 07:39:21.627 E/AndroidRuntime(23970): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2230)
05-15 07:39:21.627 E/AndroidRuntime(23970): ... 11 more
05-15 07:39:21.627 W/ActivityManager( 857): Force finishing activity com.bigdavedev.opengl/.MainActivity
我已阅读以下问题1和2,但这些都没有对我有所帮助。我粘贴在我徒劳的努力下面,希望有人能看到我不能做的事。
的AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bigdavedev.opengl"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:hasCode="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<activity
android:name="com.bigdavedev.opengl.MainActivity"
android:label="@string/app_name"
android:screenOrientation="landscape" >
<meta-data
android:name="android.app.lib"
android:value="@string/app_name" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
MainAcitivy.java:
package com.bigdavedev.opengl;
import android.app.NativeActivity;
import android.os.Bundle;
public class MainActivity extends NativeActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
}
}
Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := bigdavedev
LOCAL_SRC_FILES := main.cpp \
dave/application/application.cpp \
dave/core/kernel.cpp \
dave/platform/android.cpp
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv2
LOCAL_STATIC_LIBRARIES := android_native_app_glue
include $(BUILD_SHARED_LIBRARY)
$(call import-module, android/native_app_glue)
Application.mk:
APP_PLATFORM := android-10
NDK_TOOLCHAIN_VERSION := 4.8
APP_STL := gnustl_shared
APP_CPPFLAGS := -std=c++11
最后,main.cpp:
#include <android_native_app_glue.h>
#include "dave/application/application.hpp"
extern "C"
{
void android_main(struct android_app* state)
{
app_dummy();
dave::application app(state);
if (app.initialise())
{
app.run();
}
}
}
此时,我确信我在没有意识到的情况下正盯着解决方案。
答案 0 :(得分:0)
事实证明,元数据标签需要看起来像:
<meta-data
android:name="android.app.lib_name"
android:value="@string/app_name" />
现在一切正常。