Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please have your activity extend XWalkActivity for shared mode #4

Closed
Yury-Soika opened this issue Jan 4, 2019 · 12 comments
Closed
Labels
good first issue Good for newcomers

Comments

@Yury-Soika
Copy link

Hi, everybody!

I have the latest version of xwalk library: 23.53.589.4
I did everything as written in readme.md.
Added new XWalkView (getApplicationContext ()). OnDestroy (); And on this line falls error:
java.lang.RuntimeException: Please have your activity extend XWalkActivity for shared mode
Please tell me what to do, how to fix the error and start the application. Maybe there are examples of working applications. Share them, I will be grateful.

Best regards.
Yury

@fantasy525
Copy link
Owner

@WaterlooBridge

@WaterlooBridge
Copy link
Collaborator

@Soyko-Y Are you running on x86 phone or emulator? If yes, you need to add x86's arr file, otherwise can't find x86's so, it will automatically open sharing mode.

@fantasy525
Copy link
Owner

Hi, everybody!

I have the latest version of xwalk library: 23.53.589.4
I did everything as written in readme.md.
Added new XWalkView (getApplicationContext ()). OnDestroy (); And on this line falls error:
java.lang.RuntimeException: Please have your activity extend XWalkActivity for shared mode
Please tell me what to do, how to fix the error and start the application. Maybe there are examples of working applications. Share them, I will be grateful.

Best regards.
Yury

We use crosswalk webview arr file support armeabi-v7a only,so you can use other armeabi-v7a cpu phone.

@Yury-Soika
Copy link
Author

Hi, everybody!
I have the latest version of xwalk library: 23.53.589.4
I did everything as written in readme.md.
Added new XWalkView (getApplicationContext ()). OnDestroy (); And on this line falls error:
java.lang.RuntimeException: Please have your activity extend XWalkActivity for shared mode
Please tell me what to do, how to fix the error and start the application. Maybe there are examples of working applications. Share them, I will be grateful.
Best regards.
Yury

We use crosswalk webview arr file support armeabi-v7a only,so you can use other armeabi-v7a cpu phone.

On the crosswalk site, I found libraries for arm and for x86. If I download a library for both architectures, then it should work for all devices? Or is it more complicated? And how to create a .aar file to connect it to the project?

@fantasy525
Copy link
Owner

Hi, everybody!
I have the latest version of xwalk library: 23.53.589.4
I did everything as written in readme.md.
Added new XWalkView (getApplicationContext ()). OnDestroy (); And on this line falls error:
java.lang.RuntimeException: Please have your activity extend XWalkActivity for shared mode
Please tell me what to do, how to fix the error and start the application. Maybe there are examples of working applications. Share them, I will be grateful.
Best regards.
Yury

We use crosswalk webview arr file support armeabi-v7a only,so you can use other armeabi-v7a cpu phone.

On the crosswalk site, I found libraries for arm and for x86. If I download a library for both architectures, then it should work for all devices? Or is it more complicated? And how to create a .aar file to connect it to the project?

Yes,you can dowload a library for both architectures (arm,x86),you just replace my .arr file, but your apk size will very big, you can have a try,and If have any questions, please tell me!
step1:download this .aar file: arm&x86 aar
step2:find this libs dir,and copy your dowload both architectures aar to here
image
then open build.gradle,and modify this:
image

setp3: in the meanwhile,copy aar to your project app/libs here:
image
and same as step2
open your project app/build.gradle
image

modify name .
finally you sync project ,and run

@Yury-Soika
Copy link
Author

Yury-Soika commented Jan 18, 2019

Hi, everybody!
I have the latest version of xwalk library: 23.53.589.4
I did everything as written in readme.md.
Added new XWalkView (getApplicationContext ()). OnDestroy (); And on this line falls error:
java.lang.RuntimeException: Please have your activity extend XWalkActivity for shared mode
Please tell me what to do, how to fix the error and start the application. Maybe there are examples of working applications. Share them, I will be grateful.
Best regards.
Yury

We use crosswalk webview arr file support armeabi-v7a only,so you can use other armeabi-v7a cpu phone.

On the crosswalk site, I found libraries for arm and for x86. If I download a library for both architectures, then it should work for all devices? Or is it more complicated? And how to create a .aar file to connect it to the project?

Yes,you can dowload a library for both architectures (arm,x86),you just replace my .arr file, but your apk size will very big, you can have a try,and If have any questions, please tell me!
step1:download this .aar file: arm&x86 aar
step2:find this libs dir,and copy your dowload both architectures aar to here
image
then open build.gradle,and modify this:
image

