From e253e1b47b032d23413c93f4599a802ad12b9ea1 Mon Sep 17 00:00:00 2001 From: hermanto <55172860+slabgames@users.noreply.github.com> Date: Sat, 19 Jun 2021 15:03:50 +0800 Subject: [PATCH 1/2] updating firebase and billing version --- .../android/PROJ-gradle/app/build.gradle | 35 ++++++++++++++++--- .../app/src/main/AndroidManifest.xml | 6 ++-- templates/android/PROJ-gradle/build.gradle | 8 ++--- .../android/PROJ-gradle/gradle.properties | 1 + .../java/org/haxe/nme/BillingManager.java | 23 +++++++----- 5 files changed, 54 insertions(+), 19 deletions(-) diff --git a/templates/android/PROJ-gradle/app/build.gradle b/templates/android/PROJ-gradle/app/build.gradle index fd23012a7..88f53f78a 100644 --- a/templates/android/PROJ-gradle/app/build.gradle +++ b/templates/android/PROJ-gradle/app/build.gradle @@ -29,6 +29,11 @@ android { testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } + compileOptions { + sourceCompatibility 1.8 + targetCompatibility 1.8 + } + ::if KEY_STORE:: signingConfigs { release { @@ -93,7 +98,8 @@ dependencies { }) // Support is in 'androidx.core' now ::if ANDROID_BILLING:: - api 'com.android.billingclient:billing:2.1.0' + // api 'com.android.billingclient:billing:2.1.0' + api "com.android.billingclient:billing:4.0.0" ::end:: testImplementation 'junit:junit:4.12' @@ -103,15 +109,36 @@ dependencies { ::if NME_FIREBASE:: // Add the dependency for the Performance Monitoring library - implementation 'com.google.firebase:firebase-analytics:17.2.2' + implementation platform('com.google.firebase:firebase-bom') + implementation 'com.google.firebase:firebase-analytics' ::if NME_FIREBASE_PERFORMANCE:: - implementation 'com.google.firebase:firebase-perf:19.0.7' + implementation 'com.google.firebase:firebase-perf' ::end:: ::if NME_FIREBASE_CRASHLYTICS:: - implementation 'com.google.firebase:firebase-crashlytics-ndk:17.1.0' + implementation 'com.google.firebase:firebase-crashlytics-ndk' ::end:: + + implementation 'com.google.android.gms:play-services-ads:20.2.0' + //implementation 'com.google.firebase:firebase-inappmessaging' + //implementation 'com.google.firebase:firebase-inappmessaging-display' + //implementation 'com.google.firebase:firebase-messaging' + implementation 'com.google.firebase:firebase-iid' + // implementation 'com.google.firebase:firebase-messaging:17.3.4' + // implementation 'com.google.firebase:firebase-core:16.0.4' + //implementation 'com.google.firebase:firebase-config' + implementation 'com.google.firebase:firebase-crashlytics' + implementation 'com.google.firebase:firebase-analytics' + //implementation 'com.google.firebase:firebase-config:18.0.0' + //implementation 'com.google.firebase:firebase-iid:19.0.1' + // implementation 'com.google.firebase:firebase-messaging:20.0.1' + // implementation 'com.android.support:support-annotations:28.0.0' + // implementation 'com.google.firebase:firebase-core:17.0.0' + //implementation 'com.google.firebase:firebase-crash:16.2.1' + //implementation 'com.google.firebase:firebase-analytics:17.0.0' + implementation 'com.google.code.gson:gson:2.8.7' + implementation "androidx.work:work-runtime:2.5.0" ::end:: dependencies { diff --git a/templates/android/PROJ-gradle/app/src/main/AndroidManifest.xml b/templates/android/PROJ-gradle/app/src/main/AndroidManifest.xml index c92343070..ce8843a2f 100644 --- a/templates/android/PROJ-gradle/app/src/main/AndroidManifest.xml +++ b/templates/android/PROJ-gradle/app/src/main/AndroidManifest.xml @@ -45,9 +45,9 @@ - - + + ::foreach appPermission:: ::end:: diff --git a/templates/android/PROJ-gradle/build.gradle b/templates/android/PROJ-gradle/build.gradle index 6443612f9..e5d5bda0d 100644 --- a/templates/android/PROJ-gradle/build.gradle +++ b/templates/android/PROJ-gradle/build.gradle @@ -6,20 +6,20 @@ buildscript { google() } dependencies { - classpath "com.android.tools.build:gradle:3.4.0" + classpath "com.android.tools.build:gradle:3.6.4" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files ::if NME_FIREBASE:: - classpath 'com.google.gms:google-services:4.3.3' + classpath 'com.google.gms:google-services:4.3.8' ::if NME_FIREBASE_PERFORMANCE:: // Add the dependency for the Performance Monitoring plugin - classpath 'com.google.firebase:perf-plugin:1.3.1' // Performance Monitoring plugin + classpath 'com.google.firebase:perf-plugin:1.4.0' // Performance Monitoring plugin ::end:: ::if NME_FIREBASE_CRASHLYTICS:: - classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0' + classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.0' ::end:: ::end:: } diff --git a/templates/android/PROJ-gradle/gradle.properties b/templates/android/PROJ-gradle/gradle.properties index f2852858f..75be0e140 100644 --- a/templates/android/PROJ-gradle/gradle.properties +++ b/templates/android/PROJ-gradle/gradle.properties @@ -15,3 +15,4 @@ # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true +android.useAndroidX=true \ No newline at end of file diff --git a/templates/android/java/org/haxe/nme/BillingManager.java b/templates/android/java/org/haxe/nme/BillingManager.java index f5ede5d71..aad66dc94 100644 --- a/templates/android/java/org/haxe/nme/BillingManager.java +++ b/templates/android/java/org/haxe/nme/BillingManager.java @@ -51,7 +51,8 @@ import android.text.TextUtils; import android.util.Base64; -import com.android.billingclient.util.BillingHelper; +// import com.android.billingclient.util.BillingHelper; +import android.util.Log; import java.io.IOException; import java.security.InvalidKeyException; import java.security.KeyFactory; @@ -355,7 +356,7 @@ private void handlePurchase(Purchase purchase, JSONArray outList) throws JSONE boolean valid = verifyValidSignature(purchase.getOriginalJson(), purchase.getSignature()); JSONObject obj= new JSONObject(); - obj.put("sku", purchase.getSku() ); + obj.put("sku", purchase.getSkus().get(0) ); obj.put("valid", valid ); obj.put("purchaseToken", purchase.getPurchaseToken() ); obj.put("orderId", purchase.getOrderId() ); @@ -457,7 +458,8 @@ public static boolean verifyPurchaseInsecure(String base64PublicKey, String sign if (TextUtils.isEmpty(signedData) || TextUtils.isEmpty(base64PublicKey) || TextUtils.isEmpty(signature)) { - BillingHelper.logWarn(TAG, "Purchase verification failed: missing data."); + // BillingHelper.logWarn(TAG, "Purchase verification failed: missing data."); + Log.w(TAG,"Purchase verification failed: missing data."); return false; } @@ -482,7 +484,8 @@ public static PublicKey generatePublicKey(String encodedPublicKey) throws IOExce throw new RuntimeException(e); } catch (InvalidKeySpecException e) { String msg = "Invalid key specification: " + e; - BillingHelper.logWarn(TAG, msg); + // BillingHelper.logWarn(TAG, msg); + Log.w(TAG, msg); throw new IOException(msg); } } @@ -501,7 +504,8 @@ public static boolean verify(PublicKey publicKey, String signedData, String sign try { signatureBytes = Base64.decode(signature, Base64.DEFAULT); } catch (IllegalArgumentException e) { - BillingHelper.logWarn(TAG, "Base64 decoding failed."); + // BillingHelper.logWarn(TAG, "Base64 decoding failed."); + Log.w(TAG, "Base64 decoding failed."); return false; } try { @@ -509,7 +513,8 @@ public static boolean verify(PublicKey publicKey, String signedData, String sign signatureAlgorithm.initVerify(publicKey); signatureAlgorithm.update(signedData.getBytes()); if (!signatureAlgorithm.verify(signatureBytes)) { - BillingHelper.logWarn(TAG, "Signature verification failed."); + // BillingHelper.logWarn(TAG, "Signature verification failed."); + Log.w(TAG,"Signature verification failed."); return false; } return true; @@ -517,9 +522,11 @@ public static boolean verify(PublicKey publicKey, String signedData, String sign // "RSA" is guaranteed to be available. throw new RuntimeException(e); } catch (InvalidKeyException e) { - BillingHelper.logWarn(TAG, "Invalid key specification."); + // BillingHelper.logWarn(TAG, "Invalid key specification."); + Log.w(TAG,"Invalid key specification"); } catch (SignatureException e) { - BillingHelper.logWarn(TAG, "Signature exception."); + // BillingHelper.logWarn(TAG, "Signature exception."); + Log.w(TAG, "Signature exception"); } return false; } From 9575dd988fe0c21d64fec387e6dbad8528d011f2 Mon Sep 17 00:00:00 2001 From: hermanto <55172860+slabgames@users.noreply.github.com> Date: Tue, 29 Jun 2021 15:08:17 +0800 Subject: [PATCH 2/2] add null check on headerMap --- src/nme/net/HttpLoader.hx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/nme/net/HttpLoader.hx b/src/nme/net/HttpLoader.hx index 9d4b856ef..a033cb60a 100644 --- a/src/nme/net/HttpLoader.hx +++ b/src/nme/net/HttpLoader.hx @@ -204,6 +204,10 @@ class HttpLoader public function getHeaders() : Array { var headerMap = http.responseHeaders; + if (headerMap == null) { + onError("Header returns null"); + return [""]; + } return [ for(h in headerMap.keys()) h + ": " + headerMap.get(h) ]; }