Problem with ÙŽmake apk for Android with Monkey0506 guide

Started by Mehrdad, Mon 26/06/2017 07:47:44

Previous topic - Next topic

RickJ

Quote"Basically, this is where a person should stop trying and wait for further updates" is pretty much the understatement of the year.
I have been following with great interest and am waiting patiently for further updates but this made me smile. :)

monkey0506

Quote from: Crimson Wizard on Wed 28/06/2017 16:34:54So, the biggest problem is building those native libraries for Android port?

He also edited the NDK build script, and I'm not certain that his modifications there work on Windows either, but I can't test it at all without the engine's native dependencies. I finally got an installation of Linux under Virtualbox running again (Debian 9 installer kept crashing, so I had to download a different distro). I should be able to rebuild the Android-native Allegro (etc.) and test the NDK build from Windows, or default to downloading the NDK for Linux and run it there.

Quote from: Crimson Wizard on Wed 28/06/2017 16:34:54Those libraries is probably something that should not be rebuilt every time. Would it be a viable solution if Nick could upload precompiled libraries?

Right, there's no reason that the Allegro libraries should have to be rebuilt every time the engine is rebuilt, so if they could be hosted (outside of the repo, obviously) elsewhere that would be ideal.

Quote from: RickJ on Wed 28/06/2017 18:33:21
Quote"Basically, this is where a person should stop trying and wait for further updates" is pretty much the understatement of the year.
I have been following with great interest and am waiting patiently for further updates but this made me smile. :)

Well... *sigh* Hopefully there will be a temporary fix soon, but the plugin will need to be kept up-to-date with regard to the Android engine files it uses or this whole problem will just resurface. What should be done is that the plugin should have a dependency that the Android engine files exist in an "Editor/Android" subdirectory, and if it can't copy the engine files from there then it can't deploy the APK. That way the engine files can be updated without having to rebuild the plugin.

The way things are now, the Android engine files are packed into "template.zip" from which a(n AGS) project-specific Android Studio project is created (including the engine files), and "template.zip" is packed inside the plugin! :/ Not very well planned out, but in my own defense it was thrown together as more of a proof-of-concept from which to move forward and is versioned as v0.0 (I'll keep shouting it 'til someone hears me! :=). The engine files aside, "template.zip" should almost never have to change though, so.... [/technical-details-rant]

monkey0506

I overlooked a rather obvious (albeit less than ideal) workaround to make the plugin work with AGS 3.4.0, which is simply to create a shallow copy of the "Compiled" folder's contents just before running the jobb tool.

That, and reading that Android engine libraries from the editor's directory are included in v0.0.3-alpha. You need to extract "Android.zip" into "EDITOR_DIRECTORY/Android" (so, "EDITOR_DIRECTORY/Android/armeabi/libags_parallax.so", etc.). The rest should work as previously described. I apologize for not thinking of this approach sooner. (roll)

Mehrdad

Hi . Sorry but I have black screen with new version too. Maybe my knowledge is poor and I'm wrong.
My official site: http://www.pershaland.com/

monkey0506



monkey0506

I've gotten so far as to verify that I can extract your game data file from the OBB. I haven't yet had time to investigate why it isn't working. :( I will try and get back to you with further details soon.

Mehrdad

Hi Monkey0506
Did you find time for test my apk file? Is it possible make an apk with template default AGS game ?

We haven't any PC market in Iran ( My country ). And our country is blocked for any business for Steam , GOG ,...  Instead we have a good Android market . That's why I strongly need to this port . Already I fixed Persian fonts with huge help by Crimson Wizard . And I'm waiting long time for Android port.
I'm appreciate for any help
My official site: http://www.pershaland.com/

monkey0506

I may not have time to investigate this for several weeks at least. Even if the plugin is not working, the processes it use do work. Use the jobb tool and Oceanspirit Dennis Android Studio project files available from my GitHub account. That's the best advice I can give for now.

Mehrdad

Hi

My friend found your plugin problem. Problem is about your OBB maker . He said That made an OBB with :
https://developer.android.com/studio/command-line/jobb.html

He said that removed sa.ags from my OBB and made a new OBB with it .And replace with my OBB and works fine .

It takes some works that I haven't knowledge about it.
Monkey, Please only improve your OBB maker

Mehrdad

My official site: http://www.pershaland.com/

eri0o

Hey! I am having a weird button1 that does nothing, except poping a message stating "Has JDK? True and Has Android SDK? True", once pressed with the latest release. ???

Has anyone seen this before? Also I don't have Android (or Linux) available in Build on General Settings.

My system is:

Windows 10, 64-Bits
Adventure Game Studio 3.4.1-7 Beta (downloaded from here)
Android Studio Version is 2.3.3 (built on June 6, 2017)
Java is Version 8 Update 144 (build 1.8.0_144-b01)

I got the plugin from monkey0506 github, v0.0.3-alpha here.

Other than Google Chrome and Steam (but with no games), there is nothing else installed in this computer.

EDIT: Fixed it! I forgot to copy the Android/ in the AGS Editor folder. But now, I am getting build failed...

Spoiler



FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':agsEngineLibrary'.
> failed to find target with hash string 'android-24' in: C:\Users\erico\AppData\Local\Android\sdk
BUILD FAILED

[close]

EDIT2: I installed the Nougat, which is API level 24, using the SDK Manager from Android Studio -> Tools -> Android -> SDK Manager. But Now I am getting "failed to find Build Tools revision 24.0.1". From the SDK Manager-> SDK Tools, I see I have Android SDK Tools 26.0.2 installed. There's no obvious way to get the 24.0.1 SDK from there... :/

EDIT3: Installed build tools 24.0.1. Needed to find my android sdk folder in AppData, in the bin folder, used the command line sdkmanager to install the version with sdkmanager.bat build-tools;24.0.1. Here's a picture on imgur.

EDIT4: So it build correctly ONE TIME. Now it gives me an erro in the console:
Unexpected error: Invalid name.
Parameter name: name


I have no idea what's that. The only thing I did between builds was removing the RSA Key, because the first build created an APK and an OBB file, when I kinda just wanted an APK... But now even adding the key back doesn't solve my problem...

EDIT5: Ok. I deleted everything, and download my game source again, retraced the steps, left the RSA Key empty and buid the game.apk with everything in it! YEY! Except it doesn't work. I only get a black screen and the app exits...

EDIT6: Opening the Android Studio Project I understand what Mehrdad said, because I am getting the following error (using the Android Monitor):

09-10 14:17:06.776 3417-3417/com.erio.ff D/OBB_COPY: File not found exception occurred copying expansion file: /storage/emulated/0/Android/obb/com.erio.ff/main.1.com.erio.ff.obb (No such file or directory)
09-10 14:17:06.826 3417-3417/com.erio.ff D/STORAGE: Expansion file /storage/emulated/0/Android/obb/com.erio.ff/main.1.com.erio.ff.obb not found!

eri0o

Hey, if someone knows how to generate a single .APK file (no obb) and make it work, I would be very happy. Maybe I am forgetting something but I have no idea what. Also, from the engine, can I detect it's ran on Android?

Crimson Wizard

Quote from: eri0o on Tue 12/09/2017 19:00:50Also, from the engine, can I detect it's ran on Android?

If you mean "from script", there is System.OperatingSystem which should return eOSAndroid if you are running android port.

eri0o

Yeah,I meant from script. Ok, if I manage to generate this APK I will use this to pretoggle my touch flag on the game - it sets the text that follow mouse to be fixed on bottom and some other minor adjustments I thought could be useful :) .

eri0o

Just a small update. I added my code in the repository here.

When I ran, I get the following output (in logcat):

12-26 00:39:18.147 9283-9283/? I/art: Not late-enabling -Xcheck:jni (already on)
12-26 00:39:18.147 9283-9283/? W/art: Unexpected CPU variant for X86 using defaults: x86
12-26 00:39:18.221 9283-9283/com.mythsuntold.dungeonhands W/System: ClassLoader referenced unknown path: /data/app/com.mythsuntold.dungeonhands-1/lib/x86
12-26 00:39:18.233 9283-9283/com.mythsuntold.dungeonhands I/InstantRun: starting instant run server: is main process
12-26 00:39:18.254 9283-9283/com.mythsuntold.dungeonhands D/STORAGE_MNT: SUCCESSFULLY QUEUED
12-26 00:39:18.274 9283-9283/com.mythsuntold.dungeonhands D/PATH =: /storage/emulated/0/Android/data/com.mythsuntold.dungeonhands/files/main.3.com.mythsuntold.dungeonhands.obb
12-26 00:39:18.274 9283-9283/com.mythsuntold.dungeonhands D/STATE =: 25
12-26 00:39:18.274 9283-9283/com.mythsuntold.dungeonhands D/##: Path: /storage/emulated/0/Android/data/com.mythsuntold.dungeonhands/files/main.3.com.mythsuntold.dungeonhands.obb; state: 25
                                                               
                                                                [ 12-26 00:39:18.305  9283: 9300 D/         ]
                                                                HostConnection::get() New Host Connection established 0x9f7fd840, tid 9300
