Code Monkey home page Code Monkey logo

slibio / slib Goto Github PK

View Code? Open in Web Editor NEW
131.0 18.0 53.0 53.28 MB

SLib - A universal, efficient, light-weight framework for building cross-platform applications on Android/iOS/macOS/Tizen/Win32/Linux platforms, developed by SLIBIO. Based on C++, provides desktop/mobile widgets, OpenGL rendering and networking solutions.

License: MIT License

C 1.63% C++ 84.79% Objective-C 0.13% Java 3.90% CMake 0.24% Objective-C++ 6.06% Shell 0.05% Batchfile 0.12% SourcePawn 0.18% PHP 2.89%
cross-platform cpp11 ios android win32 macos tizen slib ui rendering-engine game-development

slib's Introduction

SLib

SLib is a universal cross-platform library, specially designed for the various UI components, OpenGL rendering and networking solutions.

SLib enables software developers to build multi-platform(Android/iOS/MacOS/Tizen/Win32) applications and games under the most effective workflows and the coding conventions of C++, while providing easy-to-use toolkits to develop HTTP/Socket servers on the Linux/MacOS/Win32 platforms.

Modules

  • core

    Auto Reference Counting, String, List, Map, File, Thread, Synchronizing, Time, Variant, Json, Xml, ...

  • crypto

    AES, RSA, GZIP, SHA1/2, GCM, MD5, Blowfish, DES, TripleDES, ...

  • db

    SQLite, MySQL, Redis

  • device

    Sensor, Vibrator

  • graphics

    Bitmap, Image, Canvas, Font, ...

  • math

    BigInt, Uint128, Matrix, Vector, Transform, ...

  • media

    MediaPlayer, AudioRecorder, AudioPlayer, Camera, ...

  • network

    UrlRequest, Socket, Asynchronous I/O, HttpServer, ...

  • render

    RenderEngine, RenderProgram, VertexBuffer, IndexBuffer, Texture, ...

  • ui

    Window, View, ViewGroup, LinearView, ScrollView, Animation, Button, EditView, TabView, WebView, ...

  • web

    WebController, WebService

  • geo

    LatLon, GeoLocation, GeoLine, GeoRectangle, Globe, Earth

Getting Started

Prerequisites

  • Xcode 9.4 or higher for compiling macOS/iOS packages
  • Android Studio 3.2 or higher for compiling Android packages
  • Visual Studio 2017 or higher for compiling Win32 packages
  • Tizen Studio 1.1.1 or higher for compiling Tizen packages
  • CMake (>=3.0), GCC/C++ (>=4.8.1) for compiling Linux packages. Optional: KDevelop(>=4.7)

Clone the repository from Github.

 git clone https://github.com/SLIBIO/SLib.git

Build the static libraries

You can see the following projects in build directory.

Project Description
Android Android Studio project for Android
iOS Xcode project for iOS
macOS Xcode project for macOS
Win32 Visual Studio solution for Win32
Tizen Tizen Studio project for Tizen
Linux CMake/KDevelop project for Linux

After compiling the projects, you can find the static libraries in the lib directory.

Setup Environment

It's time to setup the environment variables. It is a bit different depending on the platforms.

On macOS and Linux, you'll need to run the setup-path script on Terminal or Finder.

 ./setup-path

On Windows, you'll need to run the setup-path.bat batch file on Command Prompt or File Explorer.

 setup-path.bat

setup-path will register the current source directory as SLIB-PATH environment variable depending on the Operating Systems and IDEs(XCode and KDevelop).

After setting up the environment variables, please close all the running IDEs(Xcode, Android Studio, Tizen Studio,...) and terminal (or konsole) windows, and then reopen them. (on macOS, press Command+Q to completely close the IDEs).

Creating new projects based on SLib

After setting up environment using setup-path(setup-path.bat), please reopen Terminal (Command Prompt) window.

And then please create an empty directory, and then create a C++ project using following commands.

