Migration to Android Studio

Hi guys,

Just wanted to share. The ‘AndroidManifest.xml’ shown in the guide/tutorialwill not work if you are using the normal java global (like the samples given). You will get an error like below. 

To solve this, you need to add in the line android:name=“CoronaApplication” in the androidManifest.xml file.

Sample Error :

I/Corona: ERROR: Runtime error ?:0: attempt to index global 'myTests' (a nil value) stack traceback: ?: in main chunk

Sample part of ‘AndroidManifest.xml’

 \<application android:name="CoronaApplication" android:allowBackup="true" android:icon="@mipmap/ic\_launcher" android:label="@string/app\_name" android:supportsRtl="true" android:theme="@style/AppTheme" android:fullBackupContent="false" android:hardwareAccelerated="true" tools:targetApi="honeycomb" tools:ignore="GoogleAppIndexingWarning"\> ......

Those who are facing a crash error related to openssl, with this message :

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.YOURAPP, PID: 7120 java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.YOURAPP-1/base.apk"],nativeLibraryDirectories=[/data/app/com.YOURAPP-1/lib/arm, /data/app/com.YOURAPP-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]] couldn't find "libplugin.openssl.so" at java.lang.Runtime.loadLibrary(Runtime.java:367) at java.lang.System.loadLibrary(System.java:1076) at com.YOURAPP.CoronaApplication.\<clinit\>(CoronaApplication.java:66) at java.lang.Class.newInstance(Native Method) at android.app.Instrumentation.newApplication(Instrumentation.java:1019) at android.app.Instrumentation.newApplication(Instrumentation.java:1004) at android.app.LoadedApk.makeApplication(LoadedApk.java:666) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6294) at android.app.ActivityThread.access$1800(ActivityThread.java:222) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1861) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7229) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

You will now need to put the .so file in corona enterprise folder. The pre-AndroidStudio method of putting the .so file in ‘libs/armeabi-v7a’ no longer works (in my case).

Put the .so file in here, as every time the apk is build, all the files are copied from here…

"CoronaEnterprise -\> Corona -\> android -\> lib -\> Corona -\> libs -\> armeabi-v7a -\> PUT THE .SO FILE IN HERE"

Make sure this is also in your “build.gradle(android:app)”, based on the official guide/tutorial

task copyCoronaNativeLibs(type: Copy, description: 'include precompiled libraries from Corona Enterprise') { from fileTree(dir: "$coronaEnterpriseAndroidLibDir/libs", include: '\*\*/\*.so') into "$jniLibsDir" dependsOn 'copyCoronaResources' doFirst { println '== copyCoronaNativeLibs ==' } }

@yosu

Although it works, I wouldn’t recommend putting other .so files in the Corona Enterprise directory

My recommendation is to create a new task in your app’s build.gradle file. This way you can put the .so files in app/libs/armeabi-v7a.

task copyMyProjectNativeLibs(type: Copy) { from fileTree(dir: "$projectDir/libs", include: "\*\*/\*.so") into "$jniLibsDir" dependsOn "copyCoronaNativeLibs" doFirst { println "== copyMyProjectNativeLibs ==" } }

After adding the new task remember to change the certifyBuild task’s dependsOn to: 

dependsOn “copyMyProjectNativeLibs”.

Those who are facing a crash error related to openssl, with this message :

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.YOURAPP, PID: 7120 java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.YOURAPP-1/base.apk"],nativeLibraryDirectories=[/data/app/com.YOURAPP-1/lib/arm, /data/app/com.YOURAPP-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]] couldn't find "libplugin.openssl.so" at java.lang.Runtime.loadLibrary(Runtime.java:367) at java.lang.System.loadLibrary(System.java:1076) at com.YOURAPP.CoronaApplication.\<clinit\>(CoronaApplication.java:66) at java.lang.Class.newInstance(Native Method) at android.app.Instrumentation.newApplication(Instrumentation.java:1019) at android.app.Instrumentation.newApplication(Instrumentation.java:1004) at android.app.LoadedApk.makeApplication(LoadedApk.java:666) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6294) at android.app.ActivityThread.access$1800(ActivityThread.java:222) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1861) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7229) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

You will now need to put the .so file in corona enterprise folder. The pre-AndroidStudio method of putting the .so file in ‘libs/armeabi-v7a’ no longer works (in my case).

Put the .so file in here, as every time the apk is build, all the files are copied from here…

"CoronaEnterprise -\> Corona -\> android -\> lib -\> Corona -\> libs -\> armeabi-v7a -\> PUT THE .SO FILE IN HERE"

Make sure this is also in your “build.gradle(android:app)”, based on the official guide/tutorial

task copyCoronaNativeLibs(type: Copy, description: 'include precompiled libraries from Corona Enterprise') { from fileTree(dir: "$coronaEnterpriseAndroidLibDir/libs", include: '\*\*/\*.so') into "$jniLibsDir" dependsOn 'copyCoronaResources' doFirst { println '== copyCoronaNativeLibs ==' } }

@yosu

Although it works, I wouldn’t recommend putting other .so files in the Corona Enterprise directory

My recommendation is to create a new task in your app’s build.gradle file. This way you can put the .so files in app/libs/armeabi-v7a.

task copyMyProjectNativeLibs(type: Copy) { from fileTree(dir: "$projectDir/libs", include: "\*\*/\*.so") into "$jniLibsDir" dependsOn "copyCoronaNativeLibs" doFirst { println "== copyMyProjectNativeLibs ==" } }

After adding the new task remember to change the certifyBuild task’s dependsOn to: 

dependsOn “copyMyProjectNativeLibs”.