我需要你的帮助。我有时会挣扎于这个bug。谢谢你的帮助。
如果您需要更多信息,请告诉我。
我正在开发一款带有自定义Android活动的游戏。所以我创建了一个示例项目并更改了源代码以处理自定义android活动。我得到它来正确编译和构建应用程序,但是当我运行它时,我收到一条错误消息。 log cat有以下错误消息:
6-08 14:15:37.548 14319 14319 W linker : /data/app/com.MyTestCompany.puzzle-1/lib/arm/libUE4.so: is missing DT_SONAME will use basename as a replacement: "libUE4.so"
06-08 14:15:37.720 3751 6317 D audio_hw_primary: disable_audio_route: reset and update mixer path: low-latency-playback
06-08 14:15:37.721 3751 6317 D audio_hw_primary: disable_snd_device: snd_device(2: speaker)
06-08 14:15:37.734 3751 6317 D audio_hw_primary: disable_snd_device: snd_device(71: vi-feedback)
06-08 14:15:37.735 3751 6317 D audio_hw_primary: disable_audio_route: reset and update mixer path: spkr-vi-record
06-08 14:15:37.737 3751 6317 I soundtrigger: audio_extn_sound_trigger_update_device_status: device 0x2 of type 0 for Event 0
06-08 14:15:38.194 14319 14319 D UE4 : In the JNI_OnLoad function
06-08 14:15:38.202 14319 14319 D UE4 : Path found as '/storage/emulated/0'
06-08 14:15:38.204 14319 14319 D UE4 : Font Path found as '/system/fonts/'
06-08 14:15:38.204 14319 14319 D UE4 : In the JNI_OnLoad function 5
06-08 14:15:38.224 14319 14319 D AndroidRuntime: Shutting down VM
06-08 14:15:38.240 14319 14319 E AndroidRuntime: FATAL EXCEPTION: main
06-08 14:15:38.240 14319 14319 E AndroidRuntime: Process: com.MyTestCompany.puzzle, PID: 14319
06-08 14:15:38.240 14319 14319 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.MyTestCompany.puzzle/com.epicgames.ue4.GameActivity}: java.lang.IllegalArgumentException: Unable to find native library: main
06-08 14:15:38.240 14319 14319 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
06-08 14:15:38.240 14319 14319 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
06-08 14:15:38.240 14319 14319 E AndroidRuntime: at android.app.ActivityThread.-wrap11(ActivityThread.java)
06-08 14:15:38.240 14319 14319 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
06-08 14:15:38.240 14319 14319 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
06-08 14:15:38.240 14319 14319 E AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
06-08 14:15:38.240 14319 14319 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5422)
06-08 14:15:38.240 14319 14319 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
06-08 14:15:38.240 14319 14319 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
06-08 14:15:38.240 14319 14319 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
06-08 14:15:38.240 14319 14319 E AndroidRuntime: Caused by: java.lang.IllegalArgumentException: Unable to find native library: main
06-08 14:15:38.240 14319 14319 E AndroidRuntime: at android.app.NativeActivity.onCreate(NativeActivity.java:170)
06-08 14:15:38.240 14319 14319 E AndroidRuntime: at com.epicgames.ue4.GameActivity.onCreate(GameActivity.java:266)
06-08 14:15:38.240 14319 14319 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:6251)
06-08 14:15:38.240 14319 14319 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
06-08 14:15:38.240 14319 14319 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
06-08 14:15:38.240 14319 14319 E AndroidRuntime: ... 9 more
这是我的应用清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com" android:versionCode="1" android:versionName="1.0">
<!-- Application Definition -->
<application android:label="@string/app_name" android:icon="@drawable/icon" android:hasCode="true">
<activity android:name="com.epicgames.ue4.SplashActivity" android:label="@string/app_name" android:theme="@style/UE4SplashTheme" android:launchMode="singleTask" android:screenOrientation="landscape" android:debuggable="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.hazardnetworking.unrealandroidtest2.MainActivity" android:label="@string/app_name" android:theme="@style/AppTheme" android:configChanges="screenSize|orientation|keyboardHidden|keyboard" android:launchMode="singleTask" android:screenOrientation="landscape" android:debuggable="true">
<meta-data android:name="android.app.lib_name" android:value="UE4" />
</activity>
<activity android:name="com.epicgames.ue4.GameActivity" android:label="@string/app_name" android:theme="@style/UE4SplashTheme" android:configChanges="screenSize|orientation|keyboardHidden|keyboard">
</activity>
<activity android:name=".DownloaderActivity" android:screenOrientation="landscape" android:configChanges="screenSize|orientation|keyboardHidden|keyboard" android:theme="@style/UE4SplashTheme" />
<meta-data android:name="com.epicgames.ue4.GameActivity.DepthBufferPreference" android:value="0" />
<meta-data android:name="com.epicgames.ue4.GameActivity.bPackageDataInsideApk" android:value="false" />
<meta-data android:name="com.epicgames.ue4.GameActivity.bVerifyOBBOnStartUp" android:value="false" />
<meta-data android:name="com.epicgames.ue4.GameActivity.bShouldHideUI" android:value="false" />
<meta-data android:name="com.epicgames.ue4.GameActivity.ProjectName" android:value="PuzzleTestProject2" />
<meta-data android:name="com.epicgames.ue4.GameActivity.bHasOBBFiles" android:value="false" />
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/app_id" />
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<service android:name="OBBDownloaderService" />
<receiver android:name="AlarmReceiver" />
</application>
<!-- Requirements -->
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="com.android.vending.CHECK_LICENSE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
</manifest>
感谢您寻找
答案 0 :(得分:1)
您的元数据错误: main 是默认的本机库名称,如果未在清单中指定,请参阅https://developer.android.com/reference/android/app/NativeActivity.html
或者您的派生活动可能会忽略清单。 NativeActivity不是为了扩展而构建的,所以你应该格外小心。
答案 1 :(得分:0)
我得到了它的工作。我注意到的问题似乎与我的项目有关,我不知道为什么会这样。这是我发现的:
1)由于某种原因,UEDeployAndroid.cs中的MakeApk方法会删除文件,作为清理的一部分。在清理期间,它还会删除项目的build.xml。您可以在文件UEDeployAndroid.cs中的第1936行看到这一点。我不确定为什么清理会删除build.xml。现在,由于删除了build.xml,因此Ant不会构建项目。因此我不得不运行命令'android update project'。我能够使用命令行构建工具来继续构建过程。
2)每次UE编辑器更新项目时,它似乎都会创建本地库libUE4.so的新版本。因此,当我运行GameActivity.java时,它找不到库。我能够使用dumpsys找出文件夹路径和本机库版本。在重新安装之前删除旧包。
由于