Splashcreen plugin (Cordova) and icons do not work on Crosswalk

Asked

Viewed 1,633 times

4

I’m using this module that automatically adds a Crosswalk wrapper to a Cordova project.

Obs: It requires "Platform" to be [email protected].

Okay, then I give the command to Wrap the Crosswalk in the project and everything goes well.

It builds normally with the plugin dialogs and others. However when I install the Splashscreen plugin and try to give run, an error happens:

-pre-compile:
     [echo] Set jars path to: /home/rop/Projetos/Pray/cordovaa2/platforms/android/CordovaLib/ant-build/classes.jar:/home/rop/Projetos/Pray/cordovaa2/platforms/android/CordovaLib/xwalk_core_library/ant-build/classes.jar:/home/rop/Projetos/Pray/cordovaa2/platforms/android/CordovaLib/xwalk_core_library/libs/xwalk_core_library_java_app_part.jar:/home/rop/Projetos/Pray/cordovaa2/platforms/android/CordovaLib/xwalk_core_library/libs/xwalk_core_library_java_library_part.jar

-compile:
    [javac] Compiling 5 source files to /home/rop/Projetos/Pray/cordovaa2/platforms/android/ant-build/classes
    [javac] warning: /home/rop/Projetos/Pray/cordovaa2/platforms/android/CordovaLib/xwalk_core_library/libs/xwalk_core_library_java_app_part.jar(org/xwalk/core/XWalkView.class): major version 51 is newer than 50, the highest major version supported by this compiler.
    [javac] It is recommended that the compiler be upgraded.
    [javac] /home/rop/Projetos/Pray/cordovaa2/platforms/android/src/org/apache/cordova/splashscreen/SplashScreen.java:232: cannot find symbol
    [javac] symbol  : method canGoBack()
    [javac] location: class org.apache.cordova.CordovaWebView
    [javac]         if (webView.canGoBack()) {
    [javac]                    ^
    [javac] 1 error
    [javac] 1 warning

BUILD FAILED
/opt/android-sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/opt/android-sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.

Total time: 4 seconds

/home/rop/Projetos/Pray/cordovaa2/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: ant with args: debug,-f,/home/rop/Projetos/Pray/cordovaa2/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
ERROR running one or more of the platforms: Error: /home/rop/Projetos/Pray/cordovaa2/platforms/android/cordova/run: Command failed with exit code 8
You may not have the required environment or OS to run this project

My folder structure:

Estrutura de pastas

My config.xml:

<?xml version="1.0" encoding="utf-8"?>
<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>appName</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="[email protected]" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <access origin="*" />
    <platform name="android">

        <splash src="res/android/screen/res-long-port-hdpi/default.png" densitit="port-hdpi"/>
        <splash src="res/android/screen/res-long-port-ldpi/default.png" densitit="port-ldpi"/>
        <splash src="res/android/screen/res-long-port-mdpi/default.png" densitit="port-mdpi"/>
        <splash src="res/android/screen/res-long-port-xhdpi/default.png" densitit="port-xhdpi"/>

        <icon src="res/android/icon/drawable-ldpi/appicon/png" density="ldpi" />
        <icon src="res/android/icon/drawable-mdpi/appicon.png" density="mdpi" />
        <icon src="res/android/icon/drawable-hdpi/appicon.png" density="hdpi" />
        <icon src="res/android/icon/drawable-xhdpi/appicon.png" density="xhdpi" />

    </platform>
</widget>

XML

PS: Also, even icons don’t work, although they don’t depend on Plugins... Every time I run, the app installs with the default icon of Cordova.

  • 1

    You gave command of the crosswalk before or after adding the Splashscreen Plugin?

  • What instructions are you using to compile? What is the compiler version?

  • @Victorstafusa, use Cordova 4.2.0, Android 5.1 API 22. Use the 'android run Cordova' but from this error I have installed the splashscreen plugin (without it builds normal).

  • If you give a javac -version, what appears?

  • @Victorstafusa 1.6.0_34

  • I searched the code on line 232 of the file /splashscreen/SplashScreen.java and I realized that it really calls a function canGoBack of a Webview variable, such as crosswalk changes the application to use the Chromium webview I believe it does not have this function or implementation. So make sure that when performing the crosswalk to convert the project you ta have the plugin installed.

  • @Pedrohenrique, I have the plugin in the Plugins folder of the project. I am using this module to facilitate the process of installing Crosswalk https://www.npmjs.com/package/cordova-android-crosswalk. It requires the android platform in version 3.6.3.

  • @ropbla9 I was able to reproduce the error, I will make some tests and I will inform you.

Show 3 more comments

2 answers

3


As commented the problem is not presented before using the cordova-android-crosswalk, this is due to the library version of Cordova, Crosswalk requires version 3.6.3, this version has some differences between a class called CordovaWebView.java, basically it does not implement all functions of the class and separates between more files. I will not go into too much depth since the problem here is about Cordova and not Java.

But well to solve the problem is quite simple, let’s just edit a file.

Inside the main folder of your project look for the file platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java

Open this file and right after the class declaration CordovaWebView (row 80) paste the following code.

    public boolean canGoBack() {
        return super.getNavigationHistory().canGoBack();
    }

Then try again to give the build command of your project.

  • worked. Thank you so much! It’s like giving you a reward?

  • 1

    Do not know friend, try to flag the question and check with an administrator or ask a more experienced user. Next time just try to gratify and mark the right answer after checking if it solves your problem. But I’m glad you solved your problem, anytime let me know if the crosswalk really makes the Cordova apps faster.

  • compile but still splashscreen does not appear. Everything remains configured as in the question...

  • 1

    I will edit the answer with splash settings, the icons also do not work yet?

  • I already got man!

  • when I went to upgrade the version of Java came together several Features in the Ubuntu bar: Java8 Mission control, Java8 console, java8 visualVM etc.. How do I remove?

  • @ropbla9 So you managed to run your application smoothly or still have difficulties? About the Ubuntu toolbar see if this link helps http://askubuntu.com/questions/71240/how-to-remove-icons-shortcuts-from-unity-menu I don’t use much Ubuntu so I can’t help you with that.

Show 2 more comments

2

According to the wikipedia:

J2SE 8 = 52
J2SE 7 = 51
J2SE 6.0 = 50
J2SE 5.0 = 49
JDK 1.4 = 48
JDK 1.3 = 47
JDK 1.2 = 46
JDK 1.1 = 45

In your mistakes appears this:

warning: /home/rop/Projetos/Pray/cordovaa2/platforms/android/CordovaLib/xwalk_core_library/libs/xwalk_core_library_java_app_part.jar(org/xwalk/core/XWalkView.class): major version 51 is newer than 50, the highest major version supported by this compiler.

Let’s pay special attention to that:

(org/xwalk/core/Xwalkview.class): major version 51 is newer than 50, the Highest major version supported by this Compiler.

You have informed your compiler (while trying to use javac -version) is 1.6.0_34, i.e., major version 50. However, apparently the class org.xwalk.core.XWalkView was compiled with Java 7 (major version 51) and as a result the compiler of Java 6 is not able to understand or use it.

To solve this, I see three possible alternatives (not mutually exclusive):

  • Upgrade your compiler to Java 7 or Java 8. However, care must be taken to make sure that android will accept the resulting classes. If these classes use the Try-with-Resources, then they will only work on Android Kitkat (API level 19, Android 4.4) or higher (Source). In addition, Android does not yet accept Java 8, but you can use as one of the options when invoking the compiler, -target 1.6 or -target 1.7.

  • Recompile these classes with the Java 6 compiler, if you have the source code.

  • Use any tool that downgrades the Java 7 (or 8) class to Java 6. The most well-known tool for this purpose is the retro-lambda.


As for icons, note this in your XML:

<icon src="res/android/icon/drawable-ldpi/appicon/png" density="ldpi" />

Instead of appicon/png, should be appicon.png. However, I don’t know if that’s all that’s wrong or if there’s something else.

For more details, it would be good for you to better describe your folder structure, in particular what is inside the res.


And some tips on your question:

  • You forgot to put the tags and . As a result, few people saw her question and it only caught my attention because of the active reward. Don’t forget the tags next time!

  • Do not put code in image format, because it is difficult to read (because the browser resizes the image) and also the text is not selectable. I only noticed your icon error when rewriting all the XML when editing your question.

  • installed Java 7 according to this answer here http://stackoverflow.com/questions/16263556/installing-java-7-on-ubuntu. Did not work; same error

  • 1

    @ropbla9 This link shows you how to install a Java 7 virtual machine (JRE). What you need is a Java 7 compiler (JDK). It is no use to have a Java 7 or Java 8 JVM if your compiler is still Java 6, because in this case you will (obviously) only be able to compile programs until Java 6.

  • no time now. Tomorrow I will try to install the compiler and test again, but I have already marked your answer

  • tried its 3 solutions and the problem persists. I installed up to Java JKD 8 and nothing

  • i have the splash plugin in the Plugins folder of the project. I am using this module to facilitate the process of installing Crosswalk https://www.npmjs.com/package/cordova-android-crosswalk. It requires the android platform in version 3.6.3. If I don’t install Cordova or platform 3.6.3 (normal) nothing’s wrong.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.