We are very interested in Corona Enterprise running in Android Studio as well. We want to make a plugin that uses a library built in Android Studio. Converting that library to Eclipse will be difficult and seems like the wrong way to go.
As for Eclipse, this thread might be helpful:
http://forums.coronalabs.com/topic/29297-how-i-can-start-with-eclipse/
Rob
We’ve made some progress on this recently. I have the template application building in Android Studio 1.2.1.1 by porting the original custom Ant tasks from build.xml. I’m not experienced with Gradle at all, so it’s not very pretty and doesn’t work with all the Android plugin features (product flavors specifically), but it does compile and run.
The difficulty was getting the custom tasks to hook into the predefined Android Gradle plugin build tasks in the right places. In the end I’ve started replacing the signature on the final APK because I couldn’t find a way to run the CertifyBuild.sh script without invalidating the signature added automatically by the default build tasks.
I’ve uploaded the ported version of the template app here: https://github.com/mr-seiler/gradle-corona-sample
(Documentation ranges from sparse to nonexistent, but it’s a work in progress.)
So, is it possible to get something either for Eclipse or Android?
Basically, seeing this thread, and the other about Eclipse, you won’t put effort into Eclipse because it’s replaced by Android studio (which seems fair), but you won’t look into Android Studio either?
The problem is, if we don’t have access to at least one of them and a way to build with gradle, there are tons of things we can’t do, and if we are supposed to be able to use native code, we should have a way to build at least on one of the two native IDEs.
In my case, I am trying to make Parse’s push notifications work right now, which are not supported correctly by Corona (no idea why, but there are tons of threads asking for that). So instead I want to look into integrating it natively, which should be possible, except that everything I found uses gradle and I can’t find any way to do what I need.
so if you have something working on android studio or Eclipse, or a proper gradle build script you made, it would be cool because right now there are things we just can’t do.
If some people were able to make something in gradle without knowing much about it and without having access to your source, you should be able to create a proper one without too much difficulty I think.
Right now there is one thread about Eclipse, one about Android Studio, but still no solution. We shouldn’t have to translate your build code into gradle ourselves. This should already be done, explained in a tutorial, and should work out of the box.
Or just open source this and let people fix stuff, please.
Thanks
So, is it possible to get something either for Eclipse or Android?
Basically, seeing this thread, and the other about Eclipse, you won’t put effort into Eclipse because it’s replaced by Android studio (which seems fair), but you won’t look into Android Studio either?
The problem is, if we don’t have access to at least one of them and a way to build with gradle, there are tons of things we can’t do, and if we are supposed to be able to use native code, we should have a way to build at least on one of the two native IDEs.
In my case, I am trying to make Parse’s push notifications work right now, which are not supported correctly by Corona (no idea why, but there are tons of threads asking for that). So instead I want to look into integrating it natively, which should be possible, except that everything I found uses gradle and I can’t find any way to do what I need.
so if you have something working on android studio or Eclipse, or a proper gradle build script you made, it would be cool because right now there are things we just can’t do.
If some people were able to make something in gradle without knowing much about it and without having access to your source, you should be able to create a proper one without too much difficulty I think.
Right now there is one thread about Eclipse, one about Android Studio, but still no solution. We shouldn’t have to translate your build code into gradle ourselves. This should already be done, explained in a tutorial, and should work out of the box.
Or just open source this and let people fix stuff, please.
Thanks
I’m trying to use a Java SDK that has a gradle config/setup they suggest. Can I convert it to use in Corona Enterprise or is this issue everyone is complaining about, sounds like the other way round for the complaints? Thanks, anyone?
OCG Studios, could you please explain what steps you had to take to get the project running in Android Studio?
I don’t see where in this project I would put my Corona files (i.e. the Lua files, images etc). In my existing projects, the Corona folder is outside the Android folder e.g.
ProjectDir/Android
ProjectDir/Corona/main.lua
Corona then appears to package all of the lua files into a resource.car file, and moves all of the assets into an “assets” folder in the Android folder:
ProjectDir/Android/assets/resource.car
ProjectDir/Android/assets/myImage.png
ProjectDir/Android/assets/mySFX.mp3
Also, I’ve tried just getting the sample from github to build and sign an apk (with none of my code in it yet). I had to turn off proguard in build.gradle:
minifyEnabled false //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
which is fine, but now I’m getting an error saying:
Error:Execution failed for task ':app:coronaCertifyRelease'. \> Process 'command '/Applications/CoronaEnterprise/Corona/mac/bin/CertifyBuild.sh'' finished with non-zero exit value 255
which means that the Corona signing is not working.
If you can help at all that would be greatly appreciated. In the mean time I’m going to try and work through it, and will update this post if I find anything helpful.
Edit: I’m not sure if ODG Studios post has been deleted, but it’s now disappeared. In case anyone else needs the link that was in it, the post said:
I’ve found this while searching for a way to use the Enterprise template app in Android Studio:
https://github.com/mr-seiler/gradle-corona-sample
I’ve got it running and it really works like a charm!
So far I have worked out that the Corona assets are detected if I match the existing Corona Enterprise structure and put the entire directory from the github link into an “android” directory, and put my Corona directory alongside that.
ProDir | |--android | | | |--app | |--coronaLib | |--Corona | | | |--main.lua | |--myImage.png
I noticed that one of the errors when building was that the Corona folder was not found, and this now fixes that as far as I can tell.
Somewhat strangely, just putting my Corona folder there was enough for Android Studio to detect it (without me telling it to import that directory manually), and it automatically packaged the lua files into resource.car before I’d built anything. Presumably AS is automatically invoking something in Corona?
I’m still seeing the CertifyBuild.sh error though, I’ve previously seen this on iOS builds, but never on Android builds.
Hi Alan, I’m the one who originally ported that Gradle project sample. I always meant to go back and document it better but never got around to it, so sorry you’re having to work some of this stuff out the hard way.
-
Directory structure: Correct! And that’s a nice diagram; I should add it to the readme. Also, personally when I use Android Studio with our Corona project I open the
ProDir/android
level and work on the native components from there, and handle the Corona code separately. If you’re openingProDir
in studio it may behave in ways I hadn’t considered. -
Auto packing resource.car before you built: The Corona build Gradle task is hooked into the default Android build process so that it will be run before assets are merged, see: https://github.com/mr-seiler/gradle-corona-sample/blob/master/app/build.gradle#L262 I believe that studio will run this part of the build process without explicitly requesting a build, e.g. when syncing Gradle files or when running “clean”.
-
The CertifyBuild error: That’s tough, and I don’t know off the top of my head. Maybe a few pointers:
You can see the source of the Gradle task that is invoking CertifyBuild.sh here: https://github.com/mr-seiler/gradle-corona-sample/blob/master/app/build.gradle#L288 The script depends on the CORONA_APK_PATH and CORONA_RESOURCE_CAR_PATH being set correctly; you may be able to println
those values to see that they are set to files which actually exist.
You can view the source of CertifyBuild.sh and might be able to determine if the error code 255 is specific to certain error case.
Other than that, I’m afraid I don’t have the time to dig deeper this morning but might be able to over the next few days.
Thanks Matt!
I was actually just looking for a way to get in touch with the owner of the github repo, didn’t realise it was the same one you had posted earlier in the thread.
Just a suggestion for the sample: rather than adding the diagram to the readme, would it be more foolproof to stick the current repo “root” folder into an “android” folder, add a “Corona” folder with an empty main.lua or something, and then put those into the root of the repo instead? It’s certainly not urgent if it’s easier to just update the readme, but I thought it would be simpler for people who find it in future.
Perhaps you wouldn’t mind answering another question (and perhaps this will answer the certify issue too)?
In the sample, the coronaLib/libs folder contains Corona.jar, JNLua.jar and network.jar (just like Enterprise).
I’ve copied the same jars from my own Enterprise directory, because the readme mentions that this was compiled with an older build of Enterprise - 2015.2571 (presumably it was new at the time).
I’m wondering are there any other files that I would need to copy, or anything else that I should do that is required for it to use “my” corona enterprise stuff. If I were to copy my Enterprise directory and send it to someone, it would not work because it needs to be authorised via the terminal. I’m wondering if a similar thing is happening here, maybe this sample project contains some of your enterprise files, so it’s not authorised to build correctly?
As before I’ll update this thread if I find anything out myself.
The CORONA_APK_PATH seems to be the cause of the problem. Printing out the value gives me this:
/Users/me/gradle-corona-sample-master/android/app/app-debug-unaligned.apk
but there is no file with that name there. The file does however exist here:
/Users/me/gradle-corona-sample-master/android/app/build/outputs/apk/app-debug-unaligned.apk
I’ve actually provided AS with the keystore, so it should be creating a release version anyway rather than a debug. Based on the output it seems that maybe it does both?
I see there is a comment in the gradle file about signing files that may not exist, I’m wondering if this is something to do with the error I’m encountering:
/\* After much investigation, it seems that there isn't a good place in the list of Android plugin build tasks to insert the Corona libcorona.so ceritifcation script. To early, and an APK does not exist yet for that script to unpack; one task later, and the APK exists but is already signed, so the certification script invalidates the APK signature. So, we will run the CertifyBuild script on the APK and re-sign the APK 'manually'. Desired order: package \> corona certify \> re-sign \> zipAlign \*/
Edit: on a separate note, AS hangs for 30-60s EVERY time I try and edit something in a gradle file. I have to type elsewhere and then paste it in, if I try and type into AS then I have to wait after each character (this is on OSX). Did you have the same problem?
Okay, I think I have reproduced the error you are getting. I too had to disable the Proguard call; it looks in hindsight like I never properly tested the release build before publishing. There is a proguard rules file but it’s in the wrong directory and the names don’t match (woops).
Am I correct in concluding that you are using Build \> Generate Signed APK
to trigger the build process? If you set the Build Variant to Release (there should be a little sidebar accessible from the bottom left of the AS window) and just hit the “Run” button to trigger the build, does it work? (The APK will end up in ...app/build/outputs/apk/
)
I’m not certain how AS integrates the Release Keystore information you have provided through the GUI into the build process; I have always used a “manually” generated one. As you read in that comment, I found that there doesn’t seem to be a good place to inject the Corona signing, so with the additional tasks that I wrote what happens is something like this:
-
The Corona build script is triggered because I made it a dependency for step 2
-
The Android Gradle plugin merges assets.
-
… the rest of the regular build. If the Release build variant is selected then a signed release APK is generated,
which except for missing a valid Corona signature would run just fine.
-
CertifyBuild.sh is triggered. The script extracts the APK and signs the native libraries inside, which invalidates the original keystore signature from step 3.
-
A custom task re-signs the APK with either the debug or release keystore info from the
android.signingConfigs
section of the Gradle file depending on the build variant, essentially using CLI commands to sign the APK manually. (You can see exactly which commands are used inside theresignApk
function.)
I hadn’t experimented with getting the “Generate Signed APK” feature of AS working, but that would certainly be nice to have… I suspect the CertifyBuild call is failing because the CORONA_APK_PATH value is being derived from the path you gave in the “Generate Signed APK” dialog, but at that point in the build the APK has not been moved to that final location yet.
PS: I do not experience the problem you describe with AS hanging when you edit a Gradle file. That sounds very frustrating. At first I thought it might be AS triggering a Gradle Sync automatically for you while perhaps I had that turned off, but 30-60 seconds seems like much too long for that.
PPS: To get the coronaLib
module fully up to date, in addition to copying the JARs over, you may also want to copy the contents of ‘/Applications/CoronaEnterprise/Corona/android/lib/Corona/libs/armeabi-v7a’ into ‘<ProDir>/android/coronaLib/src/main/jniLibs/armeabi-v7a’ (updating the native components).
Thanks for the reply again. I’d already copied the armeabi files across, forgot to mention that before.
You were right that I was using Generate Signed APK, I just assumed that’s the option that the script would be using for some reason. I don’t need to use that method though, since you’ve set it up so that the regular “Build APK” signs them anyway. If I’d paid closer attention I would’ve realised that was happening.
I’ve been trying to get all it up and running again today. Running “Build APK” seems to work for both debug and release builds (as in I get no build errors), and they install on my devices ok (this is with a simple “hello world” test).
However when I start the app, it crashes immediately with the following errors:
W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1479 com.android.server.am.ActivityStack.removeHistoryRecordsForAppLocked:3697 com.android.server.am.ActivityStack.handleAppDiedLocked:4461 com.android.server.am.ActivityStackSupervisor.handleAppDiedLocked:3010 com.android.server.am.ActivityManagerService.handleAppDiedLocked:4601 W/ActivityManager: Force removing ActivityRecord{43bd94d8 u0 com.quiztix.movies/com.ansca.corona.CoronaActivity t17}: app died, no saved state W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1465 com.android.internal.policy.impl.PhoneWindowManager.notifyToSSRM:5591 com.android.internal.policy.impl.PhoneWindowManager.access$200:177 com.android.internal.policy.impl.PhoneWindowManager$PolicyHandler.handleMessage:716 android.os.Handler.dispatchMessage:102 W/WindowManager: Failed looking up window java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@43f48038 does not exist at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9699) at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9690) at com.android.server.wm.WindowState$DeathRecipient.binderDied(WindowState.java:1312) at android.os.BinderProxy.sendDeathNotice(Binder.java:493) at dalvik.system.NativeStart.run(Native Method)
There is more to the log before this point, but this seems to be the relevant part. Does anything in there jump out as being related to something that I could have missed in the AS project? I’ve changed the com.company.appname to com.quiztix.movies, and think I’ve caught it everywhere that it needs changing in case you’re wondering where in the log refers to this app.
Thanks again.
Edited to make the error message more readable.
That looks like quite the runtime error… It certainly could be an artifact of the build process, but I’m afraid nothing jumps out at me from just the log, so I don’t really have any insights.
For some reason, it was being caused by this bit of code in my config.lua
notification = { iphone = { types = { "badge", "sound", "alert" } }, google = { projectNumber = "123456790" }, }
As soon as it was commented out, it started to run correctly. I’ve no idea why, I’ll have to address that later.
Now I’m at the point where I’m trying to build my real app, and I’m trying to get the various libs working. The main reason I wanted to use gradle was to try and use multidex, so once I have it all up and running I’ll update my post here.
If you like, once I have everything working I wouldn’t mind helping to update the sample project and push it to your repo.
[quote=“Alan_PlantPot,post:35,topic:331530”]
For some reason, it was being caused by this bit of code in my config.lua
notification = { iphone = { types = { "badge", "sound", "alert" } }, google = { projectNumber = "123456790" }, }
As soon as it was commented out, it started to run correctly. I’ve no idea why, I’ll have to address that later. [/quote]
Strange… :huh: good luck with that one.
This was a definite benefit for our team - integrations tend to be much easier, and MultiDex was pretty painless.
Sure; feel free to submit pull requests! I spent some time yesterday filling out the ReadMe, so there is more documentation now, but there’s lots of room for improvement.
Got multidex working today! As you say it wasn’t very painful (and I can’t believe just how much easier it is to integrate new libs).
I need to do some tweaking to update our apps, then I’ll try and tidy what I’ve done up and see if there’s anything useful to push to your repo.
Thanks for all your help so far!
I’m trying to use a Java SDK that has a gradle config/setup they suggest. Can I convert it to use in Corona Enterprise or is this issue everyone is complaining about, sounds like the other way round for the complaints? Thanks, anyone?
Hi everyone,
As of daily build 2016.2886, Android Studio support is available in an official capacity.
See the announcement here.
OCG Studios, could you please explain what steps you had to take to get the project running in Android Studio?
I don’t see where in this project I would put my Corona files (i.e. the Lua files, images etc). In my existing projects, the Corona folder is outside the Android folder e.g.
ProjectDir/Android
ProjectDir/Corona/main.lua
Corona then appears to package all of the lua files into a resource.car file, and moves all of the assets into an “assets” folder in the Android folder:
ProjectDir/Android/assets/resource.car
ProjectDir/Android/assets/myImage.png
ProjectDir/Android/assets/mySFX.mp3
Also, I’ve tried just getting the sample from github to build and sign an apk (with none of my code in it yet). I had to turn off proguard in build.gradle:
minifyEnabled false //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
which is fine, but now I’m getting an error saying:
Error:Execution failed for task ':app:coronaCertifyRelease'. \> Process 'command '/Applications/CoronaEnterprise/Corona/mac/bin/CertifyBuild.sh'' finished with non-zero exit value 255
which means that the Corona signing is not working.
If you can help at all that would be greatly appreciated. In the mean time I’m going to try and work through it, and will update this post if I find anything helpful.
Edit: I’m not sure if ODG Studios post has been deleted, but it’s now disappeared. In case anyone else needs the link that was in it, the post said:
I’ve found this while searching for a way to use the Enterprise template app in Android Studio:
https://github.com/mr-seiler/gradle-corona-sample
I’ve got it running and it really works like a charm!