Adobe-Runtime-Support icon indicating copy to clipboard operation
Adobe-Runtime-Support copied to clipboard

Problem parsing the package

Open hadisn opened this issue 3 years ago • 32 comments

Hi, i use secureSWF from Kindi to encrypt apk file. With AIR33.1.1.345 everything works fine, but with newer sdk if I use secureSWF i can see error problem parsing the package.

I know that secureSWF software is outdated but it seems they won't release any updates, so is there someone have solution for this?

Thank you

hadisn avatar Nov 18 '21 17:11 hadisn

Hi - not sure what might have changed if you're still targeting APK creation.. depends a little on how they do things I guess because there's also the new requirement of having APK signature v2 in there. If it's just encrypting the swf file prior to packaging then it might have been okay, but if it was updating the APK itself and then reworking the signature, it may be a problem.

But, you may be able to solve it if you do have the APK as you can verify and re-sign using the apksigner tool that's part of the Android SDK tools?

Curious as to how this might work with Android App Bundles though ... or are they less of a problem anyway?

FYI we've just been playing with some encryption of a SWF; not the rest of the assets, but the SWF contents itself like you have different compression variants, there would be another variant which adds some obfuscation...

thanks

ajwfrost avatar Nov 18 '21 19:11 ajwfrost

Yes they updating apk and uses v1 signature scheme maybe that can be problem. Can you explain how to manually re-sign with apsigner tool?

Thank you

hadisn avatar Nov 18 '21 19:11 hadisn

FYI we've just been playing with some encryption of a SWF; not the rest of the assets, but the SWF contents itself like you have different compression variants, there would be another variant which adds some obfuscation...

@ajwfrost This is great news :) Can you share some details how strong obfuscation will be? Will you have encrypted strings also? I also used secureSWF, and there were some strong obfuscation levels even for breaking swf decompilers.

MalacTheLittle avatar Nov 18 '21 19:11 MalacTheLittle

Tried to resign with "apksigner sign --ks key.jks app.apk" Google Play doesn't show signature scheme v2 error but app cannot be installed on android device...

hadisn avatar Nov 18 '21 20:11 hadisn

I tried everything but not possible to get it work. These guys from Kindi are really irresponsible, they sell software and suddenly stop supporting it.

hadisn avatar Nov 18 '21 21:11 hadisn

@hadisn Just wondering, did you had app installed from Google Play while you were trying to install your apk to android device? I always need to deinstall it first to install .apk...

MalacTheLittle avatar Nov 18 '21 22:11 MalacTheLittle

Screenshot_20211118-230159_My Files

I deinstalled it and transfer apk directly to device by usb cable, apk file which is not secured by secureSWF can be installed and it have icon as you can see on screenshot but all other can't be installed and have no icon.

Also file secured and not signed with apksigner can't be uploaded to Google Play due v2 signing scheme requirement, but another file signed with apksigner can be uploaded but doesn't work...

hadisn avatar Nov 18 '21 22:11 hadisn

secureSWF also has option to process swf files only. Did you try to process swf and package it to apk with adt command line?

MalacTheLittle avatar Nov 18 '21 23:11 MalacTheLittle

I don't know command to package it and add ane and all other files.

hadisn avatar Nov 18 '21 23:11 hadisn

You can find instructions here, though here's my example: "C:\AIR_SDKs\AIR33.1.1.633\bin\adt" -package -target apk-captive-runtime -arch armv8 -storetype pkcs12 -keystore "certificate.p12" -storepass certificatePassword myApp.apk myApp-app.xml myApp.swf ... At ... you add all dependencies for your app (.ane files, data files/folders, etc.)

MalacTheLittle avatar Nov 18 '21 23:11 MalacTheLittle

Oh thank you, I forgot that i made .bat file for creating aab file with similiar command. I will let you know after testing...

hadisn avatar Nov 19 '21 00:11 hadisn

You can find instructions here, though here's my example: "C:\AIR_SDKs\AIR33.1.1.633\bin\adt" -package -target apk-captive-runtime -arch armv8 -storetype pkcs12 -keystore "certificate.p12" -storepass certificatePassword myApp.apk myApp-app.xml myApp.swf ... At ... you add all dependencies for your app (.ane files, data files/folders, etc.)

It seems that your solution works. I will do more testing and reply here.

Thank you

hadisn avatar Nov 19 '21 11:11 hadisn

Perfect! I'm glad it worked. I assumed it should since secureSWF obfuscates swf files from apk package because there lays your "open code". But for apk it needs to unpack swfs and pack em back again so probably has some problems with packing. And all you acctually need is obfuscated swf files from your app :)

MalacTheLittle avatar Nov 19 '21 11:11 MalacTheLittle

I released open testing and everything works fine for me but i see some errors in Google Play console, some of them are:

Landroid/media/AudioTrack;->getLatency()I

Ljava/nio/Buffer;->address:J

Landroid/media/AudioManager;->getOutputLatency(I)I

Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J

Should I ignore these warnings?

hadisn avatar Nov 19 '21 20:11 hadisn

Not sure what type of and how strong obfuscation levels have you set in SecureSWF, but you can check wheter these errors are caused by SecureSWF by setting obfuscation levels to zero or even just upload unsecured app to Google Play.