Platform Application Type Command
Android
iOS
Mobile App
(With sapp)
new-slib-app-mobile YOUR_PROJECT_NAME YOUR_APPLICATION_ID
macOS
Win32
Desktop App
(With sapp)
new-slib-app-desktop YOUR_PROJECT_NAME
Android Mobile App
(Without sapp)
new-slib-app-android YOUR_PROJECT_NAME YOUR_APPLICATION_ID
iOS Mobile App
(Without sapp)
new-slib-app-ios YOUR_PROJECT_NAME
macOS Desktop App
(Without sapp)
new-slib-app-macos YOUR_PROJECT_NAME
macOS Console App
(Without sapp)
new-slib-console-macos YOUR_PROJECT_NAME
Win32 Desktop App
(Without sapp)
new-slib-app-win32 YOUR_PROJECT_NAME
Win32 Console App
(Without sapp)
new-slib-console-win32 YOUR_PROJECT_NAME
Linux Desktop App
(Without sapp)
new-slib-app-linux YOUR_PROJECT_NAME
Linux Console App
(Without sapp)
new-slib-console-linux YOUR_PROJECT_NAME

Note that you have to compile SLib before creating new SLib application projects.

Here is an example for creating a mobile app project.

mkdir ~/SLibMobileExample
cd ~/SLibMobileExample
new-slib-app-mobile Test org.example.testapp

To preview the user interface xml files

cd src/sapp/ui
sapp LaunchScreen
sapp MainPage

Here is an example for creating a desktop app project.

mkdir ~/SLibDesktopExample
cd ~/SLibDesktopExample
new-slib-app-desktop Test

Here is an example for creating an Android project.

mkdir ~/SLibAndroidExample
cd ~/SLibAndroidExample
new-slib-app-android Test org.example.testapp

Here is an example for creating a macOS Desktop project.

mkdir ~/SLibMacOSExample
cd ~/SLibMacOSExample
new-slib-app-macos Test

After creating projects, you can share same source code across the projects by adding same sources using IDE.

Integrating SLib with existing C++ projects

It is very easy to integrate SLib into your existing C++ project. You just need to setup include and lib directories into your existing C++ project.

Platform IDE Include Directory Link Directory
Android Android Studio (CMake) ${SLIB_PATH}/include ${SLIB_PATH}/lib/Android/${CMAKE_BUILD_TYPE}-${ANDROID_ABI}
iOS Xcode $(SLIB_PATH)/include $(SLIB_PATH)/lib/iOS/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
Tizen Tizen Studio ${SLIB_PATH}/include ${SLIB_PATH}/lib/Tizen/${ConfigName}-${SDK_ARCH}
macOS Xcode $(SLIB_PATH)/include $(SLIB_PATH)/lib/macOS/$(CONFIGURATION)
Win32 Visual Studio $(SLIB_PATH)/include $(SLIB_PATH)/lib/Win32/$(Configuration)-$(Platform)
Linux CMake, KDevelop ${SLIB_PATH}/include ${SLIB_PATH}/lib/Linux/${CMAKE_BUILD_TYPE}-${CMAKE_HOST_SYSTEM_PROCESSOR}

You can also integrate SLib into any types of C++ projects using similar include and lib directory rules.

Important: Your C++ project must be compiled with C++11 support.

After setup directories, link slib library via IDE or set -lslib option to the linker.

To make your project more portable, you can copy the include directory and the precompiled static libraries into your project and use the relative path instead of the environment variable.

Android Studio (using CMake)

Firstly, open and build the project in the build/Android directory in the SLib source. After completion of build, you can see the precompiled static libraries and slib.aar in the lib/Android directory.

Secondly, open your Android project created by yourself which will use SLib.

Important: Use gradle version 2.3.1 or higher.

Edit the build.gradle in your app module as following.

  ...
  android {
    ...
    defaultConfig {
      ...
      externalNativeBuild {
        ...
        cmake {
          cppFlags "-std=c++11"
          arguments "-DSLIB_PATH=${System.env.SLIB_PATH}"
        }
        ...
      }
      ndk {
        abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
      }

      ...
    }
  }
  ...
  repositories {
    ...
    flatDir{
       ...
       dirs "${System.env.SLIB_PATH}/lib/Android"
    }
  }
  dependencies {
    ...
    compile ':slib@aar'
  }
  

Edit CMakeLists.txt in your app module as following.

  ...
  include_directories (${SLIB_PATH}/include)
  link_directories (${SLIB_PATH}/lib/Android/${CMAKE_BUILD_TYPE}-${ANDROID_ABI})
  ...
  target_link_libraries (
    your-native-module-name
    ...
    slib
    log GLESv2 OpenSLES
    ...
  )
  ...

Edit the main cpp file (for example, native-lib.cpp), and insert the following code snippet.

#include <slib/core/platform_android.h>

JNIEXPORT jint JNI_OnLoad(JavaVM* jvm, void* reserved)
{
	slib::Android::initialize(jvm);
	return JNI_VERSION_1_4;
}

If you already defined JNI_OnLoad in somewhere, please insert slib::Android::initialize(jvm); in the existing definition, instead of inserting above code snippet.

Xcode (iOS, macOS)

Firstly, open and build the project in the build/iOS (or build/macOS for macOS) directory in the SLib source. After completion of build, you can see the precompiled static libraries in the lib/iOS (or lib/macOS for macOS) directory.

Secondly, open your Xcode project created by yourself which will use SLib.

  1. Click on the project icon in the inspector (on the left side)

  2. Click on the Build Settings tab on the right side

  3. Find Search Paths section

    • Add following path to Header Search Paths

      $(SLIB_PATH)/include

    • Add following path to Library Search Paths

      on iOS

      $(SLIB_PATH)/lib/iOS/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)

      on macOS

      $(SLIB_PATH)/lib/macOS/$(CONFIGURATION)

  4. Find Linking section

    Add following linker flag to Other Linker Flags

    -lslib

Tizen Studio

Firstly, open and build the project in the build/Tizen directory in the SLib source. After completion of build, you can see the precompiled static libraries in the lib/Tizen directory.

Secondly, open your Tizen project created by yourself which will use SLib.

  1. Right click on the project in the Project Explorer

  2. Click on Properties on the popup menu.

    Then, Properties popup window will be shown.

  3. Find C/C++ General in the left tree and then open it

    Select the subitem: Paths and Symbols. Then, Paths and Symbols property page will be shown on the right side.

    • Select Includes tab on the property page

      • Select GNU C++ in Languages list on the left side of the property page.

      • Click on the Add button on the right side of the property page.

      • In the Add directory path dialog, input the following path under the Directory: and click on OK button.

        ${SLIB_PATH}/include

    • Select Library Paths tab on the property page

      • Click on the Add... button on the right side of the property page.

      • In the Add... dialog, input the following path under the Directory: and click on OK button.

        ${SLIB_PATH}/lib/Tizen/${ConfigName}-${SDK_ARCH}

    • Select Libraries tab on the property page

      • Click on the Add... button on the right side of the property page.

      • In the Add... dialog, input the following name under the File: and click on OK button.

        slib

  4. Find C/C++ Build in the left tree and then open it

    Select the subitem: Settings. Then, Settings property page will be shown on the right side.

    • Select Tool Settings tab in the property page

    • Select C++ Compiler in the tree under the tab button

    • Select the subitem: Dialect

    • On the right side, select one of the following options for Language standard item.

      ISO C++11 (-std=c++0x)

      ISO C++1y (-std=c++1y)

Visual Studio

Firstly, open and build SLib.sln solution in the build/Win32 directory in SLib source. After completion of build, you can see the precompiled static libraries in the lib/Win32 directory.

