Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Android Plugin
Started by prographodeveloper Aug 30 2018 04:27 AM

7 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

prographodeveloper

[GLOBAL: userInfoPane.html]
prographodeveloper
  • Contributor

  • 266 posts
  • Corona SDK

Hi,

 

I want to develop an Android plugin. To start with "native builds" which I have not done before, I am following these instructions: https://docs.coronalabs.com/native/android/index.html

 

It complained about the gradle version, so I updated to 3.0.0 in the main project build.gradle file:

classpath 'com.android.tools.build:gradle:3.0.0'

Then it complained about the tools, it wanted to upgrade to 26.0.0, which I allowed it to do, and changed all build.gradle files to buildToolsVersion '26.0.2'

 

Then it is complaining about something else:

Error:(36, 0) Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=debug, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.

In the build.gradle I changed:

output.outputFile = file(output.outputFile.getPath().replace('/app-', "/${apkName}-"))

To

 

output.outputFileName = file( output.outputFile.getPath().replace('/app-', "/${apkName}-") )

But now it has other errors - including errors about iphoneos (this is Android??)

Error:error: SDK "iphoneos" cannot be located
Error:error: unable to find utility "copypng", not a developer tool or in PATH
Error:Execution failed for task ':app:compileLua'.> Process 'command '/Users/TestUser/Library/Application Support/Corona/Native/Corona/mac/bin/lua'' finished with non-zero exit value 255

Have I lost my way? Does anyone have a working project?



[TOPIC: post.html]
#2

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 824 posts
  • Corona SDK

There are a few on github. I have one for smaato that I was building for Amazon when Appodeal didn't support Amazon. It should still build and would give you ideas. It is not finished and will never be but for your purposes it should be fine:

 

https://github.com/agramonte/smaato-corona-plugin

 

Good luck. It is not an easy task to build a plugin for Android.


  • prographodeveloper likes this

[TOPIC: post.html]
#3

prographodeveloper

[GLOBAL: userInfoPane.html]
prographodeveloper
  • Contributor

  • 266 posts
  • Corona SDK

The following shell script is being called and attempts to copy "iphoneos"

/Corona/Native/Corona/mac/bin/CopyResources.sh

I put a TARGET_PLATFORM check around the copy and it has built.

        if [[ "$TARGET_PLATFORM" != "android" ]]; then
             COPYPNG=$(xcrun --sdk iphoneos --find copypng)
             if [ ! -x "$COPYPNG" ]
             then
                echo "ERROR: cannot locate 'copypng' in Xcode"
                exit 1
             fi
        fi


[TOPIC: post.html]
#4

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 824 posts
  • Corona SDK

hmmm. I thought you were trying to build for Android. That script is in the mac bin directory. What project did you open to build?



[TOPIC: post.html]
#5

prographodeveloper

[GLOBAL: userInfoPane.html]
prographodeveloper
  • Contributor

  • 266 posts
  • Corona SDK

hmmm. I thought you were trying to build for Android. That script is in the mac bin directory. What project did you open to build?

 

Correct. I am building Android on my Mac.

I opened the standard example as specified in the initial link: 

/Applications/Corona/Native/Project Template/App/android


[TOPIC: post.html]
#6

prographodeveloper

[GLOBAL: userInfoPane.html]
prographodeveloper
  • Contributor

  • 266 posts
  • Corona SDK

I'm not sure if I really even want to make a plugin. I have a library of C functions

 

specialMaths.a

 

I want to call these functions - do I need to make a plugin?



[TOPIC: post.html]
#7

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 824 posts
  • Corona SDK

No. You don't have to build a plugin. You can just call the library from the Java side, but I think I see your problem. I have never linked a static C library to a Java project (it is beyond my pay grade), so I don't think I'll be much help. I have done it the other way around (link a Java (jar) to a C library) but don't think the process is the same. If I have time this weekend, I'll give it a go. I am curious if it would work.

 

 

---

 

Ok. I just looked it up and yes it is the same process as the other way around. The only way I could find to do what you want to do is to create a JNI wrapper of that library and then call it from the Java code. In my github I have a few examples of JNI wrappers. Look for plugins made for MadeWithMarmalade for Android. Most of those are wrappers. In any case, I love JNI and if I have time this weekend I'll attempt to create one from a random library.

 

---

 

You can also look at:

https://en.wikipedia.org/wiki/Java_Native_Access


Edited by agramonte, 31 August 2018 - 06:39 AM.

  • prographodeveloper likes this

[TOPIC: post.html]
#8

prographodeveloper

[GLOBAL: userInfoPane.html]
prographodeveloper
  • Contributor

  • 266 posts
  • Corona SDK

I downloaded your smaato, it immediately worked, I am gonna try to customise that.




[topic_controls]
[/topic_controls]