MalacTheLittle avatar Nov 19 '21 21:11 MalacTheLittle

I am using same obfuscation levels as for all apps currently on Google Play, but i have another question :)

I am trying to package aab and when included ane files app crashes on start, without ane it works fine.

Ane doesn't support x86 platform, so is there way to exclude x86 and x86_64 while packaging aab?

Thank you

hadisn avatar Nov 19 '21 21:11 hadisn

Sorry, can't help you with that. I'm still uploading two apk's to Play Console and will do that until aab becomes the only option :)

MalacTheLittle avatar Nov 21 '21 01:11 MalacTheLittle

Me too, but soon i think about upload new game...:)

hadisn avatar Nov 21 '21 02:11 hadisn

Ane doesn't support x86 platform, so is there way to exclude x86 and x86_64 while packaging aab?

Currently not without going through an intermediate step. We were looking to add this possibility though so that you can choose what goes into the bundle..

To do it manually you would need to change the config file in the AIR SDK lib\adt.cfg so that it has KeepAndroidStudioOutput=true uncommented. Then you should end up with an AndroidStudioProject folder that's in the same location as your app descriptor file.

Within this will be the native libraries in app\src\main\jniLibs so you can delete the ones you don't want.

You may also need to add a section like the below into the android {} section of the app\build.gradle file (alongside compileOptions):

splits {
    abi {
        enable true
        reset()
        include 'armeabi-v7a', 'arm64-v8a'
        universalApk false
    }
}

(from https://stackoverflow.com/a/58077427)

ajwfrost avatar Nov 21 '21 23:11 ajwfrost

I did it, but how to package aab now? Everything changed in app\build.gradle resets to default when I start command to package aab?

hadisn avatar Nov 22 '21 11:11 hadisn

@hadisn once you've got this folder, you can open it using Android Studio and then Build -> "Build Bundle/APK" or "Generate Signed Bundle/APK"

thanks

ajwfrost avatar Nov 22 '21 13:11 ajwfrost

@hadisn sorry for the delay -> when you see this:

java.lang.NoClassDefFoundError: com.google.android.gms.common.R$string

it's because the AAB format changed how resources were packaged in from ANEs, so I think you just need to get the latest version of the AdMob ANE to resolve this one...

thanks

ajwfrost avatar Nov 25 '21 09:11 ajwfrost

@ajwfrost thank you, I downloaded ANE and trying package it by myself because guys who nade it doesnt support it anymore, I figured that is problem with ANE but i dont know exactly where, hope I will solve this. If there is someone who is interested in this to help me, it would be good 🙂

hadisn avatar Nov 25 '21 09:11 hadisn

Ah - so actually if you have got this extracted into an Android Studio project, you may be able to solve it from there... as the ANEs will have been unpacked as part of that process...

If you look in the AndroidStudioProject folder, do you see a subfolder called something like "com.google.android.gms.common", or other similarly named (com.google.android.something) folders?

There should then be, under these, a folder structure like "src\main\res\values" and then an XML file that contains the string values.

I think it may be that the top level folder name isn't quite right e.g. it may be called "com.google.android.common" and needs to be renamed to "com.google.android.gms.common" or similar... If you do make any changes to that folder name, you need to also update the top-level 'settings.gradle' file where it lists the subfolders to include, and the 'app\build.gradle' file will have a depencency line for it starting implementation project(":...")

thanks

ajwfrost avatar Nov 25 '21 09:11 ajwfrost

Yes, I have opened it in Android Studio and I will try your suggestion, thank you very much, I really appreciate your help.

hadisn avatar Nov 25 '21 09:11 hadisn

I can't find those folders, here is screenshot of project in android studio image

hadisn avatar Nov 25 '21 10:11 hadisn

That looks like the Android Studio project for the ANE itself? (library project, plus some configuration that isn't something we generate). I had been meaning that if you use ADT to build your application, it should then generate the AndroidStudioProject folder and if you open that project in Android Studio, you should see the 'app' plus other folders that are created based on the included ANEs.

thanks

ajwfrost avatar Nov 25 '21 11:11 ajwfrost

As I mentioned before, I successfully packaged application with android studio from "AndroidStudioProject" but without ANE, now trying to make ANE compatible with it...

Yes this is project for ANE (https://github.com/pozirk/ANEAdMob)

hadisn avatar Nov 25 '21 11:11 hadisn

Yes - so I had been responding to a notification I got via email but I can't see the post in this thread any more, something may have been going a bit funny with github (or emails) perhaps.. sorry if I misunderstood! I thought that you had packaged up a bundle with the ANE and were then getting a "class not found" error due to one of the resources from the ANE not being packaged into the app bundle properly..

There may be some guidance from the below site which could help particularly if there are issues with resources: https://airsdk.dev/docs/tutorials/platform/android/custom-resources

thanks

ajwfrost avatar Nov 25 '21 11:11 ajwfrost

I never solved this, is there anyone who knows if there is AdMob ANE that works with current Adobe Air SDK, now even apk crashes on startup with AIR 33.1.1.743.

I don't know what to do anymore, too much time i spend to this so I can't focus to developing game...

hadisn avatar Feb 14 '22 16:02 hadisn