Unreal with Custom Android Activity

Hi All,

I need your help. Am struggling with this bug for sometime. Thanks for your help.

Do let me know if you need more information.

I am developing a game with custom android activities. So I created a sample project and changed the source code to handle custom android activity. I got it to compile and build the app properly, but when I run it, i get an error message. The log cat has the following error message:



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


Here is my apps manifest:



<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>


Also Here are my apps folder structure and the various android files:

Thanks

Try moving the library metadata back to GameActivity. SplashActivity passes control to it and it is where the libraries UE4 needs are loaded.

Hi ,

Thanks for your quick reply. I did add the meta data in the manifest. It still get the same message. Here is the change to the manifest file:



 <activity android:name="com.epicgames.ue4.GameActivity" android:label="@string/app_name" android:theme="@style/UE4SplashTheme"   android:configChanges="screenSize|orientation|keyboardHidden|keyboard">
      <meta-data android:name="android.app.lib_name" android:value="UE4" />
    </activity>


Thanks

Try removing the android:launchMode=“singleTask” from your activity. What exactly are you doing in it?

Hi ,

I am not trying to create a game, I am using unreal for simulations and 3d animations. I am trying to add my custom activities for the android app. So I had to change the C# scripts that build and deploy android apk. I am able to execute my activity using the AM command line tool. However, I have been getting this error, I am unable to figure out why this bug is happening. Not sure why android is unable to recognize the libUE4.so…

I did remove the ‘singleTask’ parameter in the manifest and I still get the same error.

Thanks

UE4 runs native and it handles all the events. GameActivity is the base for initialization and for some JNI activity but it is really a native application and expects to be the main loop.

Hi Guys,

I was looking into the error log leading up to the bug and I noticed a Warning message that I think is causing this issue. Here is the warning message:

05-23 18:04:39.503 30674 30674 W linker : /data/app/com.MyTestCompany.puzzle-1/lib/arm/libUE4.so: is missing DT_SONAME will use basename as a replacement: “libUE4.so”

I am thinking that this is what is causing this bug. I am not sure why I have to manually mention the DT_SONAME. From what I understand, SONAME is used for library versioning. I am also not sure as to what version number should I mention ?

I will have to look into this further. If you guys know anything about this, do let me know before I test this theory out.

Thanks

It isn’t the DT_SONAME. This is fixed in 4.12, but doesn’t really cause any issue other than a toast in later Android versions.

I got it to work. The problems I noticed seems specific to my project and I don’t know why this is so. Here is what I found:

  1. For some reason, the method MakeApk in UEDeployAndroid.cs delets the files as part of the clean up. During the clean-up, it also deletes the project’s build.xml. You can see this in line 1936 in the file UEDeployAndroid.cs. I am not sure why the cleanup deletes the build.xml. Now since the build.xml is deleted, the Ant does not build the project. Hence I had to run the command ‘android update project’.

  2. Everytime the UE editor updates the project, it seems to create a new version the native library libUE4.so. Hence it is not finding the library when I run the GameActivity.java. I was able to use dumpsys to find out the folder path and the native library versions. Deleting the olde packages before reinstalling works.

Thanks