ZGameEditor & Android Setting

All topics about ZGameEditor goes here.

Moderator: Moderators

User avatar
Rado1
Posts: 770
Joined: Wed May 05, 2010 12:16 pm

Postby Rado1 » Fri Apr 25, 2014 3:59 pm

Android SDK compiler has already done it for you. Just visit the generated bin folder. It contains a file named <app name>-debug.apk.

BTW if you are developing for OUYA, there's a new video tutorial for OUYA controller, see https://www.youtube.com/watch?v=99y2JBY ... Oz_qaU634A It contains also the description of the building and installation process.

User avatar
Ats
Posts: 127
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: ZGameEditor & Android Setting

Postby Ats » Mon Jul 09, 2018 11:50 am

Hi, I'm currently pushing Omeganaut to Google Play, and I must say that I'll have a little problem by the end of the month:

Target API level requirements from August 2018
Warning:

Your app currently targets API level 16 and must target at least API level 26 to ensure it is built on the latest APIs optimized for security and performance.

From August 2018, new apps must target at least Android 8.0 (API level 26).
From November 2018, app updates must target Android 8.0 (API level 26).


Does that mean that ZGE should update the compilation version to 26 instead of 16?
Or do I have something to set up in the magical AndroidManifest.xml file?

User avatar
VilleK
Site Admin
Posts: 1912
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: ZGameEditor & Android Setting

Postby VilleK » Mon Jul 09, 2018 12:53 pm

Hi, I was not aware of this :).

Perhaps it is enough to manually edit the AndroidManifest.xml file and set minSdkVersion to "26"?

User avatar
Ats
Posts: 127
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: ZGameEditor & Android Setting

Postby Ats » Mon Jul 09, 2018 11:02 pm

The problem is if I just change minSdkVersion to 26, the game won't run on "old" phones. And if I push that to the play store, I won't be able to go back afterwards. I already had that problem with another game. Here's what I need to do:

Code: Select all

<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />

But ZGE rewrites AndroidManifest.xml file when compiling, so it removes my precious lines. I tried to convert that file to read only, but then it won't compile. What should I do?

Edit:
So I tried to replace the AndroidManifest.xml afterwards, using:

  • Decompile: java -jar /usr/local/bin/apktool.jar decode Omeganaut.apk -o app -f
  • Replace AndroidManifest.xml
  • Compile: java -jar /usr/local/bin/apktool.jar build app -o Omeganaut_new.apk
  • Sign APK: jarsigner -verbose -keystore KEY.keystore Omeganaut_new.apk NAME
  • Align APK: zipalign -f -v 4 Omeganaut_new.apk Omeganaut_aligned.apk

Now the APK works, but Google Play don't want it anymore:
You uploaded an APK with an invalid signature (learn more about signing). Error from apksigner: ERROR (Jar signer NAME.RSA): JAR signature META-INF/NAME.RSA uses digest algorithm SHA-256 and signature algorithm RSA which is not supported on API Level(s) 16-17 for which this APK is being verified


I spent all day trying to do add android:targetSdkVersion="26" to the apk, I'm a bit fed up...
I just need ZGE to not touch AndroidManifest while building the apk.


Edit 2:
One last test before going to bed. I can't go to sleep after such a defeat.
And I managed to change my line!!! The problem was coming from another little change in the manifest:
Replacing only <uses-sdk android:minSdkVersion="16" /> by <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" /> works.
But I was also replacing android:screenOrientation="landscape" by android:screenOrientation="sensorLandscape", and that one triggered the replacement of my manifest by a new one made by ZGE.

Maybe ZGE is detecting that this parameter is different from the one selected in the build window?
Image

VilleK, if that's the case, can you add sensorLandscape to the options?

User avatar
Ats
Posts: 127
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: ZGameEditor & Android Setting

Postby Ats » Tue Jul 10, 2018 12:29 am

And it's getting worse...

With <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" /> the ClearColor doesn't seem to work anymore and gives me a white screen instead of a black one...

Image

Also, the Store only allows the game on a very few number of devices (mines are not included, classic), because it says that:

Doesn't support required feature <uses-feature>
- android.hardware.audio.low_latency


Without more explanations.
So with low_latency on, it runs only on 2814 devices.
When that line is removed, it runs on 14324 devices (including mines, such as old Galaxy S6).

What is the purpose of android.hardware.audio.low_latency for ZGE?


Edit:
And I can't roll back to minSdkVersion="16"... I should have seen that coming....

Problem:
Users that have the APK with version code 180710, which targets SDK 23 or higher, will receive an error when they attempt to upgrade to this APK because it targets SDK 16.

Resolution:
Ensure that your release includes APKs targeting SDK 23 or higher to which all users that have the APK with version code 180710 can upgrade.



