SDKBox: Manual Integration For Android - AppActivity.java Problem

Hi,

I’ve been trying to link PluginAdMob to my game on Android. I installed the plugin manually. The game compiles but when I call a method on the plugin it causes a crash. For example this code causes a crash:

sdkbox::PluginAdMob::init();

I think this has to do with the file AppActivity.java not being set up right. I followed the advice in the manual integration guide as best I could, but there were some problems. For instance, in the sdkbox-admob_v2.6.0.0 folder there is no actual AppActivity.java file. There is just a patch file named AppActivity.java.ccc.3.0.patch. I wasn’t sure what to do with that, so I used the AppActivity.java file I found in sdkbox-sample-iap-master.

The “Manual Integration For Android” guide explains to:

" Replace extends Cocos2dxActivity with extends com.sdkbox.plugin.SDKBoxActivity"

but when I do that for the AppActivity.java file I took from sdkbox-sample-iap-master folder, I end up with a file that looks like this:

package org.cocos2dx.cpp;

import org.cocos2dx.lib.Cocos2dxActivity;

public class AppActivity extends com.sdkbox.plugin.SDKBoxActivity {
}

That doesn’t look right. I also think that it’s the wrong version anyway.

What I need to know is, where do I get the right version of AppActivity.java from? I copied the file to the folder proj.android-studio/app/src/org/cocos2dx/cpp. I think this is right but should there be more files in there? Also, do I need a proj.android-studio/app/src/org/cocos2dx/lib folder with Cocos2dxActivity.java etc as well?

Thanks for reading. I will show the stack of the crash in the next post.

Here is the stack:

Thread-21-[GL Thread 498]

art_sigsegv_fault 0x00000000e2e5eac0

art::FaultManager::HandleFault(int, siginfo*, void*) 0x00000000e2e5f074

art::art_fault_handler(int, siginfo*, void*) (.llvm.8419848004154328202) 0x00000000e2e5ed8b

___lldb_unnamed_symbol25$$app_process32 0x000000006021022e

___lldb_unnamed_symbol2$$libc.so 0x00000000e5b1f070

sdkbox::JNIUtils::cacheEnv(_JavaVM*) 0x00000000b8d7cd3f

sdkbox::JNIUtils::__getEnv() 0x00000000b8d7d078

sdkbox::JNIUtils::__getEnvAttach() 0x00000000b8d7d095

sdkbox::JNIUtils::GetJNIStaticMethodInfo(char const*, char const*, char const*, _JNIEnv*) 0x00000000b8d7db75

sdkbox::Logger::PlatformInit() 0x00000000b8d77b31

It seems like sdkbox wasn’t initialized properly. So what should the AppActivity.java file look like?

and put jars in https://github.com/sdkbox/sdkbox-sample-cpp317/tree/admob/proj.android/app/libs folder

Hi @yinjimmy ,

Thanks for your help on this. I tried the AppActivity file above but I had some problems. When I compile the project I get this error:

error: cannot find symbol super.setEnableVirtualButton(false);

If I comment out this line I can compile.

//super.setEnableVirtualButton(false);

When I do that the code compiles ok, and runs without any errors. Unfortunately the ads do not show up. I’m not sure if this has anything to do with commenting out super.setEnableVirtualButton(false); or not.

The project I have is set up just like your example project here:

Cocos2dxActivity.java is in cocos2dx/platform/android/java/src/org/cocos2dx/lib with the other files, and AppActivity.java is in proj.android-studio/app/src/org/cocos2dx/cpp.

Is it necessary to complete this part of the manual install?

" Manual Integration for Google Play Services SDK (dependent library only) "

This part is confusing me because I can see the file proj.android-studio/app/project.properties in the folders, but when I open Android Studio I can’t see it in any of the drop down lists. So it seems like it is not included in the project. Is copying the gps folder, and modifying project.properties an important step? Maybe this is why things are not working.

Thanks for your help.

you do not need the gps folder, just use the