Android Native from the start. How?

So I’ve spent the whole day taking the plunge to check out Native. I followed the docs (downloading, installing latest Corona, Android Studio and Java), pressed setup Native. That’s as far as i have got.

I have tried opening the template and Run/Build are missing but make APK returns an error can’t find bundle for base name messagesJPS and some EN_US package

I tried importing it too.

It also says project doesnt use gradle and recommended migrating. Maybe I opened it wrong? I open “app” folder not gradle file - if i do that it stuck on “Building Gradle” but it also does that if i create a new app. Is that frozen? Who knows

I tried sample projects. Simple Lua Extension has an error about .idea something is missing. I couldn’t see any .idea folders in sample directory

I tried Launching From NativeUI folder and after I had to select an output path, i came up with same base name messagesJPS  error

Im also getting error in manifest xml "unresolved package ’ coronalabs’

On initial launch of Android Studio, I had some LUA model choice between EmmyLua and Lua. I tossed a coin with that one.

Cant see any other docs to help me out here.

This is missing:

“If you’re new to Corona Enterprise or Android Studio, see our Android Prerequisites guide for instructions on how to set up Android Studio for Corona Enterprise development.”

Could really do with those back up even if they are outdated to have some idea.

Your pinned topics in this forum dont work either.

Do I need JNLua. to open up sample projects and if so how do i set that up?

In case I was missing plugins, I also copied download_plugins.sh to the android folder, clicked on it to run as i read somewhere else thats what might have to do, and that just opens up Xcode to view it, not run it.

Im hoping im missing something simple thats responsible for all this. 

Just some basics to get me started to open the sample project would be great. Paths, plugins etc Just like the guides you have for Xcode/Visual Studio which all had samples that worked out of the box

Basically, I have followed what docs you have to get started and cant get started. Im either being dumb and missing something obvious or something obvious is missing

EDIT ALSO: I created a new app with second activity, was frozen on “building Gradle” and then said it needs Android SDK 26 so now downloading that. Has that anything to do with it above? After this, it says i need SDK build tools 26.0.2 so now downloading that. Hangon… SDK not included in Android Studio then? Learning the hard way

EDIT 2 after the updating, it hasnt made any difference to opening sample projects even though it deployed the built-in Android studio templates fine

EDIT 3 Now template opens up (after realising i open up the “Android” folder inside “App”) it now says failed target with hash string “android-25” so i click to install missing platforms and it fails says its unavailable and Android tools has vanished from menu bar. This is so fun

EDIT 4: I changed the gradle script with sdk versions to 26 and build tools to 26.0.2. (the ones i had installed earlier) It then refreshed and it started running gradle build but it was stuck on this for ages. I cancelled and then saw Corona telling me in the console that I wasnt authorised and needed an Enterprise subscription.  I have noticed that there was a network error and since checking for android SKS there were more available. I have set to download them all now incase i need them again and will try again once downloaded. Fingers crossed.

Edit 5: Managed to get it to build until Corona Enterprise Subscription error again. Seems to be stuck on “gradle build running”. Will restart Android Studio and relaunch see what happens…

EDIT 6 FINALLY

I deauthorized Corona and reauthorized and it worked! , restarted and rebuilt aone of the samples and it worked. Took a minute to build and hey presto.

So to summarize some crucial steps were missing in setup docs:

When it says you need minimum Android SDK, it seems you cant get this manually anymore but within Android Studio after its installed. (Thats what seems to me anyway)

Follow the setup instructions but THEN make sure you go to tools, SDK tools and get the latest SDKs and build tools. This seems to have been missing for me. Also I had network error later and it didnt tell me there was an error it just didnt show older SDKs so if you dont see much check network.

Then opening up samples you open up the folder that contains folders app,build,gradle . Usually called “Android”

If it mentioned Enterprise subscription in console,  then sign out of corona and log back in

You can also edit built tools to latest one thats installed if its not the same one in the build gradle settings.

Oh i also installed Android File transfer utility but i will never know if Android Studio didnt need it.

Ill keep this here if anyone else was having same problems starting completely from scratch.

10 hours later. Time for large Gin and Tonic!

I’m glad you have this working.  Android Studio is always updating something.  There are things that just frustrating about it. It’s one of the reasons I’m struggling to make a tutorial for Android native builds.

But in the simplest terms, if Android Studio is configured properly and you’ve authorized Corona, find the “Android” folder inside the App folder (please make a copy of it to your project, so you a) can rename it and b ) keep the original App project untouched.), then you should be able to drag that android folder to the Android Studio icon in the doc, when it loads, hit the play button, select a device or virtual machine to run it on and see a dictionary entry for “Corona”.

Rob

 Yes Ill have this project saved under lock and key while Im fiddling with it. 

One thing did come up now that I know is going to be a major issue is the corona standard plugins like Notifications. Im Just trying to figure out how to get push notifications working in an old project. I see that IOS have a way of including them via Xcode+build.settings. I can see Android dont have this yet but thats okay.

Im guessing I need to find the jar files and include that and any others manually. I dont mind that at all really - just need to know what and where i do things.

I went back to the “download_plugins.sh” and have just learnt I dont just run that sh file(which then opens Xcode) but I can drag that into terminal program on Mac and press enter for it to execute. It has found the plugins so ill now look up how to put them in.

So Im also adding this in this forum for anyone else thats starting off like me,

To get your plugins used in build settigs:

Place download_plugins.sh in “android” folder of your project

Open Terminal and drag download_plugins.sh into it, press enter. Watch confirmation and destination of downloaded plugins.

Okay so i copied the notifications plugin in to where the other jar files are way down in the lib folder in the corona application / native and now I dont get an error. I think it works. Actually yes it does. I see my notification on the task bar. Its all coming together.

Now to figure out how to disable system idle timer to false as that doesnt seem to work from Lua and somehow cant see print commands on the console. Ill get there though.

To add to the things to do lis in Android Studio. AS recommended i update Gradle to 3. After this it broke slightly. I had updated all of Android Studio again to 3.1 i think and it still was broke. Something to do with output file name being read only and trying to change it.

Anyway this is what fixed it: (in the build gradle for "app)

applicationVariants.all { variant ->

variant.outputs.all { output ->
output.outputFileName = file(output.outputFile.getPath().replace(’/app-’, “/${apkName}-”))
}
}

changed “each” to “all”

and “outputFile” to “outputFileName”

It since updated to Grade 4 i think, it then complained it needed build tools 3 which although not in the SDK manager, the link came up in messages and once that happened back to normal

Now after full sync it builds again… and breath…

One other issue i am finding - and it maybe not an issue in real usage,  is that occasionally the landscape project deploys with the width squashed. Like it is reading portrait width pixel count. This means my whole app squashes the app in leaving a black area . But i think this happens when its deployed when phone has gone into suspend mode (you have to press power button to get it back on). IE when you build , phone gets bored and turns off, then gets deployed.

If its only on deploy while suspended then I doubt its a problem app wont ever start while in suspend mode. 

I’m glad you have this working.  Android Studio is always updating something.  There are things that just frustrating about it. It’s one of the reasons I’m struggling to make a tutorial for Android native builds.

But in the simplest terms, if Android Studio is configured properly and you’ve authorized Corona, find the “Android” folder inside the App folder (please make a copy of it to your project, so you a) can rename it and b ) keep the original App project untouched.), then you should be able to drag that android folder to the Android Studio icon in the doc, when it loads, hit the play button, select a device or virtual machine to run it on and see a dictionary entry for “Corona”.

Rob

 Yes Ill have this project saved under lock and key while Im fiddling with it. 

One thing did come up now that I know is going to be a major issue is the corona standard plugins like Notifications. Im Just trying to figure out how to get push notifications working in an old project. I see that IOS have a way of including them via Xcode+build.settings. I can see Android dont have this yet but thats okay.

Im guessing I need to find the jar files and include that and any others manually. I dont mind that at all really - just need to know what and where i do things.

I went back to the “download_plugins.sh” and have just learnt I dont just run that sh file(which then opens Xcode) but I can drag that into terminal program on Mac and press enter for it to execute. It has found the plugins so ill now look up how to put them in.

So Im also adding this in this forum for anyone else thats starting off like me,

To get your plugins used in build settigs:

Place download_plugins.sh in “android” folder of your project

Open Terminal and drag download_plugins.sh into it, press enter. Watch confirmation and destination of downloaded plugins.

Okay so i copied the notifications plugin in to where the other jar files are way down in the lib folder in the corona application / native and now I dont get an error. I think it works. Actually yes it does. I see my notification on the task bar. Its all coming together.

Now to figure out how to disable system idle timer to false as that doesnt seem to work from Lua and somehow cant see print commands on the console. Ill get there though.

To add to the things to do lis in Android Studio. AS recommended i update Gradle to 3. After this it broke slightly. I had updated all of Android Studio again to 3.1 i think and it still was broke. Something to do with output file name being read only and trying to change it.

Anyway this is what fixed it: (in the build gradle for "app)

applicationVariants.all { variant ->

variant.outputs.all { output ->
output.outputFileName = file(output.outputFile.getPath().replace(’/app-’, “/${apkName}-”))
}
}

changed “each” to “all”

and “outputFile” to “outputFileName”

It since updated to Grade 4 i think, it then complained it needed build tools 3 which although not in the SDK manager, the link came up in messages and once that happened back to normal

Now after full sync it builds again… and breath…

One other issue i am finding - and it maybe not an issue in real usage,  is that occasionally the landscape project deploys with the width squashed. Like it is reading portrait width pixel count. This means my whole app squashes the app in leaving a black area . But i think this happens when its deployed when phone has gone into suspend mode (you have to press power button to get it back on). IE when you build , phone gets bored and turns off, then gets deployed.

If its only on deploy while suspended then I doubt its a problem app wont ever start while in suspend mode.