Edit 2:
By pure luck, the black background is back on target 23, the low latency is deactivated but everything seems to work, and Google Play is finally willing to take my apk. I've been on that since 9AM. It's now almost 3AM. Yeah google... And I'll still have to update to target 26 by november 2018. Countdown is ticking :evil:

User avatar
VilleK
Site Admin
Posts: 1912
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: ZGameEditor & Android Setting

Postby VilleK » Tue Jul 10, 2018 8:52 am

Sorry you are having such a struggle with this. Its been a while since I did any Android development so I don't have any current knowledge I'm afraid. But if you manually edit the xml-file then there should be a m.bat file in the project path that you can use to rebuild the apk? The apk is a zip file but it must be digitally signed and encrypted to work on actual device, the m.bat should take care of that unless I remember incorrectly.

User avatar
Ats
Posts: 127
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: ZGameEditor & Android Setting

Postby Ats » Thu Jul 12, 2018 7:58 am

Thanks VilleK. I didn't think about that folder. And I just discovered the file Library.xml too :oops:

Is it possible that you add a "custom" option to line 1273 in ZApplication.pas ?

Code: Select all

{$ifndef minimal}List.GetLast.SetOptions(['2.2 (API Level 8)','4.1 (API Level 16)']);

so one can add a "custom" folder in ZGameEditor/Android/Template and mess around with the parameters without touching base or 4.1 folders' settings

User avatar
VilleK
Site Admin
Posts: 1912
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: ZGameEditor & Android Setting

Postby VilleK » Thu Jul 12, 2018 8:20 am

After ZGE copied the template files to your project folder it should not overwrite them again if you have modified the files. So you should be able to experiment in your project folder? If you find settings that work with API level 23 then let me know and I'll make a template folder for that.

User avatar
Ats
Posts: 127
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: ZGameEditor & Android Setting

Postby Ats » Thu Jul 12, 2018 10:45 am

No. As I told two days ago, there are some options that you can change in the manifest, and some others that you can't, otherwise it triggers the replacement of the project files by the template files.

For instance:
replacing
android:screenOrientation="landscape" >
by
android:screenOrientation="sensorLandscape" >

Also I've compiled to target 23 in order to make it available on Google Play. But I think I'll try to make target 26 works instead, since it will be the new requirement by next month:

From August 2018, new apps must target at least Android 8.0 (API level 26).
From November 2018, app updates must target Android 8.0 (API level 26).

User avatar
Ats
Posts: 127
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: ZGameEditor & Android Setting

Postby Ats » Fri Jul 13, 2018 8:45 am

Debugging that kind of stuff is not my thing, so I have to read a lot of stuff online and I'm advancing very slowly :lol:
Here's my little progress:

When compiled to target API 23, the apk crashes on recent phones (ex: Nokia 6.1, Huawei Honor View 10) with this log:

Code: Select all

java.lang.UnsatisfiedLinkError:
  at java.lang.Runtime.loadLibrary0 (Runtime.java:1016)
  at java.lang.System.loadLibrary (System.java:1657)
  at org.zgameeditor.Zge.<init> (Zge.java:78)
  at org.zgameeditor.ZgeActivity.onCreate (ZgeActivity.java:48)
  at android.app.Activity.performCreate (Activity.java:7036)
  at android.app.Activity.performCreate (Activity.java:7027)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1215)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2731)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2856)
  at android.app.ActivityThread.-wrap11 (Unknown Source)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1589)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:164)
  at android.app.ActivityThread.main (ActivityThread.java:6501)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:438)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:807)


When compiled to target API 26, the apk is behaving weird on "old" phones (see above screenshot: viewtopic.php?p=8746#p8738)
  • Light is overexposed on 3d models
  • ClearColor background is pure white
  • Sprites particles and fonts are OK
  • Models with materials and bitmap textures will appear ok, depending on the texture.
    In the ZPong.zgeproj example, only the bars are ok. The ball is pure white.

This weird bug appeared with Android 7.0 API 24 which introduced OpenGL ES 3.2 API. (I tested all Android API)
https://developer.android.com/about/ver ... ndroid-7.0

On recent phones, target API 26 will just close the apk at launch, without a crash log.

User avatar
VilleK
Site Admin
Posts: 1912
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: ZGameEditor & Android Setting

Postby VilleK » Fri Jul 13, 2018 1:51 pm

Debugging on Android is indeed very difficult :). I guess that before you get that exception there is shown some other message in the android log that explains why the library cannot be loaded. Can you debug and display the android log? The "r.bat" file in the project folder used to do that, iirc.

User avatar
Ats
Posts: 127
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: ZGameEditor & Android Setting

Postby Ats » Sun Jul 15, 2018 9:26 am

So I started a list of the tested devices so I can try to find why it is working, or not. It appears that it is working mainly on my phone...
https://docs.google.com/spreadsheets/d/ ... sp=sharing

And I managed to resurect an old Sony Xperia Z3 compact where the game crashes. Here's the log:
build.board: MSM8974
build.bootloader: s1
build.brand: Sony
build.cpu_abi: armeabi-v7a
build.cpu_abi2: armeabi
build.device: D5803
build.display: 23.5.A.1.291
build.fingerprint: Sony/D5803/D5803:6.0.1/23.5.A.1.291/2769308465:user/release-keys
build.hardware: qcom
build.host: BuildHost
build.id: 23.5.A.1.291
build.manufacturer: Sony
build.model: D5803
build.product: D5803
build.radio: unknown
build.serial: YT91124MHY
build.tags: release-keys
build.time: 1467083751000
build.type: user
build.user: BuildUser
version.codename: REL
version.incremental: 2769308465
version.release: 6.0.1
version.sdk_int: 23

07-10 20:20:01.096 I/Timeline(3464): Timeline: Activity_launch_request id:com.txori.omeganaut_debug time:5828423
07-10 20:20:01.097 I/ActivityManager(928): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.txori.omeganaut_debug/org.zgameeditor.ZgeActivity bnds=[538,814][716,1002]} from uid 10106 on display 0
07-10 20:20:01.143 I/ActivityManager(928): Start proc 23499:com.txori.omeganaut_debug/u0a237 for activity com.txori.omeganaut_debug/org.zgameeditor.ZgeActivity
07-10 20:20:01.327 E/linker (23499): /data/app/com.txori.omeganaut_debug-1/lib/arm/libzgeandroid.so: has text relocations
07-10 20:20:01.330 E/AndroidRuntime(23499): Process: com.txori.omeganaut_debug, PID: 23499
07-10 20:20:01.330 E/AndroidRuntime(23499): java.lang.UnsatisfiedLinkError: dlopen failed: /data/app/com.txori.omeganaut_debug-1/lib/arm/libzgeandroid.so: has text relocations
07-10 20:20:01.332 D/ActivityManager(928): New dropbox entry: com.txori.omeganaut_debug, data_app_crash, 4f7a766a-d979-436e-99e2-92f925329316
07-10 20:20:01.343 W/ActivityManager(928): Force finishing activity com.txori.omeganaut_debug/org.zgameeditor.ZgeActivity
07-10 20:20:01.586 I/WindowManager(928): Screen frozen for +392ms due to Window{cc8ddd5 u0 Application Error: com.txori.omeganaut_debug}
07-10 20:20:01.951 W/ActivityManager(928): Activity

User avatar
Kjell
Posts: 1644
Joined: Sat Feb 23, 2008 11:15 pm

Re: ZGameEditor & Android Setting

Postby Kjell » Sun Jul 15, 2018 10:42 am

Hi guys,

Apparently you're not allowed to load a shared library with text relocations anymore since SDK 23 .. here's a snippet from the "Android 6.0 Changes" document.

On previous versions of Android, if your app requested the system to load a shared library with text relocations, the system displayed a warning but still allowed the library to be loaded. Beginning in this release, the system rejects this library if your app's target SDK version is 23 or higher. To help you detect if a library failed to load, your app should log the dlopen(3) failure, and include the problem description text that the dlerror(3) call returns. To learn more about handling text relocations, see this guide.

So it's pretty weird that it doesn't crash on the Samsung Galaxy S6 and ZTE BLADE A520.

K

User avatar
Ats
Posts: 127
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: ZGameEditor & Android Setting

Postby Ats » Sun Jul 15, 2018 11:46 pm

Nice finding Kjell. I tried to follow the Hardened/Textrels Guide without sucess. And even if I could make it work, I wouldn't know what to do with the decompiled assembly lines...
So I took a look directly at the file that gives libzgeandroid.so and I think I found a little error:
https://github.com/VilleKrumlinde/zgame ... ndroid.pas

Isn't line 142 missing a ; ??

Other than that, I absolutely don't know what to do. I'm going back at making the game instead of trying to run it on Android. If someone who knows what he is doing wants to continue, maybe that could help: https://bugs.freepascal.org/view.php?id=31764

User avatar
Kjell
Posts: 1644
Joined: Sat Feb 23, 2008 11:15 pm

Re: ZGameEditor & Android Setting

Postby Kjell » Sun Jul 15, 2018 11:58 pm

Hi Ats,

Ats wrote:Isn't line 142 missing a ; ??

Nope .. in Pascal / Delphi any statement preceding the end keyword isn't required to be closed with a semicolon.

K


Return to “General discussion”

Who is online

Users browsing this forum: No registered users and 2 guests