Secondly, open your VC project created by yourself which will use SLib.

  1. Right click on the project in the Solution Explorer

  2. Click on Properties on the popup menu.

    Then, ... Property Pages dialog will be shown.

  3. Select VC++ Directories under the Configuration Properties in the left tree.

    On the right side,

    • Add following path to the Include Directories option

      $(SLIB_PATH)/include

    • Add following path to the Library Directories option

      $(SLIB_PATH)/lib/Win32/$(Configuration)-$(Platform)

  4. Select Linker under the Configuration Properties in the left tree.

    • Select subitem: Input

    • On the right side, add following file to the Additional Dependencies

      slib.lib

CMake or KDevelop

Firstly, run build-release.sh (or build-debug.sh) in the build/Linux directory in SLib source. (You can also use KDevelop project - SLib.kdev4 to compile SLib). After completion of build, you can see the precompiled static libraries in the lib/Linux directory.

Secondly, setup your project which will use SLib.

Edit CMakeLists.txt as following

    ...
    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
    
    set (SLIB_PATH $ENV{SLIB_PATH})
    include_directories (${SLIB_PATH}/include) 
    link_directories(${SLIB_PATH}/lib/Linux/${CMAKE_BUILD_TYPE}-${CMAKE_HOST_SYSTEM_PROCESSOR})
    ...
    target_link_libraries (
        your-executable-name
        ...
        slib
        dl z pthread ...
    )

Contributing

We sincerely appreciate your support and suggestions. For contributing pull requests, please make sure to contact us at [email protected].

License

SLib is dual-licensed. It is currently licensed under the MIT License, but also under a separate proprietary license. If you feel like you need to purchase a proprietary license for SLib, please contact us at [email protected]

slib's People

Contributors

bay-pavel avatar borys-duda-biz avatar canton32 avatar fred1218zh avatar georgi-ant avatar karoly-vig avatar lucasleongit avatar pmijailovic avatar vasylshumskyi avatar wille-hansson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slib's Issues

Production use

Has SLib been used in production ? If yes, for which platform and in which context ?

B.

How to set button in vertical layout?

For example:
Some words under a icon/image in center of button.

m_bButton2->setText("Test Title");
m_bButton2->setMultiLine(true);
m_bButton2->setMargin(30, 5, 5, 5);
m_bButton2->setSize(this->dprToPx(150), this->dprToPx(90));
m_bButton2->setBorder(false);
m_bButton2->setTextColor(slib::Color(54,142,244,255));
m_bButton2->setTextAlignment(slib::Alignment::BottomCenter);
m_bButton2->setIconMargin(10, 10, 10, 0);
m_bButton2->setIconSize(this->dprToPx(50), this->dprToPx(50));
m_bButton2->setIconAlignment(slib::Alignment::TopCenter);
m_bButton2->setIcon(slib::PlatformDrawable::loadFromAsset("images/images/homebg1.png"));

Localization for string values

Is it possible to support multi-language?
For example, native Android provides strings-xx.xml file inside value... and all values defined in this file are used for localization.
In other words, we can get different texts according to language preference by using just one id.
This is valid in iOS even if the method is different.

Is it possible such usage in SLib? If not, this is elementary requirement, I think.

UI: values need to be predefined in xml

<image
    name='img1'
    src='@drawable/ui_img1'
    scale='contain'
    width='40%sw'
    height='40%sh'
    centerHorizontal='true'
    top='15%sh'
/>
...
<image
    name='img2'
    src='@drawable/ui_img2'
    scale='contain'
    width='40%sw'
    height='40%sh'
    centerHorizontal='true'
    top='15%sh'
/>

Here, it's not convenient to write 40%sp every time and will be more annoying for update/revision.
Such problems happen in working with values like

  • dimension
  • color
  • number
  • animation
  • shape

There's already string value implemented in desirable way.

"Image::loadFromAsset" error in extended class on Android

FILE:loginForm.h
CODE:
class loginFormApp : public ViewPage
{
public:
loginFormApp(MobileApp* p_hanlde);//创建初始化对象
Ref pHanlde;
...
}

FILE:loginForm.cpp
CODE:
loginFormApp::loginFormApp(MobileApp* p_hanlde)
{
pHanlde = p_hanlde;
Ref imageView1 = new ImageView;
imageView1->setWidthFilling();
imageView1->setHeightFilling();
imageView1->setSource(Image::loadFromAsset("images/logo.png"));
...
pHanlde->addViewToContent(mlogin_main_view);
}

