mapsplugin / cordova-plugin-googlemaps

Google Maps plugin for Cordova
Apache License 2.0
1.66k stars 913 forks source link

cca project fails to compile #302

Closed instaplacecyprus closed 8 years ago

instaplacecyprus commented 9 years ago

When adding this plugin to my project that uses cca (chrome mobile apps) it fails to compile

chrisharney commented 9 years ago

built with crosswalk-cordova-13.41.318.0-arm: black screen screenshot_2015-03-12-13-33-53

wf9a5m75 commented 9 years ago

Bug report: Transparent incorrectly https://crosswalk-project.org/jira/browse/XWALK-3742

trancee commented 9 years ago

LogCat shows me the following output regarding Crosswalk, could that be another issue?

03-18 10:38:30.452: D/GoogleMapsPlugin(20728): (debug)action=getMap args[0]={"backgroundColor":[0,0,0,0]}
03-18 10:38:30.462: D/GoogleMapsPlugin(20728): (debug)action=clear
03-18 10:38:30.462: D/GoogleMapsPlugin(20728): (debug)action=exec args[0]=Map.setOptions
03-18 10:38:30.462: D/GoogleMapsPlugin(20728): (debug)action=getMyLocation args[0]={"enableHighAccuracy":true}
03-18 10:38:30.472: W/XWalkViewInternal(20728): LAYER_TYPE_SOFTWARE is not supported by XwalkView

It then seems to throw an exception, but not sure it is relevant:

03-18 10:38:31.852: W/CordovaPlugin(20728): Attempted to send a second callback for ID: GoogleMaps265083622
03-18 10:38:31.852: W/CordovaPlugin(20728): Result was: "No result"
03-18 10:38:31.872: W/System.err(20728): java.lang.reflect.InvocationTargetException
03-18 10:38:31.872: W/System.err(20728):    at java.lang.reflect.Method.invokeNative(Native Method)
03-18 10:38:31.872: W/System.err(20728):    at java.lang.reflect.Method.invoke(Method.java:515)
03-18 10:38:31.872: W/System.err(20728):    at plugin.google.maps.MyPlugin.execute(MyPlugin.java:50)
03-18 10:38:31.872: W/System.err(20728):    at plugin.google.maps.GoogleMaps$3.run(GoogleMaps.java:250)
03-18 10:38:31.872: W/System.err(20728):    at android.os.Handler.handleCallback(Handler.java:733)
03-18 10:38:31.872: W/System.err(20728):    at android.os.Handler.dispatchMessage(Handler.java:95)
03-18 10:38:31.872: W/System.err(20728):    at android.os.Looper.loop(Looper.java:136)
03-18 10:38:31.872: W/System.err(20728):    at android.app.ActivityThread.main(ActivityThread.java:5146)
03-18 10:38:31.872: W/System.err(20728):    at java.lang.reflect.Method.invokeNative(Native Method)
03-18 10:38:31.872: W/System.err(20728):    at java.lang.reflect.Method.invoke(Method.java:515)
03-18 10:38:31.872: W/System.err(20728):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
03-18 10:38:31.872: W/System.err(20728):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
03-18 10:38:31.872: W/System.err(20728):    at dalvik.system.NativeStart.main(Native Method)
03-18 10:38:31.872: W/System.err(20728): Caused by: java.lang.NullPointerException: null camera target
03-18 10:38:31.872: W/System.err(20728):    at com.google.android.gms.common.internal.o.b(Unknown Source)
03-18 10:38:31.882: W/System.err(20728):    at com.google.android.gms.maps.model.CameraPosition.(Unknown Source)
03-18 10:38:31.882: W/System.err(20728):    at com.google.android.gms.maps.model.CameraPosition.(Unknown Source)
03-18 10:38:31.882: W/System.err(20728):    at com.google.android.gms.maps.model.CameraPosition$Builder.build(Unknown Source)
03-18 10:38:31.882: W/System.err(20728):    at plugin.google.maps.PluginMap.setOptions(PluginMap.java:116)
03-18 10:38:31.882: W/System.err(20728):    ... 13 more
wf9a5m75 commented 9 years ago

@trancee That is not related. Even withoug google map, I testes just an image view, crosswalk can not display it under the browser.

Watch here: https://crosswalk-project.org/jira/plugins/servlet/mobile#issue/XWALK-3742

and if you have enough time, please join to the discussion.

trancee commented 9 years ago

I cloned your test repository and tried out the suggestion by fujunwei, unfortunately it did not change anything.

I did not fully understand his suggestion about the SurfaceView though. I tried to add the flag PixelFormat.TRANSPARENT when adding the appView to the root in the createViews method of CordovaActivity.java, but this did also not help.

jianbo commented 9 years ago

Any update for this issue?

wf9a5m75 commented 9 years ago

Ask to here. https://crosswalk-project.org/jira/plugins/servlet/mobile#issue/XWALK-3742

ghost commented 9 years ago

It seems the issue have been fixed. https://crosswalk-project.org/jira/browse/XWALK-3742

wf9a5m75 commented 9 years ago

I'm busy today. Check it out by yourself @easyalgoltd

wf9a5m75 commented 9 years ago

I confirmed this plugin (#test branch) worked with CrossWalk version 14.42.329.0 https://github.com/wf9a5m75/phonegap-googlemaps-plugin/wiki/Tutorial-for-CrossWalk-(Android)

wf9a5m75 commented 9 years ago
alert(navigator.appVersion);

crosswalk

telemakhos commented 9 years ago

Great! Many thanks! :smile: :+1:

hirbod commented 9 years ago

Best news on this sunny day :)

michahell commented 9 years ago

Yay. If anyone could confirm for android 4.2.2 + that'd be great! Can not test it myself today unfortunately :(

JcDenton86 commented 9 years ago

Map shows up on my nexus! great and thanks

TranceLove commented 9 years ago

Works perfect with my Ionic-based project running on my OnePlus One running SlimLP (custom 5.0.2). :+1:

hirbod commented 9 years ago

Could someone make a tutorial how to port an existing project to crosswalk? And what about Intel and arm? Are there any differences? Do we need both binaries? Or is arm enough?

gustavohenke commented 9 years ago

@Hirbod, an tutorial exists here: https://crosswalk-project.org/documentation/cordova/migrate_an_application.html

There are downloads available for both ARM + Intel or just one of them: https://crosswalk-project.org/documentation/downloads.html

hirbod commented 9 years ago

How important is it to support x86? If we include both binaries in one apk, the app size is about 50mb, if not, we have to deploy two apks and upload two files to the play store. I would like to know how you guys handle this.

JcDenton86 commented 9 years ago

Hi @Hirbod:

You can follow the 6 steps described here. When you are done and you build successfully, then change your Cordova Java class as wf9a5m75 shows in the wiki page. As for the apk you don't have to support both, just arm (the x86 is for intel cpus)

gustavohenke commented 9 years ago

How important is it to support x86?

I don't think it's too important... http://www.gsmarena.com/results.php3?sFreeText=Intel&sOSes=2 Even though my search may be kinda weak to find all x86 Android phones.

hirbod commented 9 years ago

Thanks for the report guys. I will report back later. I have a very complex community based app with a lot of features, crossing fingers everything works as expected.

hirbod commented 9 years ago

What about plugin compatibility? Do 3rd party plugins work well with crosswalk? Are there any caveats?

JcDenton86 commented 9 years ago

That's the list of the plugins I am using right now.. All working as expected. (now Google maps too)

com.brodysoft.sqlitePlugin 1.0.3 "Brodysoft SQLitePlugin" com.google.playservices 22.0.0 "Google Play Services for Android" nl.x-services.plugins.actionsheet 1.1.2 "ActionSheet" nl.x-services.plugins.socialsharing 4.3.13 "SocialSharing" nl.x-services.plugins.toast 2.0.2 "Toast" org.apache.cordova.device 0.2.13 "Device" org.apache.cordova.dialogs 0.2.11 "Notification" org.apache.cordova.file 1.3.2 "File" org.apache.cordova.file-transfer 0.4.8 "File Transfer" org.apache.cordova.geolocation 0.3.11 "Geolocation" org.apache.cordova.globalization 0.3.3 "Globalization" org.apache.cordova.network-information 0.2.14 "Network Information" org.apache.cordova.splashscreen 0.3.5 "Splashscreen" plugin.google.maps 1.2.4 "phonegap-googlemaps-plugin" plugin.http.request 1.0.0 "phonegap-http-request"

hirbod commented 9 years ago

Ok, I have similar ones. I'm just crossing fingers with https://github.com/ccsoft/cordova-facebook

Btw, you should update PlayServices to v23, as the #test branch should not work with 22

JcDenton86 commented 9 years ago

I uninstalled and re-installed the test branch earlier because I set up the project from the beginning to migrate to crosswalk and it's working as is right now.. I' ll check it though ..

hirbod commented 9 years ago

This if OT now, but you need to remove v22 manually and apply it again.

hirbod commented 9 years ago

If I build with target 19, I get:

     [aapt] Generating resource IDs...
     [aapt] /Users/Hirbod/Desktop/appdev/Nachbarschaft_NEW/platforms/android/CordovaLib/xwalk_core_library/res/layout/date_time_picker_dialog.xml:20: error: No resource identifier found for attribute 'datePickerMode' in package 'android'
     [aapt] 
     [aapt] /Users/Hirbod/Desktop/appdev/Nachbarschaft_NEW/platforms/android/CordovaLib/xwalk_core_library/res/layout/date_time_picker_dialog.xml:31: error: No resource identifier found for attribute 'timePickerMode' in package 'android'
     [aapt] 
     [aapt] /Users/Hirbod/Desktop/appdev/Nachbarschaft_NEW/platforms/android/CordovaLib/xwalk_core_library/res/layout-land/date_time_picker_dialog.xml:20: error: No resource identifier found for attribute 'datePickerMode' in package 'android'
     [aapt] 
     [aapt] /Users/Hirbod/Desktop/appdev/Nachbarschaft_NEW/platforms/android/CordovaLib/xwalk_core_library/res/layout-land/date_time_picker_dialog.xml:31: error: No resource identifier found for attribute 'timePickerMode' in package 'android'

and If I set level 21 (as described in the migrate docs), I get hundreds of other errors.

JcDenton86 commented 9 years ago

Building with target-19 had the same errors and to pass them, I commented out the lines that caused these errors in the corresponding XML files and then it built successfully. Using target-21 built with no errors. Are the errors coming from plugin/cordova files? Try to delete ant-build and ant-gen directories from your project. Also make sure that you are inside CordovaLib directory while you run the commands in the migrate docs.

hirbod commented 9 years ago

I was inside of cd platforms/android/ as described in the docs

I get cordova errors on 21

hirbod commented 9 years ago

I guess I fail here

Build the projects in this order:

    xwalk_core_library
    CordovaLib
    kitchensink

The sequence of commands you need is as follows (from the top-level project directory):

What do they mean exactly?

hirbod commented 9 years ago

I guess I'm close to get it, but know the splashscreen plugin makes problems and also this one here:

MainActivity is not abstract and does not override abstract method onXWalkReady() in XWalkActivity
JcDenton86 commented 9 years ago

Your source file is inside the platforms/android/src/your/package/name/YourClass.java

hirbod commented 9 years ago

I got it, thanks, but it looks totally different. seems like it did not get updated

/*
       Licensed to the Apache Software Foundation (ASF) under one
       or more contributor license agreements.  See the NOTICE file
       distributed with this work for additional information
       regarding copyright ownership.  The ASF licenses this file
       to you under the Apache License, Version 2.0 (the
       "License"); you may not use this file except in compliance
       with the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

       Unless required by applicable law or agreed to in writing,
       software distributed under the License is distributed on an
       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
       KIND, either express or implied.  See the License for the
       specific language governing permissions and limitations
       under the License.
 */

package net.nachbarschaft;

import android.os.Bundle;
import org.apache.cordova.*;

public class MainActivity extends CordovaActivity
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        super.init();
        // Set by <content src="index.html" /> in config.xml
        loadUrl(launchUrl);
    }
}
hirbod commented 9 years ago

GOT IT! Thanks guys. It was really Step 6. The documentation is not clear enough. This were the steps:

1) Go into project 2) $ export ANDROID_HOME=$(dirname $(dirname $(which android))) 3) cd platforms/android/CordovaLib/xwalk_core_library/ 4) $ android update project --subprojects --path . --target "android-21" 5) ant debug 6) cd ../ 7) $ android update project --subprojects --path . --target "android-21" 8) ant debug 9) cd ../../.. 10) cordova build android

Now it works. Just need to apply the patches from wiki know, but build works without any error.

EDIT: I was too fast. Now I get this error:

    [javac] /Users/Hirbod/Desktop/appdev/Nachbarschaft/platforms/android/src/net/nachbarschaft/MainActivity.java:33: error: method does not override or implement a method from a supertype
    [javac]     @Override
    [javac]     ^
    [javac] /Users/Hirbod/Desktop/appdev/Nachbarschaft/platforms/android/src/net/nachbarschaft/MainActivity.java:35: error: cannot find symbol
    [javac]         XWalkPreferences.setValue(XWalkPreferences.ANIMATABLE_XWALK_VIEW, false);
    [javac]                                   ^
    [javac]   symbol:   variable XWalkPreferences
    [javac]   location: class MainActivity
    [javac] /Users/Hirbod/Desktop/appdev/Nachbarschaft/platforms/android/src/net/nachbarschaft/MainActivity.java:35: error: cannot find symbol
    [javac]         XWalkPreferences.setValue(XWalkPreferences.ANIMATABLE_XWALK_VIEW, false);
    [javac]         ^
    [javac]   symbol:   variable XWalkPreferences
    [javac]   location: class MainActivity
    [javac] /Users/Hirbod/Desktop/appdev/Nachbarschaft/platforms/android/src/net/nachbarschaft/MainActivity.java:39: error: cannot find symbol
    [javac]         this.appView.setZOrderOnTop(true);
    [javac]                     ^
    [javac]   symbol:   method setZOrderOnTop(boolean)
    [javac]   location: variable appView of type CordovaWebView
    [javac] 4 errors
    [javac] 3 warnings
hirbod commented 9 years ago

Got it.. My .java file had missing:

import org.xwalk.core.XWalkPreferences; Seems like migrating does not update the .java file properly. SplashScreen plugin is not working.

This is my file now:

package net.nachbarschaft;

import android.os.Bundle;
import org.apache.cordova.*;
import org.xwalk.core.XWalkPreferences;

public class MainActivity extends CordovaActivity
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void onXWalkReady() {
        XWalkPreferences.setValue(XWalkPreferences.ANIMATABLE_XWALK_VIEW, false);  // <!-- Add this line

        super.init();

        this.appView.setZOrderOnTop(true);  // <!-- Add this line

        // Set by <content src="index.html" /> in config.xml
        loadUrl(launchUrl);
    }
}

Could someone share his file please? Want to proof if I haven't miss any import-statement.

hirbod commented 9 years ago

It works PERFECTLY! I'm so happy. Thanks to all and Masashi :D .. But I had to implement x86 since I test on GenyMotion and Intel HAXM.

wf9a5m75 commented 9 years ago

You can download the files for X86 from here. https://download.01.org/crosswalk/releases/crosswalk/android/canary/14.42.329.0/x86/

hirbod commented 9 years ago

I know Masashi, I already did. Everything works perfectly, only SplashScreen plugin does not work, but it is not caused by your plugin

wf9a5m75 commented 9 years ago

It seems CrossWalk webView does not fire the onScrollChanged event when you scroll the web page. It means this plugin does not synchronize the position with the map div.

jianbo commented 9 years ago

Can someone help with this build error? Im using the test branch with my Ionic app

/home/L/Desktop/0/platforms/android/src/plugin/google/maps/MyPluginLayout.java:53: error: cannot find symbol this.root = (ViewGroup) webView.getParent(); ^ symbol: method getParent() location: variable webView of type CordovaWebView /home/L/Desktop/0/platforms/android/src/plugin/google/maps/MyPluginLayout.java:55: error: cannot find symbol webView.setBackgroundColor(Color.TRANSPARENT); ^ symbol: method setBackgroundColor(int) location: variable webView of type CordovaWebView /home/L/Desktop/0/platforms/android/src/plugin/google/maps/MyPluginLayout.java:57: error: cannot find symbol webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

TranceLove commented 9 years ago

@jianbo one possible reason is you target your app to Android SDK 19. Try target to SDK 21.

Check AndroidManifest.xml, project.properties. Also when integrating Crosswalk into your project, remember to say --target "android-21" when you do android update.

Good luck...

hirbod commented 9 years ago

@wf9a5m75 is onScrollChanged a JAVA event, or a JS event?

wf9a5m75 commented 9 years ago

Java

jianbo commented 9 years ago

@TranceLove I updated project with target=android-21 in project.properties and in my AndroidManifest.xml. still no luck.

TranceLove commented 9 years ago

@jianbo Hmm... next place to look for is cordova -v. Is it 4.3.0? Update it if not.

Note however, this will use cordova-android 3.7.1 instead of 3.6.4 as in previous cordova versions. Not affecting me as of now, but again, YMMV.

BTW, I think you will want to ask for further help in Ionic's forum instead of here...

jianbo commented 9 years ago

@TranceLove -desktop:~/Desktop/hey$ cordova -v 4.3.0 I start a fresh project and getting this when add platform

Failed to install 'org.apache.cordova.engine.crosswalk':CordovaError: Plugin doesn't support this project's cordova-android version. cordova-android: 3.7.1, failed version requirement: >=4.0.0-dev

Then I run 'cordova platform add android@4.0.0-dev' I get

Unable to fetch platform android@4.0.0-dev: Error: version not found: 4.0.0-dev : cordova-android/4.0.0-dev

wf9a5m75 commented 9 years ago

@jianbo I didn't test org.apache.cordova.engine.crosswalk at all. Follow this tutorial. https://github.com/wf9a5m75/phonegap-googlemaps-plugin/wiki/Tutorial-for-CrossWalk-(Android)

rolinger commented 9 years ago

Hi all, looking for help with my build errors. I posted the details here: https://github.com/wf9a5m75/phonegap-googlemaps-plugin/issues/518

As well, I am running Cordova version 5.0.0. Do I need to downgrade to 4.3.0?

hirbod commented 9 years ago

Yes, currently 5.0.0 isn't supported