Skip to content

Commit

Permalink
Add basic shims for Android plugin 2.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
CFKevinRef committed Jul 26, 2018
1 parent 7182170 commit 0d43751
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions react.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,19 @@ afterEvaluate {
currentBundleTask.ext.generatedResFolders = files(resourcesDir).builtBy(currentBundleTask)
currentBundleTask.ext.generatedAssetsFolders = files(jsBundleDir).builtBy(currentBundleTask)

variant.registerGeneratedResFolders(currentBundleTask.generatedResFolders)
// registerGeneratedResFolders for Android plugin 3.x
if (variant.respondsTo("registerGeneratedResFolders")) {
variant.registerGeneratedResFolders(currentBundleTask.generatedResFolders)
} else {
variant.registerResGeneratingTask(currentBundleTask)
}
variant.mergeResources.dependsOn(currentBundleTask)

// packageApplication for Android plugin 3.x
def packageTask = variant.hasProperty("packageApplication")
? variant.packageApplication
: tasks.findByName("package${targetName}")

def resourcesDirConfigValue = config."resourcesDir${targetName}"
if (resourcesDirConfigValue) {
def currentCopyResTask = tasks.create(
Expand All @@ -98,7 +108,7 @@ afterEvaluate {
enabled currentBundleTask.enabled
}

variant.packageApplication.dependsOn(currentCopyResTask)
packageTask.dependsOn(currentCopyResTask)
}

def currentAssetsCopyTask = tasks.create(
Expand All @@ -117,6 +127,6 @@ afterEvaluate {
enabled currentBundleTask.enabled
}

variant.packageApplication.dependsOn(currentAssetsCopyTask)
packageTask.dependsOn(currentAssetsCopyTask)
}
}

6 comments on commit 0d43751

@sashaba
Copy link

Choose a reason for hiding this comment

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

I modified my react.gradle with this code and still can't build APK, i got duplicate file error
(all images inside this folder) android/app/src/main/res/drawable-mdpi/ and
(all images inside this folder) /android/app/build/generated/res/react/release/drawable-mdpi/
somebody please help me.

@sashaba
Copy link

Choose a reason for hiding this comment

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

so, after uninstalling Code push i was able to build the APK.
Thank you.

@CFKevinRef
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sashaba that makes sense, I have local modifications to Code Push to make it work for me too. Assuming this gets traction I'll submit a PR to that project as well. Thanks for testing!

@sashaba
Copy link

Choose a reason for hiding this comment

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

@CFKevinRef that PR would be great, hope you make it. If you don’t mind, may I ask you which file of code push did you modify?
Thanks.

@CFKevinRef
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I would think that this merged PR should take care of things: microsoft/react-native-code-push#1219

What version of CodePush and the Android Gradle Plugin are you using?

@sashaba
Copy link

Choose a reason for hiding this comment

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

Code push 5.4.0 and gradle 3.1.3, i'm going to try #1219.
Thank you.

Please sign in to comment.