Android:Image::loadFromAsset can not show image.
IOS:OK

In app.cpp:
CODE:
Ref imageView1 = new ImageView;
imageView1->setWidthFilling();
imageView1->setHeightFilling();
imageView1->setSource(Image::loadFromAsset("images/logo.png"));

"Image::loadFromAsset" is ok.
Android:OK
IOS:OK

Layouting issue

When I use the aspect ratio mode for layouting and wrapping, it doesn't work properly for linear view.

<sapp version='1'>
	<layout
		type='page'
		name='WelcomePage'
		background='@drawable/background'
		backgroundScale='cover'
		>
		
		<linear orientation='vertical'
			width='wrap'
			height='wrap'
			alignCenter='true'
			background='red'>

			<image src='@drawable/slib_icon'
				width='15%sw'
				centerHorizontal='true'/>
			
			<label text='Welcome to SLib.io'
				width='wrap'
				height='wrap'
				marginTop='5%sh'/>

		</linear>

 	</layout>
</sapp>

Tracking animation steps

In following example, maybe the dev needs to track while animating, how much the value has been changed as the time being.

Ref<Animation> animation = view->createTranslateAnimationTo(Vector2(300, 300), 3);
animation->setRepeatCount(5);
animation->start();

So, how about following solution?

Ref<Animation> animation = view->createTranslateAnimationTo(Vector2(300, 300), 3);
animation->setRepeatCount(5);

// suggestion //////
animation->setTracker([](deltaTime, state) {
    // deltaTime is 0-based and limited to 3s x 5(repeat)
    // state is related to Vector2(300,300)
    do_some(deltaTime, state);
}); 
/////////////////////////

animation->start();

Undefined symbols for architecture x86_64: "ExampleCameraViewApp::DEVPPI"

Error Information:
Undefined symbols for architecture x86_64:
"ExampleCameraViewApp::DEVPPI", referenced from:
ExampleCameraViewApp::onStart() in app.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

When:

#ifdef SLIB_PLATFORM_IS_MOBILE
DEVPPI = slib::DeviceInformation::getDevicePPI();
Console::println("\r\nPPI:%ld\r\n",DEVPPI);//Show PPI
#else
DEVPPI = 163;//Show ppi
#endif

multiple definition of `slib::Console::readLine()' In Android Studio

Build command failed.
Error while executing process /Users/rareli/Library/Android/sdk/cmake/3.6.4111459/bin/cmake with arguments {--build /Users/rareli/Documents/SLIB/SLib/examples/UI/CameraView/Android/app/.externalNativeBuild/cmake/debug/arm64-v8a --target native-lib}
[1/3] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o
[2/3] Building CXX object CMakeFiles/native-lib.dir/Users/rareli/Documents/SLIB/SLib/examples/UI/CameraView/src/app.cpp.o
[3/3] Linking CXX shared library ../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libnative-lib.so
FAILED: : && /Users/rareli/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android --gcc-toolchain=/Users/rareli/Library/Android/sdk/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64 --sysroot=/Users/rareli/Library/Android/sdk/ndk-bundle/sysroot -fPIC -isystem /Users/rareli/Library/Android/sdk/ndk-bundle/sysroot/usr/include/aarch64-linux-android -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -frtti -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a --sysroot /Users/rareli/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm64 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libnative-lib.so -o ../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o CMakeFiles/native-lib.dir/Users/rareli/Documents/SLIB/SLib/examples/UI/CameraView/src/app.cpp.o -L/Users/rareli/Documents/SLIB/SLib/tool/../lib/Android/Debug-arm64-v8a -lslib -llog -lGLESv2 -latomic -lm "/Users/rareli/Library/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/libgnustl_static.a" && :
/Users/rareli/Documents/SLIB/SLib/tool/../lib/Android/Debug-arm64-v8a/libslib.a(log.cpp.o): In function slib::Console::readLine()': /Users/rareli/Documents/SLIB/SLib/src/slib/core/log.cpp:36: multiple definition of slib::Console::readLine()'
/Users/rareli/Documents/SLIB/SLib/tool/../lib/Android/Debug-arm64-v8a/libslib.a(system.cpp.o):/Users/rareli/Documents/SLIB/SLib/src/slib/core/system.cpp:160: first defined here
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

Xml layout property - alignTop/alignLeft/alignRight/alignBottom name refine.

I'm reading document, but I think it would be good if you can change alignBottom to alignParentBottom.
It's a bit complicated, because if you didn't provided screenshot, I couldn't notice that it's
a layout_gravity option.
I thought it's a gravity option at the first time before I check the screenshot.

ChromiumView is empty when start the window by sapp.untill resized the window.

A bug in ChromiumView on mac.
I was added ChromiumView into linear in sapp.
but webview can not show in window,untill I have been resized the window.

It's normal without sapp(example project).
[SAPP]

[CPP]

void MainWindow::onCreate()
{
Ref m_webView;
this->setResizable(true);
m_webView = new ChromiumView;
m_webView->setWidthFilling();
m_webView->setHeightFilling();
m_webView->loadURL("https://bing.com");
mainLinear->addChild(m_webView);
}

webview is error

the webview is null when open a url/page.
code:

m_webView = new WebView();
m_webView->setWidthFilling();
m_webView->setHeightFilling();

m_webView->loadURL("http://mozilla.org/MPL/2.0/");

Console::println("Error:%s",m_webView->getErrorMessage());

addViewToContent(m_webView);

new attribute is required (cornerRound)

Among View attributes, it'll be better to define cornerRound to specify round size at corners.
It will be useful to create round buttons.

In this case, there will be conflict between boundShape attribute.
boundShape can be one of rectangle, ellipseor roundRect.
My request is related to roundRect but more edge-case.

So I suggest following forms of solution based on removing boundShape.

<View
   ...
   width="dimenWidth"
   height="dimenHeight"
   cornerRound="dimenCorner"
   ...
/>

Let's assume that dimenWidth > dimenHeight.

  • if dimenCorner=0, same result of boundShape=rectangle.
  • if dimenCorner<dimenHeight/2, similar to boundShape=roundRect but more accurate.
  • if dimenHeight/2<=dimenCorner<dimenWidth/2, round sides but linear top/bottom lines.
  • otherwise, same result of boundShape=ellipse.

UrlRequest::post use https

Request to https website.
Error:D/NetworkSecurityConfig: No Network Security Config specified, using platform default
W/IInputConnectionWrapper: finishComposingText on inactive InputConnection

LOG:
Client not ready yet..Waiting for process to come online
Connected to process 6963 on device smartisan-od103-ce88d86d
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/System: Daemon delayGCRequest, sDelayGCRequest=true, delay=false, sPendingGCRequest=false
I/chromium: [INFO:CONSOLE(4)] "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.", source: file:///android_asset/images/js/jquery-2.1.4.min.js (4)
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
D/INFO: Keyboard is disappeared
I/Activity: Paused

DeviceInformation::getDevicePPI() ERROR

IOS:OK
Android:Error

Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/System: Daemon delayGCRequest, sDelayGCRequest=false, delay=true, sPendingGCRequest=false
I/Console: Width:1080
PPI:4294967295(Error value)

code:
Console::print("PPI:%d",DeviceInformation::getDevicePPI());

java.lang.UnsatisfiedLinkError: No implementation found for void slib.platform.android.Android.nativeOnCreateActivity(android.app.Activity)

Me again.
As I am waiting for the iOS example, I've been trying to at least test the Android part as I saw there was a JNI example in the examples folder.
So the basic example does run. But as soon as I try to use the SLibActivity on the Java side I end up with the error specified in the title
Here is the full bug report:

What steps will reproduce the problem?

  1. Build and run the JNI example
  2. JNI example runs without any error
  3. In MainActivity, add
Intent intent = new Intent(this, VideoActivity.class);
this.startActivity(intent);

to onCreate

with VideoActivity as follows:

public class VideoActivity extends SlibActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        Log.d("VideoActivity", "onCreate");

    }
}
  1. The app crashes

What is the expected result?

The app should not crash

What do you see instead?

  1. The app crashes with:
Java_slib_platform_android_Android_nativeOnCreateActivity and Java_slib_platform_android_Android_nativeOnCreateActivity__Landroid_app_Activity_2)
                                                       at slib.platform.android.Android.nativeOnCreateActivity(Native Method)
                                                       at slib.platform.android.Android.onCreateActivity(Android.java:42)
                                                       at slib.platform.android.SlibActivity.onCreate(SlibActivity.java:39)
                                                       at android.app.Activity.performCreate(Activity.java:6813)
                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1121)
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2677)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789)
                                                       at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
                                                       at android.os.Handler.dispatchMessage(Handler.java:110)
                                                       at android.os.Looper.loop(Looper.java:203)
                                                       at android.app.ActivityThread.main(ActivityThread.java:6251)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)

What version of the product are you using? On what operating system?

Version v0.1.4 - Android 7.0

Please provide any additional information below.

  1. I am not sure what is going on, why the linking error happens as thenative-lib.so gets loaded properly but then at runtime, calling Android.nativeOnCreateActivity crashes

Hope you will be able to help out, I'm just trying to get a camera feed.

Follow the C++ standard rules regarding reserved names

The C++ Standard, [reserved.names] [ISO/IEC 14882-2014], specifies the following rules regarding reserved names:

  • ...
  • Each name that contains a double underscore __ or begins with an underscore followed by an uppercase letter is reserved to the implementation for any use.
  • Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace.
  • ...

For more information, visit https://www.securecoding.cert.org/confluence/display/cplusplus/DCL51-CPP.+Do+not+declare+or+define+a+reserved+identifier

suggest about headers

hi, thanks for so nice lib!!!
i have some suggest about headers.

  1. rename the root dir "inc" to "include"
  2. change the include rule "../../../inc/slib/xxx/xxx.h" to "slib/xxx/xxx.h"
    do it to all header and src,just as google c++ guide.

example: SLib/src/slib/core/base.cpp
#include "../../../inc/slib/core/base.h" ==> #include "slib/core/base.h"

example:SLib/inc/slib/core/base.h
#include "definition.h" ==> #include "slib/core/definition.h"

Flash back in android

Device: Mobile Phone
Android Version: 23(6.x)
Bug: Exit app as soon as possible when starting.

Debug Information:

$ adb push /Users/rareli/Documents/WORKSPACE/SLib/examples/UI/CameraView/Android/app/build/outputs/apk/debug/app-debug.apk /data/local/tmp/io.slib.examplecameraview
$ adb shell pm install -t -r "/data/local/tmp/io.slib.examplecameraview"
pkg: /data/local/tmp/io.slib.examplecameraview
Success

$ adb shell am start -n "io.slib.examplecameraview/io.slib.examplecameraview.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while executing: am start -n "io.slib.examplecameraview/io.slib.examplecameraview.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=io.slib.examplecameraview/.MainActivity }
Error type 3

Error: Activity class {io.slib.examplecameraview/io.slib.examplecameraview.MainActivity} does not exist.

Error while Launching activity

Example for iOS and Android

Would it be possible to have any example on how to use SLib for iOS/Android via a tableview/list sample app ?

How to make background's alpha?

now,I can't set background's alpha by setAlpha();
eg.
m_view = new View;
m_view->setWidthFilling();
m_view->setHeight(150);//It's px? I advise to use dp.
m_view->setTop(0);
m_view->setBorderColor(slib::Color::Red); // test Color
m_view->setBorderWidth(2);
//m_view->setAlwaysOnDrawBackground(true);
m_view->setBackgroundColor(slib::Color::Blue);
m_view->setAlpha(0.8);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.