setp3: in the meanwhile,copy aar to your project app/libs here:
image
and same as step2
open your project app/build.gradle
image

modify name .
step4:
app/buid.gradle

defaultConfig {
        ndk {
            abiFilters  "armeabi-v7a", "x86" 
        }
    }

finally you sync project ,and run

@fantasy525 Thank you very much for the detailed guidance. I did everything as you described and the problem with shared mode was solved. But there was a new problem.
capture

"HomeScreen" - it's my file where I use "RCTCrossWalkWebView"
So, I try import it like in your manual: import { RCTCrossWalkWebView } from 'react-native-crosswalk-webview-plus'
And then I use it like in your example: <RCTCrossWalkWebView style={{width:500,flex:1}} source={{uri:'https://www.baidu.com'}}/>
And I get an error as in the screenshot.
I try import "RCTCrossWalkWebView" without {}, like that: import RCTCrossWalkWebView from 'react-native-crosswalk-webview-plus'
But get the same error.

If you know, how to solve it, please, help me.

@fantasy525
Copy link
Owner

@Soyko-Y

you check your local npm package, in RCTCrossWalkWebView.js

/**
 * 此处requireNativeComponent的第一个参数为源码corssWalkWebViewGroupManager 中
 * public static final String REACT_CLASS = "CrosswalkWebView"; 的值,不能随便写,否则会提示找不到模块
 */
const NativeCrosswalkWebView = requireNativeComponent('CrosswalkWebView', RCTCrossWalkWebView, {
  nativeOnly: {
    messagingEnabled: PropTypes.bool,
  },
});
export {RCTCrossWalkWebView} ;

I export {RCTCrossWalkWebView}, so you need do this:

import { RCTCrossWalkWebView } from 'react-native-crosswalk-webview-plus'

if this not work,please install latest version.

@Yury-Soika
Copy link
Author

@Soyko-Y

you check your local npm package, in RCTCrossWalkWebView.js

/**
 * 此处requireNativeComponent的第一个参数为源码corssWalkWebViewGroupManager 中
 * public static final String REACT_CLASS = "CrosswalkWebView"; 的值,不能随便写,否则会提示找不到模块
 */
const NativeCrosswalkWebView = requireNativeComponent('CrosswalkWebView', RCTCrossWalkWebView, {
  nativeOnly: {
    messagingEnabled: PropTypes.bool,
  },
});
export {RCTCrossWalkWebView} ;

I export {RCTCrossWalkWebView}, so you need do this:

import { RCTCrossWalkWebView } from 'react-native-crosswalk-webview-plus'

if this not work,please install latest version.

@fantasy525 I checked local npm package, in RCTCrossWalkWebView.js.
All like in you. Exported as well. Updated to the latest version and nothing. Did not help. However, I found a solution. I changed your code a bit and it worked for me:

In RCTCrossWalkWebView.js:

const WEBVIEW_REF = 'crosswalkWebView';

const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');
//class RCTCrossWalkWebView extends Component{
export default class RCTCrossWalkWebView extends Component{
  static JSNavigationScheme=JSNavigationScheme;

...

const NativeCrosswalkWebView = requireNativeComponent('CrosswalkWebView', RCTCrossWalkWebView, {
  nativeOnly: {
    messagingEnabled: PropTypes.bool,
  },
});
// export {RCTCrossWalkWebView} ;

In index.js:

import RCTCrossWalkWebView from './RCTCrossWalkWebView'
// export {RCTCrossWalkWebView}
module.exports = RCTCrossWalkWebView

And import like this:

import RCTCrossWalkWebView from 'react-native-crosswalk-webview-plus'

Now everything works and I'm happy. Thank you, @fantasy525 :)

@fantasy525
Copy link
Owner

@Soyko-Y OK,enjoy yourself!

@fantasy525 fantasy525 added the good first issue Good for newcomers label Feb 17, 2019
@fantasy525 fantasy525 pinned this issue Feb 17, 2019
@Domingowen
Copy link

i found the this problem new XWalkView(this).onDestroy();

  • What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

and android build fail, could you help how resolve this problem ?

@fantasy525
Copy link
Owner

@Domingowen Hi,Are you in a Shared mode?and do you use both x86 and arm aar?

@neilzhengzx
Copy link

neilzhengzx commented Aug 26, 2021

in proguard-rules.pro

-keep class org.xwalk.core.**{*;}
-keep class org.chromium.**{*;}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants