Can't open Android Native Demos
in Native
Hi, I'm very new to Android Studio and I'm having trouble opening the demos provided in the Android Realtime SDK.
The readme doesn't say what environment these were build in, so I'm assuming it was they work in Android Studio.
I open a project and select the root folder of the project, for example:
/Photon-AndroidNDK-Sdk_v4-1-16-3/Demos/demo_loadBalancing
where the run button normally is there's an option to configure when I configure it as an app and try to run it says it's missing the AndroidManifest.xml
When I load the folder that has the AndroidManifest it says it's missing a module.
I'm also having trouble loading the library into a new project. I can link the C++ library to it, but I then have troubles writing a NetworkLogic controller, or calling the code from Java, but I figure this isn't the place for that so I'm mostly concerned with loading the demo projects and messing around with them
The readme doesn't say what environment these were build in, so I'm assuming it was they work in Android Studio.
I open a project and select the root folder of the project, for example:
/Photon-AndroidNDK-Sdk_v4-1-16-3/Demos/demo_loadBalancing
where the run button normally is there's an option to configure when I configure it as an app and try to run it says it's missing the AndroidManifest.xml
When I load the folder that has the AndroidManifest it says it's missing a module.
I'm also having trouble loading the library into a new project. I can link the C++ library to it, but I then have troubles writing a NetworkLogic controller, or calling the code from Java, but I figure this isn't the place for that so I'm mostly concerned with loading the demo projects and messing around with them
0
Comments
The demo projects ship with makefiles for NDK-build and with VisualGDB projects.
Android Studio is not necessary to build and run the demo projects. You can either use Visual Studio with VisualGDB or run the plain makefiles directly from the command line.
You can create Android Studio projects for the demos buy following the guides at https://developer.android.com/studio/projects/add-native-code.
See https://developer.android.com/studio/projects/gradle-external-native-builds for how to add native libraries like the Photon Android libraries to your project.
Note that wherever those guides differentiate between cmake and NDK-build, you should go with the NDK-build instructions.
you can try this:https://blog.csdn.net/ldghd/article/details/108409518
I'm trying to build the library using ndk-build but I get an error:
I've checked and double checked the paths and all the Android.mk files, but I can't get it to compile
I've even copied and pasted the file path from the terminal and it goes to the correct directory, so I don't think I'm insane.
This looks like a path-length issue. Due to the way how ndk-build works it can happen on Windows that you cross the maximum limit length limit of Windows when you include 3rd party libs in Android projects that are located at relatively long directory paths.
Try moving your project to a shorter path.
For a quick check if this is indeed the cause of the problem, you can simply copy your project folder to a location like C:/a.
Now however I can't access any of the native functions from within Java. I copied from DemoActivity.java and it crashes on startup. idk if I need to import anything, but I tried leaving the activity blank and was able to runt he app with the compiled c++ code not doing anything. I try to call startDemo(); in onCreate(Bundle savedInstanceState) and the app crashes.
you can show the error info printed in logcat window.
1.Your package name is "com.cerebralclutch.clutchbowling".
2.You can check the code is found "Java_com_cerebralclutch_clutchbowling_MainActivity_startDemo" in main.cpp.
3. You should replace "demo.android.loadBalancing" by "com.cerebralclutch.clutchbowling".replace "DemoActivity" by "MainActivity" .
if it's anything other than this I get a connection error 1023
specifically the app loads logs I changed the function names in main.cpp like @Daguo said and the app compiles and runs fine except for this error.
Nothing shows up in Logcat, but in the Run tab I get
Try this link:
https://forum.photonengine.com/discussion/14208/android-cant-connect-using-photon-realtime
As you can see in the link that @Daguo has provided, the connection issue might simply come from a missing Internet-permission in the manifest file. Have you checked that?
What is the context of your last post?
It looks like you are back to the path length issue.
I've made sure to change all refrences in the main.cpp (otherwise it would crash)
also just to make sure I just paste into the root of the AndroidManifest.xml
it looks like this now
Google restricts the max length for the package name to 30 characters (apparently 50 characters if you only want to support very recent Android versions and set the API version accordingly high, but I have not tested this).
"com.cerebralclutch.clutchbowling" is 32 characters long a hence 2 characters beyond that limit.
Shortening it by 2 or more characters should do the trick.
Ah, OK. Likely an automated algorithm of the forum software put in the SPAM-queue and a colleague has manually approved it after verifying that it wasn't spam. Thanks for clearing that up. I thought you wrote this post today and was confused because I thought that we were past that issue.