12-26 00:39:18.306 9283-9300/com.mythsuntold.dungeonhands I/OpenGLRenderer: Initialized EGL, version 1.4
12-26 00:39:18.306 9283-9300/com.mythsuntold.dungeonhands D/OpenGLRenderer: Swap behavior 1
12-26 00:39:18.306 9283-9300/com.mythsuntold.dungeonhands W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
12-26 00:39:18.306 9283-9300/com.mythsuntold.dungeonhands D/OpenGLRenderer: Swap behavior 0
12-26 00:39:18.318 9283-9300/com.mythsuntold.dungeonhands D/EGL_emulation: eglCreateContext: 0x9f79dfc0: maj 2 min 0 rcv 2
12-26 00:39:18.341 9283-9300/com.mythsuntold.dungeonhands D/EGL_emulation: eglMakeCurrent: 0x9f79dfc0: ver 2 0 (tinfo 0xab0f2660)
12-26 00:39:18.359 9283-9300/com.mythsuntold.dungeonhands D/EGL_emulation: eglMakeCurrent: 0x9f79dfc0: ver 2 0 (tinfo 0xab0f2660)
12-26 00:39:18.380 9283-9300/com.mythsuntold.dungeonhands D/EGL_emulation: eglMakeCurrent: 0x9f79dfc0: ver 2 0 (tinfo 0xab0f2660)
12-26 00:39:18.381 9283-9283/com.mythsuntold.dungeonhands W/IInputConnectionWrapper: reportFullscreenMode on inexistent InputConnection

The state==25 above means I am getting the state PERMISSION_DENIED in onObbStateChange.

Spoiler
Code: ags
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.activity_main);
        expansionListener = new OnObbStateChangeListener() {
            @Override
            public void onObbStateChange(String path, int state) {
                super.onObbStateChange(path, state);
                final StorageManager storageManager =
                        (StorageManager) getApplicationContext()
                                .getSystemService(Context.STORAGE_SERVICE);
                Log.d("PATH = ", path);
                Log.d("STATE = ", state + "");
                if (state == OnObbStateChangeListener.MOUNTED) {
                    String mountedPath = storageManager.getMountedObbPath(path);
                    Log.d("STORAGE", "-->MOUNTED");
                    startGame(new File(mountedPath, GAME_FILE_NAME).getPath());
                } else {
                    Log.d("##", "Path: " + path + "; state: " + state);
                }
            }
        };
    }
[close]

eri0o

(I switched to use data folder instead of obb folder because of an API change in API23)

Edit: it appears a PERMISSION_DENIED is caused by the OBB indicating it's owned by a different package. I will try to generate it again when I am at home and see what happens.

I also remember the key string being shown as @0 instead of null by Android Studio, so two things to check!

Edit2: Ok, the error was BOTH. My command for the jobb tool was the following now:
   ~/Android/Sdk/tools/bin/jobb -d ./obb/ -o main.3.com.mythsuntold.dungeonhands.obb -pn com.mythsuntold.dungeonhands -pv 3

Also, I directly set the key to null (line 186 of MainActivity.java):

Code: ags
...
        if (!storageManager.isObbMounted(mainFile.getAbsolutePath())) {
            if (mainFile.exists()) {
                if (storageManager.mountObb(mainFile.getAbsolutePath(), null, expansionListener))  // ..., null was key, ...
...



Now I am hiting the following error:

Code: ags

12-26 19:02:53.275 4810-4810/com.mythsuntold.dungeonhands I/InstantRun: starting instant run server: is main process
12-26 19:02:53.303 4810-4810/com.mythsuntold.dungeonhands D/STORAGE_MNT: SUCCESSFULLY QUEUED
12-26 19:02:53.348 4810-4829/com.mythsuntold.dungeonhands I/OpenGLRenderer: Initialized EGL, version 1.4
12-26 19:02:53.348 4810-4829/com.mythsuntold.dungeonhands D/OpenGLRenderer: Swap behavior 1
12-26 19:02:53.349 4810-4829/com.mythsuntold.dungeonhands W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
12-26 19:02:53.349 4810-4829/com.mythsuntold.dungeonhands D/OpenGLRenderer: Swap behavior 0
12-26 19:02:53.357 4810-4829/com.mythsuntold.dungeonhands D/EGL_emulation: eglCreateContext: 0x9c63a680: maj 2 min 0 rcv 2
12-26 19:02:53.366 4810-4810/com.mythsuntold.dungeonhands D/PATH =: /storage/emulated/0/Android/data/com.mythsuntold.dungeonhands/files/main.3.com.mythsuntold.dungeonhands.obb
12-26 19:02:53.366 4810-4810/com.mythsuntold.dungeonhands D/STATE =: 1
12-26 19:02:53.367 4810-4829/com.mythsuntold.dungeonhands D/EGL_emulation: eglMakeCurrent: 0x9c63a680: ver 2 0 (tinfo 0xa617d330)
12-26 19:02:53.369 4810-4810/com.mythsuntold.dungeonhands D/STORAGE: -->MOUNTED
12-26 19:02:53.377 4810-4829/com.mythsuntold.dungeonhands D/EGL_emulation: eglMakeCurrent: 0x9c63a680: ver 2 0 (tinfo 0xa617d330)
12-26 19:02:53.429 4810-4810/com.mythsuntold.dungeonhands D/AndroidRuntime: Shutting down VM
12-26 19:02:53.432 4810-4810/com.mythsuntold.dungeonhands E/AndroidRuntime: FATAL EXCEPTION: main
                                                                            Process: com.mythsuntold.dungeonhands, PID: 4810
                                                                            java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.mythsuntold.dungeonhands-1/base.apk", zip file "/data/app/com.mythsuntold.dungeonhands-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.mythsuntold.dungeonhands-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.mythsuntold.dungeonhands-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.mythsuntold.dungeonhands-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.mythsuntold.dungeonhands-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.mythsuntold.dungeonhands-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.mythsuntold.dungeonhands-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.mythsuntold.dungeonhands-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.mythsuntold.dungeonhands-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.mythsuntold.dungeonhands-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.mythsuntold.dungeonhands-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.mythsuntold.dungeonhands-1/lib/x86, /system/lib, /vendor/lib]]] couldn't find "libagsengine.so"
                                                                                at java.lang.Runtime.loadLibrary0(Runtime.java:972)
                                                                                at java.lang.System.loadLibrary(System.java:1530)
                                                                                at com.bigbluecup.android.EngineGlue.<init>(EngineGlue.java:67)
                                                                                at com.bigbluecup.android.AgsEngine.onCreate(AgsEngine.java:182)
                                                                                at android.app.Activity.performCreate(Activity.java:6662)
                                                                                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
                                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
                                                                                at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                at android.os.Looper.loop(Looper.java:154)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
12-26 19:02:59.279 4810-4819/com.mythsuntold.dungeonhands E/PowerManager: WakeLock finalized while still held: fullwakelock
12-26 19:02:59.573 4810-4819/com.mythsuntold.dungeonhands E/System: Uncaught exception thrown by finalizer
12-26 19:02:59.574 4810-4819/com.mythsuntold.dungeonhands E/System: java.lang.IllegalStateException: Binder has been finalized!
                                                                        at android.os.BinderProxy.transactNative(Native Method)
                                                                        at android.os.BinderProxy.transact(Binder.java:615)
                                                                        at android.os.IPowerManager$Stub$Proxy.releaseWakeLock(IPowerManager.java:415)
                                                                        at android.os.PowerManager$WakeLock.finalize(PowerManager.java:1164)
                                                                        at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:222)
                                                                        at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:209)
                                                                        at java.lang.Thread.run(Thread.java:761)



updated my repository here.

And just for proof, this is an image where I open the native-libs.jar and find the 'missing' libagsengine.so inside of it: https://i.imgur.com/j1Hd1PM.png

no native libs in output of the Native Libs Monitor . :(


Edit3: IT'S WORKING!

https://github.com/ericoporto/mythsuntold_dungeonhands V.0.1.0

I had to add the code below inside     agsEngineLibrary.gradle under android:

Code: ags

    sourceSets {
        main {
            // let gradle pack the shared library into apk
            jniLibs.srcDirs = ['jniLibs']
        }
    }


I built using:
Android Studio 3.0.1
Build #AI-171.4443003, built on November 9, 2017
JRE: 1.8.0_152-release-915-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.10.0-35-generic (Ubuntu 16.04)

DOWNLOAD HERE THE APK SO FAR



I have an error saying I have to do something about midi digitpatch whatever, but audio is working! Also I need to find out why DragAndDrop doesn't work!

(I know I need to update the art one day too...)

Mehrdad

Great works Erio.Congrats!!. Maybe it's useful for MIDI :
http://www.adventuregamestudio.co.uk/forums/index.php?topic=53209.msg636536035#msg636536035

Sorry, my knowledge is poor for any help. Would you mind please lead me too to make apk+OBB when you get success?
My official site: http://www.pershaland.com/


SMF spam blocked by CleanTalk