Hi,
I’m trying to do a custom build with eas to integrate HMS Core (Huawei dev kit)
So i need to add a maven repo to build.gradle
To do this, i created a plugin with withProjectBuildGradle from @expo /config-plugins, but not sure how it works exactly.
My plugin:
const { withProjectBuildGradle } = require("@expo/config-plugins")
module.exports = function CustomGradlePlugin(config) {
return withProjectBuildGradle(config, async config => {
let buildscriptRepos = config.modResults.buildscript.repositories
buildscriptRepos.$ = {
...buildscriptRepos.$,
"maven": "{url 'https://developer.huawei.com/repo/'}",
}
let allProjsRepos = config.modResults.allprojects.repositories
allProjsRepos.$ = {
...allProjsRepos.$,
"maven": "{url 'https://developer.huawei.com/repo/'}",
}
return config
})
}
Response from eas build:configure
PluginError: Plugin is an unexpected type: undefined
Code: INVALID_PLUGIN_TYPE
I can’t find doc about that, is there a obscure place where i can find that ?
[UPDATE]
I’ve found that here
config.modResults.contents = replace(
config.modResults.contents,
"mavenLocal()",
`mavenLocal()
maven {
// Required for react-native-background-geolocation
url("\${project(":react-native-background-geolocation").projectDir}/libs")
}
maven {
// Required for react-native-background-fetch
url("$\{project(":react-native-background-fetch").projectDir}/libs")
}`
)
Looks good but i still have unexpected type: undefined
message
[UPDATE]
My build succeeded with these 2 plugins
Modify gradle config
const { withProjectBuildGradle } = require("@expo/config-plugins")
module.exports = function customGradlePlugin(config) {
return withProjectBuildGradle(config, async config => {
config.modResults.contents = config.modResults.contents.replaceAll(
"mavenCentral()",
`mavenCentral()
maven {
url 'https://developer.huawei.com/repo/'
}`
)
return config
})
}
Add huawei commondata permission
const { withAndroidManifest } = require("@expo/config-plugins")
module.exports = function androiManifestPlugin(config) {
return withAndroidManifest(config, async config => {
let androidManifest = config.modResults.manifest
// add the tools to apply permissions
androidManifest.$ = {
...androidManifest.$,
"xmlns:tools": "http://schemas.android.com/tools",
}
androidManifest["uses-permission"].push({
$: {
"android:name": "com.huawei.appmarket.service.commondata.permission.GET_COMMON_DATA"
}
})
return config
})
}
Then don’t forget to reference your plugins in your app.config.js or app.json
"plugins": [
"./android-custom-permissions-plugin",
"./custom-gradle-plugin",
...
Finaly, run an eas build
I’m waiting for Huawei Developer Program review to test hms-map, but i think i’m good.
Okay, i finaly succeed but that was not easy, mostly because of the lack of documentation on expo plugins
I wrote a tutorial to explain if anyone is interested
1 Like
system
Closed
July 3, 2022, 4:23pm
5
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.