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

[Android] Split code into two stores #1336

Merged
merged 10 commits into from
Jun 9, 2021

Conversation

andresesfm
Copy link
Collaborator

@andresesfm andresesfm commented May 13, 2021

Creates two variants: play and amazon and only uses the required code.

NOTE: This would be a breaking change with a very simple fix described in the documentation. To add: missingDimensionStrategy 'store', 'play' in build.gradle

@andresesfm andresesfm changed the title split code into two stores [Android] Split code into two stores May 13, 2021
@andresesfm andresesfm changed the title [Android] Split code into two stores [Android] Split code into two stores (WIP) May 14, 2021
@andresesfm andresesfm added ⓐ amazon 🤖 android Related to android 🏃🏻‍♀️ in progress Currently working on labels May 14, 2021
src/iap.ts Show resolved Hide resolved
*.js.flow
*.d.ts
*.js
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes it difficult to search inside IapExample folder since vscode ignores all the js.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then how about

*.js
!IamExample

And actually, this example project is not currently maintained.

The latest version I am maintaining is here. Well but hopefully the example project still works.

IapExample/App.js Show resolved Hide resolved
IapExample/App.js Show resolved Hide resolved
IapExample/android/app/build.gradle Show resolved Hide resolved
android/build.gradle Show resolved Hide resolved
src/iap.ts Show resolved Hide resolved
src/iap.ts Show resolved Hide resolved
@andresesfm andresesfm requested a review from hyochan June 2, 2021 16:51
@andresesfm andresesfm removed the 🏃🏻‍♀️ in progress Currently working on label Jun 2, 2021
Copy link
Member

@hyochan hyochan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for real hard work @andresesfm. You've rocked the Amazon iap.

I've just given small reviews and would like to test my previous android app if things aren't breaking after changes.

Also, since this is pretty much a heavy update, I would prefer you to update the version to 6.1.0 instead of 6.0.10.

Lastly, may I add you to a core-conributor to react-native-iap. We desperately need a person like you here.

*.js.flow
*.d.ts
*.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then how about

*.js
!IamExample

And actually, this example project is not currently maintained.

The latest version I am maintaining is here. Well but hopefully the example project still works.

@@ -180,7 +191,8 @@ android {

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.facebook.react:react-native:+"
implementation project(path: ':react-native-iap')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this is new to me! I've always digged in node_modules and sometimes forgot to copy and paste the original work 😅

Thanks for sharing.

IapExample/android/settings.gradle Show resolved Hide resolved
@@ -13,7 +13,7 @@
"apsl-react-native-button": "^3.1.1",
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-iap": "^6.0.6",
"react-native-iap": "file:..",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be file:../? I am afraid if there is any ad-hoc problem.

android/build.gradle Show resolved Hide resolved
package.json Show resolved Hide resolved
src/iap.ts Outdated
@@ -131,7 +131,7 @@ export const endConnection = (): Promise<void> =>
const myRNIapModule = getAndroidModule();

if (!RNIapModule || !RNIapAmazonModule) {
console.warn('Native android module does not exist');
console.info('Native android module does not exist, while ending connection');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What actually does it mean while ending connection?

src/iap.ts Outdated
@@ -269,12 +269,14 @@ export const getProducts = <SkuType extends string>(
const myRNIapModule = getAndroidModule();

await checkNativeAndroidAvailable(myRNIapModule);

console.log("skus",skus);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to remove this

src/iap.ts Outdated
const products = await myRNIapModule.getItemsByType(
ANDROID_ITEM_TYPE_IAP,
skus,
);

console.log("products",products);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. I think we need to remove this

src/iap.ts Outdated
Comment on lines 536 to 537
console.warn("purchase",purchase);
console.warn('isConsumable',isConsumable);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@hyochan hyochan changed the title [Android] Split code into two stores (WIP) [Android] Split code into two stores Jun 6, 2021
@hyochan hyochan added 🍗 enhancement New feature or request 🛠 bugfix All kinds of bug fixes labels Jun 6, 2021
Copy link
Member

@hyochan hyochan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andresesfm Hi. I think you're done with the review fixes and I've just tried installing this new version in dooboolab.com pull request by yarn add react-native-iap@next which is currently version 6.1.0. However, I am facing the below build error. Could you kindly look into this and see what should be done to solve the build problem?

I am afraid if we are missing additional context for the previous user. The above project was using 6.0.3 which did not have a build problem.

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:mergeDebugAssets'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve project :react-native-iap.
     Required by:
         project :app
      > The consumer was configured to find a runtime of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug'. However we cannot choose between the following variants of project :react-native-iap:
          - amazonDebugRuntimeElements
          - playDebugRuntimeElements
        All of them match the consumer attributes:
          - Variant 'amazonDebugRuntimeElements' capability dooboolab:react-native-iap:unspecified declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
              - Unmatched attributes:
                  - Provides attribute 'com.android.build.api.attributes.VariantAttr' with value 'amazonDebug' but the consumer didn't ask for it
                  - Provides attribute 'store' with value 'amazon' but the consumer didn't ask for it
          - Variant 'playDebugRuntimeElements' capability dooboolab:react-native-iap:unspecified declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
              - Unmatched attributes:
                  - Provides attribute 'com.android.build.api.attributes.VariantAttr' with value 'playDebug' but the consumer didn't ask for it
                  - Provides attribute 'store' with value 'play' but the consumer didn't ask for it
        The following variants were also considered but didn't match the requested attributes:
          - Variant 'amazonDebugApiElements' capability dooboolab:react-native-iap:unspecified declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
              - Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
          - Variant 'amazonReleaseApiElements' capability dooboolab:react-native-iap:unspecified:
              - Incompatible because this component declares an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' and the consumer needed a runtime of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug'
          - Variant 'amazonReleaseRuntimeElements' capability dooboolab:react-native-iap:unspecified declares a runtime of a component:
              - Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug'
          - Variant 'playDebugApiElements' capability dooboolab:react-native-iap:unspecified declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
              - Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
          - Variant 'playReleaseApiElements' capability dooboolab:react-native-iap:unspecified:
              - Incompatible because this component declares an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' and the consumer needed a runtime of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug'
          - Variant 'playReleaseRuntimeElements' capability dooboolab:react-native-iap:unspecified declares a runtime of a component:
              - Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug'

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

* Get more help at https://help.gradle.org

BUILD FAILED in 24s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

Copy link
Member

@hyochan hyochan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just find out the solution in the README.md.

missingDimensionStrategy 'store', 'play'

Thanks a lot for your contribution 🙏
I also like to reward you for this PR.

Could you submit expense in react-native-iap opencollective? I want to reward you with $50. know it isn't much but I want to thank you for helping react-native-iap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ⓐ amazon 🤖 android Related to android 🛠 bugfix All kinds of bug fixes 🍗 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants