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

Add v2 Support for Android Plugin Architecture #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ You can find the docs for this first-party plugin in the [official Godot docs](h

Prerequisites:

- Android SDK (platform version 30)
- Android SDK (platform version 33)
- the Godot Android library (`godot-lib.***.release.aar`) for your version of Godot from the [downloads page](https://godotengine.org/download).

Steps to build:
Expand All @@ -21,3 +21,10 @@ Steps to build:
3. Run `./gradlew build` in the cloned repository

If the build succeeds, you can find the resulting `.aar` files in `./godot-google-play-billing/build/outputs/aar/`.

## Installing
- This now uses v2 of the [Android Plugin](https://docs.godotengine.org/en/stable/tutorials/platform/android/android_plugin.html) architecture. (Compatible with Godot 4.2+)
- Choose your preferred language and place the directory `google_play_billing` which is inside of `editor_export_plugin` into the `addons` folder of your Godot project.
- Take the compiled `.aar` files from the plugin and place them in the `libs` folder.
- Enable the plugin from the dedicated project settings tab. (For C# users, press the build button first)
- Make sure to enable Android Gradle builds when exporting.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
classpath "com.android.tools.build:gradle:7.4.1"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#region Copyright
/*************************************************************************/
/* GooglePlayBillingConfig.cs */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#endregion

#if TOOLS

using System;
using Godot;

namespace GooglePlayBilling;

[Tool]
public partial class GooglePlayBillingConfig : EditorExportPlugin
{
private const string PLUGIN_NAME = "GodotGooglePlayBilling";

// Dependency paths relative to the project's addons folder.
private const string LIB_PATH_RELEASE = "google_play_billing/libs/GodotGooglePlayBilling.1.2.0.release.aar";
private const string LIB_PATH_DEBUG = "google_play_billing/libs/GodotGooglePlayBilling.1.2.0.debug.aar";
private const string BILLING_DEPENDENCY = "com.android.billingclient:billing:5.2.1";


public override bool _SupportsPlatform(EditorExportPlatform platform)
{
if (platform is EditorExportPlatformAndroid)
{
return true;
}
else
{
return false;
}
}
public override string[] _GetAndroidLibraries(EditorExportPlatform platform, bool debug)
{
if (debug)
{
return new string[] { LIB_PATH_DEBUG };
}
else
{
return new string[] { LIB_PATH_RELEASE };
}
}
public override string[] _GetAndroidDependencies(EditorExportPlatform platform, bool debug)
{
return new string[] { BILLING_DEPENDENCY };
}
public override string _GetName()
{
return PLUGIN_NAME;
}
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#region Copyright
/*************************************************************************/
/* GooglePlayBillingEditorPlugin.cs */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#endregion

#if TOOLS

using System;
using Godot;

namespace GooglePlayBilling;

[Tool]
public partial class GooglePlayBillingEditorPlugin : EditorPlugin
{
private GooglePlayBillingConfig playBillingConfig;

public override void _EnterTree()
{
playBillingConfig = new();
AddExportPlugin(playBillingConfig);
}
public override void _ExitTree()
{
RemoveExportPlugin(playBillingConfig);
playBillingConfig = null;
}
}

#endif
7 changes: 7 additions & 0 deletions editor_export_plugin/csharp/google_play_billing/plugin.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[plugin]

name="Google Play Billing Plugin"
description="Implements purchasing API for Android."
author="Godot Engine"
version="1.0"
script="GooglePlayBillingEditorPlugin.cs"
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#************************************************************************/
# GooglePlayBillingEditorPlugin.gd */
#************************************************************************/
# This file is part of: */
# GODOT ENGINE */
# https://godotengine.org */
#************************************************************************/
# Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
# Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
# */
# Permission is hereby granted, free of charge, to any person obtaining */
# a copy of this software and associated documentation files (the */
# "Software"), to deal in the Software without restriction, including */
# without limitation the rights to use, copy, modify, merge, publish, */
# distribute, sublicense, and/or sell copies of the Software, and to */
# permit persons to whom the Software is furnished to do so, subject to */
# the following conditions: */
# */
# The above copyright notice and this permission notice shall be */
# included in all copies or substantial portions of the Software. */
# */
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#************************************************************************/

@tool
extends EditorExportPlugin

var _plugin_name = "GodotGooglePlayBilling"

# Dependency paths relative to the project's addons folder.
var _lib_path_release = "google_play_billing/libs/GodotGooglePlayBilling.1.2.0.release.aar"
var _lib_path_debug = "google_play_billing/libs/GodotGooglePlayBilling.1.2.0.debug.aar"
var _billing_dependency = "com.android.billingclient:billing:5.2.1"

func _supports_platform(platform):
if (platform is EditorExportPlatformAndroid):
return true
else:
return false

func _get_android_libraries(platform, debug):
if (debug):
return PackedStringArray([_lib_path_debug])
else:
return PackedStringArray([_lib_path_release])

func _get_android_dependencies(platform, debug):
return PackedStringArray([_billing_dependency])

func _get_name():
return _plugin_name
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#************************************************************************/
# GooglePlayBillingEditorPlugin.gd */
#************************************************************************/
# This file is part of: */
# GODOT ENGINE */
# https://godotengine.org */
#************************************************************************/
# Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
# Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
# */
# Permission is hereby granted, free of charge, to any person obtaining */
# a copy of this software and associated documentation files (the */
# "Software"), to deal in the Software without restriction, including */
# without limitation the rights to use, copy, modify, merge, publish, */
# distribute, sublicense, and/or sell copies of the Software, and to */
# permit persons to whom the Software is furnished to do so, subject to */
# the following conditions: */
# */
# The above copyright notice and this permission notice shall be */
# included in all copies or substantial portions of the Software. */
# */
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#************************************************************************/

@tool
extends EditorPlugin

var play_billing_config : GooglePlayBillingConfig

func _enter_tree():
play_billing_config = AndroidExportPlugin.new()
add_export_plugin(play_billing_config)

func _exit_tree():
remove_export_plugin(play_billing_config)
play_billing_config = null
7 changes: 7 additions & 0 deletions editor_export_plugin/gdscript/google_play_billing/plugin.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[plugin]

name="Google Play Billing Plugin"
description="Implements purchasing API for Android."
author="Godot Engine"
version="1.0"
script="GooglePlayBillingEditorPlugin.gd"
6 changes: 3 additions & 3 deletions godot-google-play-billing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ ext.pluginVersionCode = 5
ext.pluginVersionName = "1.2.0"

android {
compileSdkVersion 31
compileSdk 33
buildToolsVersion "30.0.3"

defaultConfig {
minSdkVersion 18
targetSdkVersion 31
minSdk 24
targetSdk 33
versionCode pluginVersionCode
versionName pluginVersionName
}
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion godot-google-play-billing/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<application>

<meta-data
android:name="org.godotengine.plugin.v1.GodotGooglePlayBilling"
android:name="org.godotengine.plugin.v2.GodotGooglePlayBilling"
android:value="org.godotengine.godot.plugin.googleplaybilling.GodotGooglePlayBilling" />

</application>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*************************************************************************/
/* GodotGooglePlayBilling.java */
/* GodotGooglePlayBilling.java */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*************************************************************************/
/* GooglePlayBillingUtils.java */
/* GooglePlayBillingUtils.java */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Jun 15 13:39:16 CEST 2020
#Mon Apr 29 14:02:56 EDT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip