Flex Project - Run on iOS Simulator - Null Pointer Exception

Answered

I get a Java Null Pointer exception when I attempt to run any Flex AIR app (including the default template project) with IntelliJ on the iOS Simulator.

The iOS Simulator works fine from Adobe Animate CC.

I can reproduce the Null Pointer exception using the command line.

/Applications/Intellij\ IDEA.app/Contents/jre/jdk/Contents/Home/jre/bin/java -Dapplication.home=/Users/adamgering/Src/SDK/Flex4.14 -Dfile.encoding=UTF-8 -Djava.awt.headless=true -Duser.language=en -Duser.region=en -Xmx512m -jar /Users/adamgering/Src/SDK/Flex4.14/lib/adt.jar -package -target ipa-test-interpreter-simulator -storetype PKCS12 -keystore /Applications/Intellij\ IDEA.app/Contents/plugins/flex/lib/temp_keystore.p12 -storepass keystore_password /Users/adamgering/Src/Proto/FlexTest/out/production/FlexTest/Main.ipa /Users/adamgering/Src/Proto/FlexTest/out/production/FlexTest/Main-ios-descriptor.xml -platformsdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk -C /Users/adamgering/Src/Proto/FlexTest/out/production/FlexTest Main.swf

unexpected failure: null
java.lang.NullPointerException
at com.adobe.air.ipa.IPAOutputStream.resignApp(IPAOutputStream.java:1006)
at com.adobe.air.ipa.IPAPackager.renameOutput(IPAPackager.java:312)
at com.adobe.air.ApplicationPackager.createPackage(ApplicationPackager.java:93)
at com.adobe.air.ipa.IPAPackager.createPackage(IPAPackager.java:283)
at com.adobe.air.ADT.parseArgsAndGo(ADT.java:604)
at com.adobe.air.ADT.run(ADT.java:446)
at com.adobe.air.ADT.main(ADT.java:496)

All the files and paths appear to exist, except for the .IPA file (which I'd presume is getting created?). I've replace the KeyStore with my own keystore and password, and that makes no difference. In fact the path can even be invalid, so it appears the error is coming earlier in the build process.

I've tested against Apache Flex 4.14 and 4.15 both, no difference.

I can package and publish the app to the AppStore without problem, but I can't run the same app on the iOS Simulator.

7 comments

The exception is thrown by the ADT tool which is a part of the AIR SDK. Which AIR SDK version is installed as a part of your Apache Flex 4.14 and 4.15 SDK? Upgrading to the latest AIR SDK may help.

Alternatively, using iOS Simulator that is older than 9.3 (that you use) also may help. The issue is between ADT tool and iOS Simulator, IDE can't help here.

0

Flex 4.91 / AIR 17 -- threw a really nasty error message regarding Apple code -- not worth posting here/debugging.

Flex 4.14 / AIR 20 -- NullPointerException

Flex 4.15 / AIR 20 -- NullPointerException

Flex 4.15 / AIR 21 -- Session could not be started: Error Domain=LaunchServicesError Code=0 "(null)" UserInfo={Error=APIInternalError, ErrorDescription=Failed to make staged container live __NSConcreteUUID 0x786550f0> ....

 

P.S. Please make IntelliJ dialogs allow text copy/paste. It's insanely bad that I have to type the error messages rather than copy/paste them.

0

So AIR 20 fails, but AIR 21 succeeds using the ADT build command. Both Flex 4.15, so it appears the reported bug is an AIR SDK problem that was fixed with AIR 21.

However, I then receive the "Session could not be started" bug. I believe that may be an IntelliJ -> iOS Simulator problem. I get a similar problem (cannot open Simulator error -- except that it does(!?)) in Adobe Flash CC 2015. That error is not present in the newer Adobe Animate CC product. Problem started after updating to Xcode 7.3.

/Applications/Intellij\ IDEA.app/Contents/jre/jdk/Contents/Home/jre/bin/java -Dapplication.home=~/Src/SDK/Flex4.15_AIR20 -Dfile.encoding=UTF-8 -Djava.awt.headless=true -Duser.language=en -Duser.region=en -Xmx512m -jar ~/Src/SDK/Flex4.15_AIR20/lib/adt.jar -package -target ipa-test-interpreter-simulator -storetype PKCS12 -keystore /Applications/Intellij\ IDEA.app/Contents/plugins/flex/lib/temp_keystore.p12 -storepass keystore_password ~/Src/Proto/FlexTest/out/production/FlexTest/Main.ipa ~/Src/Proto/FlexTest/out/production/FlexTest/Main-ios-descriptor.xml -platformsdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk -C ~/Src/Proto/FlexTest/out/production/FlexTest Main.swf

This fails with a Null Exception Pointer.

/Applications/Intellij\ IDEA.app/Contents/jre/jdk/Contents/Home/jre/bin/java -Dapplication.home=~/Src/SDK/Flex4.15_AIR21 -Dfile.encoding=UTF-8 -Djava.awt.headless=true -Duser.language=en -Duser.region=en -Xmx512m -jar ~/Src/SDK/Flex4.15_AIR21/lib/adt.jar -package -target ipa-test-interpreter-simulator -storetype PKCS12 -keystore /Applications/Intellij\ IDEA.app/Contents/plugins/flex/lib/temp_keystore.p12 -storepass keystore_password ~/Src/Proto/FlexTest/out/production/FlexTest/Main.ipa ~/Src/Proto/FlexTest/out/production/FlexTest/Main-ios-descriptor.xml -platformsdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk -C ~/Src/Proto/FlexTest/out/production/FlexTest Main.swf

This succeeds. Only difference is the first is Flex 4.15 / AIR 20, the second is Flex 4.15 / AIR 21.

 

0

Yes, NPE is a problem of AIR SDK 20 and older. I've found similar problem: https://forums.adobe.com/thread/2111044?start=0&tstart=0

To start the app on Simulator IDE also uses ADT tool from the AIR SDK. Command is 

`adt -launchApp -platform ios -platformsdk ... -device ios-simulator -appid ...`

You may try this from Terminal and ask on Adobe forum for help if it fails.

0

In summary, iOS Simulator works with AIR SDK 21; but only if the simulator is closed (not running) at the time (otherwise you get a failed to make staged container live error).

AIR SDK 21 also, however, made a breaking change with regards to HTTP requests. It may be desired/required to add the following to InfoAdditions (in the application descriptor XML):

<!-- Application does not use encryption -->
<key>ITSAppUsesNonExemptEncryption</key><false/>
<!-- Application may make HTTP requests to any domain -->
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>

0

PS. I wasted too much time before realizing I needed to select "Custom Template" on the iOS tab of Project Structure...Modules.

It's very naive for IntelliJ to believe they can auto-generate a usable application descriptor for iOS. I'd highly suggest eliminating that "feature".

0

Thanks for the update!

Yes, generated descriptor is only for a quick start with a toy project.

0

Please sign in to leave a comment.