I am currently migrating our project from Ant to Android Studio. With corona enterprise 2016.2886, I have the project actually building an apk, and it will run on the device. I have setup the tasks in our build.gradle files to be identical with the example in the docs, with additions to build with the ndk. The resulting process is as follows:
When I try using CoronaEnterprise 2016.2904 or 2016.2906, however, the app crashes on startup with the following JNI-related error:
W/dalvikvm(31900): Invalid indirect reference 0x4006fcb4 in decodeIndirectRef E/dalvikvm(31900): VM aborting F/libc (31900): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 31900 (ageName.Removed)
The resulting memory dump references ‘/system/lib/libdvm.so’, ‘/data/data/com.PackageName.Removed/lib/libcorona.so’, and ‘/system/lib/libc.so’. I can post the full dump on request.
Any ideas on what might be different between these builds that would cause the crash?
Hi Danny, thanks for getting a conversation started on this :) . It does indeed crash even with a full clean and rebuild. This is an error I seem to be getting under various circumstances that can often be resolved with a simple clean and rebuild, as you implied. In the case where I switch from 2016.2886 to 2016.2904, however, cleaning does not do the trick.
I have tried this process to ensure a clean build, but maybe I’m missing something:
Quit Android Studio -> Delete CoronaEnterprise folder -> Manually delete all build, assets, jniLibs, and obj folders from project -> Empty the Trash -> Copy in the new CoronaEnterprise folder -> Open Android Studio, build and run apk (on device)
Also, my Xcode build works just fine with 2016.2904, so this is an Android-only issue for me.
Thanks for the suggestion Danny! My app’s build.gradle file already contained that line for my cleanAssets task though. I remember coming across it in some other thread.
Here are the portions of my build.gradle that deviate from the norm, perhaps my usage of lua2c.sh in generateLuaByteCodes isn’t recommended:
//task order: //cleanAssets -\> generateLuaBytecodes -\> ndkBuild -\> compileLua -\> copyCoronaResources -\> copyCoronaNativeLibs -\> certifyBuild //not the full android section, just the part that is different android { sourceSets.main { jni.srcDirs = [] //disable automatic ndk-build call with auto-generated Android.mk } } def coronaEnterpriseDir = "$rootDir/../CoronaEnterprise" def coronaEnterpriseMacBinDir = "$coronaEnterpriseDir/Corona/mac/bin" def targetName = 'plugin\_ourPlugin' task generateLuaBytecodes(type: Exec, description: 'uses lua2c to create corona entry point') { workingDir = "$coronaEnterpriseMacBinDir" commandLine "$coronaEnterpriseMacBinDir/lua2c.sh", "$rootDir/../$targetName" + '.lua', "$rootDir/.", 'release' dependsOn 'cleanAssets' doFirst { println '== generateLuaBytecodes ==' } } task cleanNative(type: Exec) { workingDir file('src/main') commandLine getNdkBuildCmd(), 'clean' doFirst { println '== cleanNative ==' } } tasks.withType(JavaCompile) { compileTask -\> compileTask.dependsOn ndkBuild } // call regular ndk-build(.cmd) script from app directory task ndkBuild(type: Exec) { commandLine getNdkBuildCmd(), '-C', file('src/main/jni').absolutePath, '-j', Runtime.runtime.availableProcessors(), "NDK\_LIBS\_OUT=$jniLibsDir", 'all', 'NDK\_DEBUG=1' dependsOn 'generateLuaBytecodes' doFirst { println '== ndkBuild ==' } } tasks.clean.dependsOn cleanNative def getNdkDir() { if (System.env.ANDROID\_NDK\_ROOT != null) return System.env.ANDROID\_NDK\_ROOT Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) def ndkdir = properties.getProperty('ndk.dir', null) if (ndkdir == null) throw new GradleException("NDK location not found. Define location with ndk.dir in the local.properties file or with an ANDROID\_NDK\_ROOT environment variable.") return ndkdir } def getNdkBuildCmd() { def ndkbuild = getNdkDir() + "/ndk-build" if (Os.isFamily(Os.FAMILY\_WINDOWS)) ndkbuild += ".cmd" return ndkbuild }
I think I identified the problem. Corona.jar and JNLua.jar were among our plugin’s libs, which were checked into source control rather than being included in the build process dynamically. Because those .jars were already in the libs folder, I guess they were taking precedence over:
Hi Danny, thanks for getting a conversation started on this :) . It does indeed crash even with a full clean and rebuild. This is an error I seem to be getting under various circumstances that can often be resolved with a simple clean and rebuild, as you implied. In the case where I switch from 2016.2886 to 2016.2904, however, cleaning does not do the trick.
I have tried this process to ensure a clean build, but maybe I’m missing something:
Quit Android Studio -> Delete CoronaEnterprise folder -> Manually delete all build, assets, jniLibs, and obj folders from project -> Empty the Trash -> Copy in the new CoronaEnterprise folder -> Open Android Studio, build and run apk (on device)
Also, my Xcode build works just fine with 2016.2904, so this is an Android-only issue for me.
Thanks for the suggestion Danny! My app’s build.gradle file already contained that line for my cleanAssets task though. I remember coming across it in some other thread.
Here are the portions of my build.gradle that deviate from the norm, perhaps my usage of lua2c.sh in generateLuaByteCodes isn’t recommended:
//task order: //cleanAssets -\> generateLuaBytecodes -\> ndkBuild -\> compileLua -\> copyCoronaResources -\> copyCoronaNativeLibs -\> certifyBuild //not the full android section, just the part that is different android { sourceSets.main { jni.srcDirs = [] //disable automatic ndk-build call with auto-generated Android.mk } } def coronaEnterpriseDir = "$rootDir/../CoronaEnterprise" def coronaEnterpriseMacBinDir = "$coronaEnterpriseDir/Corona/mac/bin" def targetName = 'plugin\_ourPlugin' task generateLuaBytecodes(type: Exec, description: 'uses lua2c to create corona entry point') { workingDir = "$coronaEnterpriseMacBinDir" commandLine "$coronaEnterpriseMacBinDir/lua2c.sh", "$rootDir/../$targetName" + '.lua', "$rootDir/.", 'release' dependsOn 'cleanAssets' doFirst { println '== generateLuaBytecodes ==' } } task cleanNative(type: Exec) { workingDir file('src/main') commandLine getNdkBuildCmd(), 'clean' doFirst { println '== cleanNative ==' } } tasks.withType(JavaCompile) { compileTask -\> compileTask.dependsOn ndkBuild } // call regular ndk-build(.cmd) script from app directory task ndkBuild(type: Exec) { commandLine getNdkBuildCmd(), '-C', file('src/main/jni').absolutePath, '-j', Runtime.runtime.availableProcessors(), "NDK\_LIBS\_OUT=$jniLibsDir", 'all', 'NDK\_DEBUG=1' dependsOn 'generateLuaBytecodes' doFirst { println '== ndkBuild ==' } } tasks.clean.dependsOn cleanNative def getNdkDir() { if (System.env.ANDROID\_NDK\_ROOT != null) return System.env.ANDROID\_NDK\_ROOT Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) def ndkdir = properties.getProperty('ndk.dir', null) if (ndkdir == null) throw new GradleException("NDK location not found. Define location with ndk.dir in the local.properties file or with an ANDROID\_NDK\_ROOT environment variable.") return ndkdir } def getNdkBuildCmd() { def ndkbuild = getNdkDir() + "/ndk-build" if (Os.isFamily(Os.FAMILY\_WINDOWS)) ndkbuild += ".cmd" return ndkbuild }
I think I identified the problem. Corona.jar and JNLua.jar were among our plugin’s libs, which were checked into source control rather than being included in the build process dynamically. Because those .jars were already in the libs folder, I guess they were taking precedence over: