I’m trying to call a java function from a C++ class. Here’s what I’ve done:
1.) Created a class in Android Studio called “AdHelper” in the app/src/com/myCompany folder. It has a public static function “test” which in theory should log the message “Please let me just have this one success today.”
package com.myCompany;
public class AdHelper {
public static void test()
{
System.out.println("Please let me just have this one success today.");
}
}
There is nothing to do special for JniHelper. Your code seems correct.
Does it work without ProGuard activated? If so, your proguard-rules.pro isn’t correct. A better solution for custom JniHelper Java functions, is to annotate the functions with @Keep. So you can do fine grained ProGuard configuration. But this is only my opinion about ProGuard.
@mars3142@tdebock How can I determine if proguard is or isn’t enabled? What build or runtime indicators are there? Second, it’s all a bit confusing. There seems to be several answers regarding disabling proguard which range from deleting the rules file itself, to adding certain rules in the rules file, to setting minifyEnabled to false in the build.gradle (of which there are 3 in a cocos2dx project).
Also, there is a proguard-project.txt file referenced in the project.properties file (which doesn’t seem to exist and I assume should’ve been removed from the cocos2dx project template).
I should add that I use CMake for my C++ dependencies. And I added the AdHelper class through the Android Studio UI. I can see the AdHelper class in the project view in Android Studio. Does this mean that it is included in my build?
This is my first Android app and it’s been a struggle learning how a cocos2dx project comes together. So sorry about the length!
Did you try my recommendation? JniHelper might have a hard time just ‘finding’ AdHelper without the specification of the path instead com/myCompany/AdHelper…
@tdebock Yes, I did try that to no effect, but again nothing I have done has effected the outcome in any way. I guess I’ll try and comment out all of the rules that were automatically added by cocos2dx or SDKBOX.