Build error when plug-in cordova-plugin-Googlemaps and cordova-plugin-admobpro

Asked 2 years ago, Updated 2 years ago, 94 views

I am currently studying Android apps at cordova.
I am creating a map application using cordova-plugin-googlemaps.
When I put cordova-plugin-admobpro in order to display the advertisement,
The following error will occur and will not be able to build.

Error:cmd:Command failed with exit code1Error output:

C:\Users\name\app\platforms\android\src\plugin\Google\maps\PluginUtil.java:135: 
*G***[:AbstractSafeParcelable*AA*N*Z*X***** 
     Builder builder=LatLngBounds.builder();
                                  ^
com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable**N***X*E*t*@*C*******


FAILURE—Build failed with an exception.

* What was wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
>Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace.Run with --info --debug
option to get more log output.

By the way, the error is
cordova-plugin-Googlemaps and cordova-plugin-admobpro
If you only put them both in, but only one, you can build them properly.

I thought about it in my own way as an amateur, but maybe
Builder builder=LatLngBounds.builder();
I think this is the cause...
In that case, what should I do with this?
Is there any other reason?

If anyone understands, please do so.
Please teach me m(__)m

so that even beginners can understand.

android cordova

2022-09-30 17:52

1 Answers

Home StackOverflow had a similar question.

/platforms/android/project.properties can be rewritten as follows:
When I tried it in this environment, the build error no longer occurred.

·Change the 9.8.0 designation to +

#cordova.system.library.4=com.google.android.gms:play-services-maps:9.8.0
# cordova.system.library.5 = com.google.android.gms:play-services-location:9.8.0
cordova.system.library.4 = com.google.android.gms:play-services-maps:+
cordova.system.library.5 = com.google.android.gms:play-services-location:+

To explain why the error is occurring, cordova-plugin-googlemaps has play-services-maps and play-services-location libraries that depend on fixed versions of 9.8.0.
On the other hand, cordova-plugin-admobpro does not specify a version for libraries that depend on com.google.android.gms:play-services-ads:+.
Due to differences in versions of these libraries, some classes in the library may or may not be implemented, and the following classes may not be found:

 class file for com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable not found

However, this solution is also an aggressive method.
The cordova-plugin-googlemaps plug-in specifies the library version to which it depends as 9.8.0.
This is because we know that 9.8.0 will work fine to some extent, but we don't know if it will work in a later version.
Therefore, if you use this solution, the API for cordova-plugin-googlemaps where you removed the version specification may not work properly.
(It may work fine, so if there is no problem after using it, you can leave it as it is.)
Also, this problem is expected to be fixed by the plug-in side in due course.

Additional information

It may sound personal, but you should avoid manually modifying /platforms/android/project.properties.
This is because /platforms/under control is managed by cordova and files are automatically generated/modified/deleted at various times.
In this example, /platforms/android/project.properties was automatically changed when the cordova-plugin-googlemaps plugin was installed.

So to change and apply the library version of the plug-in

Fix the problem
In this case: Fix cordova-plugin-googlemaps/plugin.xml

<!--<framework src="com.google.android.gms:play-services-maps:9.8.0"/>-->
<!--<framework src="com.google.android.gms:play-services-location:9.8.0"/>-->
<framework src="com.google.android.gms:play-services-maps:+"/>
<framework src="com.google.android.gms:play-services-location:+"/>

Apply forked repository plug-in

cordova plugin install https://github.com/fork-my-plugin/cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="YOUR_ANDROID_API_KEY_IS_HERE" --variable API_KEY_FOR_IOS="YOUR_IOS_API_KEY_IS_HERE"

It would be better to apply it as shown in .
As for 1. I think it is possible to drop it locally with clone and correct it.
In that case, you may need to think a little bit about how to manage the source.


2022-09-30 17:52

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.