EAS Build Android error

Hello,
I get an error when I want to build my android app wit EAS. I’ve looked online but no idea what it might be. Some directions or what it might be will be highly appriaciated.
The errors are 4. They appear during Run gradlew phase. On my package name it adds dot at the end. No idea why.

Thanks.

expo: 41, managed

> Task :app:compileReleaseJavaWithJavac FAILED
1076
[stderr] /build/workingdir/build/android/app/src/main/java/com/gosho/pesho/MainActivity.java:1: error: <identifier> expected
1077 
[stderr] package com.gosho.pesho.;
1078
[stderr]                                   ^
1079
[stderr] /build/workingdir/build/android/app/src/main/java/com/gosho/pesho/generated/BasePackageList.java:1: error: illegal '.'
1080
[stderr] package com.gosho.pesho..generated;
1081
[stderr]                                   ^
1082
[stderr] /build/workingdir/build/android/app/src/main/java/com/gosho/pesho/MainApplication.java:1: error: <identifier> expected
1083
[stderr] package com.gosho.pesho.;
1084
[stderr]                                   ^
1085
[stderr] /build/workingdir/build/android/app/src/main/java/com/gosho/pesho/MainApplication.java:14: error: illegal '.'
1086
[stderr] import com.gosho.pesho..generated.BasePackageList;
1087
[stderr]                                  ^
1088
[stderr] 4 errors
1089
[stderr] FAILURE: Build failed with an exception.
1090
[stderr] * What went wrong:
1091
[stderr] Execution failed for task ':app:compileReleaseJavaWithJavac'.

Hi @kaioian

What do you get if you run the following?

git grep 'com\.gosho\.pesho'

Hi @wodin
I get:

app.json:      "bundleIdentifier": "com.gosho.pesho",
app.json:      "package": "com.gosho.pesho",

If you create a new app, does that build successfully?

Created a blank project and tested with it. It worked fine.
Then I transferred all my files to the blank project, updated the packages. But the same problem.
Not sure what it might be. Any suggestions?

Do you have a managed workflow project? Do you have ios/ and android/ directories (or do you have them but they are gitignored?)?

Did you by any chance make any changes to the metro config or anything like that? Or any config plugins?

What are your dependencies?

@charliecruzan I’m using managed workflow. I don’t have ios/ and android/ directories.
@wodin Here are my dependencies:

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@expo/vector-icons": "^12.0.5",
    "@react-native-community/masked-view": "0.1.10",
    "@react-navigation/drawer": "^5.9.2",
    "@react-navigation/native": "^5.7.3",
    "@react-navigation/stack": "^5.9.0",
    "expo": "~42.0.1",
    "expo-ads-admob": "~10.1.2",
    "expo-asset": "~8.3.1",
    "expo-av": "~9.2.3",
    "expo-constants": "~11.0.1",
    "expo-font": "~9.2.1",
    "expo-haptics": "~10.1.0",
    "expo-keep-awake": "~9.2.0",
    "expo-linking": "~2.3.1",
    "expo-splash-screen": "~0.11.2",
    "expo-status-bar": "~1.0.4",
    "firebase": "8.2.3",
    "formik": "2.1.4",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz",
    "react-native-app-intro-slider": "^4.0.4",
    "react-native-draw-on-screen": "^1.0.15",
    "react-native-gesture-handler": "~1.10.2",
    "react-native-reanimated": "~2.2.0",
    "react-native-safe-area-context": "3.2.0",
    "react-native-screens": "~3.4.0",
    "react-native-svg": "12.1.1",
    "react-native-web": "~0.13.12",
    "yup": "0.27.0"
  },
  "devDependencies": {
    "@babel/core": "~7.9.0",
    "@types/react": "~16.9.35",
    "@types/react-dom": "~16.9.8",
    "@types/react-native": "~0.63.2",
    "jest-expo": "^41.0.0",
    "typescript": "~4.0.0"
  },
  "private": true
}

can you share a link to your build page please?

Sure, here it is:
https://expo.dev/accounts/kaioian/projects/uchismen/builds/244b530e-2bc7-452f-bcfc-03a044689e8a

The classic build works fine, but my app is for age under 5 and google play has rejected it because of the Facebook ad in the SDK, so I wanted to test with EAS.

it looks like this is caused by the app name, see app name limitation · Issue #458 · expo/eas-cli · GitHub

@notbrent A big thanks, I think this was the problem. Changed the name to English and it worked. But the solution is for iOS is there such option for Android when I want to use non-english name?

Any ideas?

I’ve just had a look through the Android build process docs. I think that step 7 from the Remote Steps points to a way to work around this problem.

I think if you use a latin-alphabet name in app.json and then use eas-build-post-install to replace the app name in the android directory with the real app name, that might work.

This is just off the top of my head. It is not the proper solution and I haven’t had a look at any of the Expo code to see what the proper solution might look like.

I’ve just run expo prebuild in a test project and I find the app name in the following files after that. (Note: if you do this it will make a bunch of changes to your project, but you can roll back using git. If you’re unsure of how to do this you could test it in a new app):

android/app/src/main/res/values/strings.xml
android/settings.gradle

I suspect the settings.gradle one should be left alone and the strings.xml one is what you’re looking for.

I’ve just given the following a try and it seems to have worked!:

diff --git package.json package.json
index 283acfc..5589dc0 100644
--- package.json
+++ package.json
@@ -5,7 +5,8 @@
     "android": "expo start --android",
     "ios": "expo start --ios",
     "web": "expo start --web",
-    "eject": "expo eject"
+    "eject": "expo eject",
+    "eas-build-post-install": "sed -i.bak 's/zip-test/拉開拉鏈/' android/app/src/main/res/values/strings.xml && rm -f android/app/src/main/res/values/strings.xml.bak"
   },
   "dependencies": {
     "expo": "~42.0.1",

App icon and name

After doing the above I searched for strings.xml in the Config Plugin docs and found the Default mods section. I think using mods.android.strings for this would be better than using the eas-build-post-install hook, but off hand I don’t know how to use mods.android.strings.

The following should probably lead to another option: Localize your app  |  Android Developers

@wodin Thanks, I will check this when I have more time.

:+1:

If you want something quick’n’dirty, I think eas-build-post-install will work for you.

And is there a better approach? Or a documentation I can check? Or this should be added to eas?
Thanks.

Yes, using the withStringsXml config plugin would be better. I’m not sure exactly how to use it, though. Perhaps one of the Expo team members could give us an example. @notbrent?

EDIT: Here’s an example of how to write something similar to the above.

Something based on the Android localization docs (probably together with a config plugin) would probably be even better.

Otherwise, you’ll need to wait until they can fix this issue in the expo prebuild code.

I see that a pull request to fix this has been merged into expo-cli. So I expect the fix will be in the next release.

https://github.com/expo/expo-cli/pull/3758

Great, thanks for the help @wodin and @notbrent

1 Like