Cannot build APK

Good night everyone, how are you?

I have a project (Managed) in Expo SDK43 where I can generate the binary for iOS and I can’t do it on Android anymore.

I tried it on the Expo service and there are also errors when I generate binary for Android.

Below are the logs on the Expo service:

Build 2fede57d

```
> Task :app:compressReleaseAssets
```

134

```
> Task :app:processReleaseResources
```

135

```
> Task :expo:compileReleaseKotlin
```

136

```
w: /app/turtle/workingdir/android/sdk43/packages/expo/android/src/main/java/expo/modules/ReactActivityDelegateWrapper.kt: (134, 38): Unchecked cast: Any! to T
```

137

```
w: /app/turtle/workingdir/android/sdk43/packages/expo/android/src/main/java/expo/modules/ReactActivityDelegateWrapper.kt: (148, 45): Unchecked cast: Any! to T
```

138

```
w: /app/turtle/workingdir/android/sdk43/packages/expo/android/src/main/java/expo/modules/ReactNativeHostWrapper.kt: (15, 37): 'UIImplementationProvider' is deprecated. Deprecated in Java
```

139

```
w: /app/turtle/workingdir/android/sdk43/packages/expo/android/src/main/java/expo/modules/ReactNativeHostWrapper.kt: (42, 47): 'UIImplementationProvider' is deprecated. Deprecated in Java
```

140

```
w: /app/turtle/workingdir/android/sdk43/packages/expo/android/src/main/java/expo/modules/ReactNativeHostWrapper.kt: (100, 34): Unchecked cast: Any! to T
```

141

```
> Task :expo:compileReleaseJavaWithJavac
```

142

```
> Task :expo:mergeReleaseGeneratedProguardFiles
```

143

```
> Task :expo:exportReleaseConsumerProguardFiles
```

144

```
> Task :expo:bundleLibCompileToJarRelease
```

145

```
> Task :expo:bundleLibResRelease
```

146

```
> Task :expo:bundleLibRuntimeToJarRelease
```

147

```
> Task :app:compileReleaseKotlin
```

148

```
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
```

149

```
    /root/.gradle/caches/transforms-3/6b1fe43bf07805782e2087b4ab0569c8/transformed/jetified-kotlin-stdlib-jdk8-1.5.20.jar (version 1.5)
```

150

```
    /root/.gradle/caches/transforms-3/f99a28ef2bf4c1e55f02d14aee52e153/transformed/jetified-kotlin-stdlib-jdk7-1.5.20.jar (version 1.5)
```

151

```
    /root/.gradle/caches/transforms-3/b1d5eaf82bcc414f60a23e6ce8ca9028/transformed/jetified-kotlin-stdlib-1.5.20.jar (version 1.5)
```

152

```
    /root/.gradle/caches/transforms-3/ae0443e6f0c1162fc1855786c76a6156/transformed/jetified-kotlin-reflect-1.4.21.jar (version 1.4)
```

153

```
    /root/.gradle/caches/transforms-3/f9ad13b52f5d4f35b801fd0228209942/transformed/jetified-kotlin-stdlib-common-1.5.20.jar (version 1.5)
```

154

```
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
```

155

```
> Task :app:compileReleaseJavaWithJavac
```

156

```
> Task :app:compileReleaseSources
```

157

```
> Task :app:lintVitalRelease
```

158[stderr]

```
Could not load custom lint check jar file /root/.gradle/caches/transforms-3/b7b081b0ef20f0808f147dd05f365c64/transformed/jetified-ui-graphics-1.0.0-rc02/jars/lint.jar
```

159[stderr]

```
java.lang.NoClassDefFoundError: com/android/tools/lint/client/api/Vendor
```

160[stderr]

```
	at androidx.compose.ui.graphics.lint.UiGraphicsIssueRegistry.<init>(UiGraphicsIssueRegistry.kt:34)
```

161[stderr]

```
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
```

162[stderr]

```
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
```

163[stderr]

```
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
```

164[stderr]

```
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
```

165[stderr]

```
	at java.lang.Class.newInstance(Class.java:442)
```

166[stderr]

```
	at com.android.tools.lint.client.api.JarFileIssueRegistry$Factory.loadIssueRegistry(JarFileIssueRegistry.kt:200)
```

167[stderr]

```
	at com.android.tools.lint.client.api.JarFileIssueRegistry$Factory.get(JarFileIssueRegistry.kt:152)
```

168[stderr]

```
	at com.android.tools.lint.client.api.JarFileIssueRegistry$Factory.get(JarFileIssueRegistry.kt:116)
```

169[stderr]

```
	at com.android.tools.lint.client.api.LintDriver.registerCustomDetectors(LintDriver.kt:494)
```
..... much lines!!!

```
	... 155 more
```

And I tried it on my machine too:

Dec 9 19:55:09 turtle[35094] INFO:  FAILURE: Build failed with an exception.
  platform: "android"
  buildPhase: "running gradle"
  source: "stderr"
Dec 9 19:55:09 turtle[35094] INFO:  * Where:
  platform: "android"
  buildPhase: "running gradle"
  source: "stderr"
Dec 9 19:55:09 turtle[35094] INFO:  Settings file '/home/caca/.turtle/workingdir/android/sdk43/android-shell-app/settings.gradle' line: 12
  platform: "android"
  buildPhase: "running gradle"
  source: "stderr"
Dec 9 19:55:09 turtle[35094] INFO:  * What went wrong:
  platform: "android"
  buildPhase: "running gradle"
  source: "stderr"
Dec 9 19:55:09 turtle[35094] INFO:  A problem occurred evaluating settings 'android-shell-app'.
  platform: "android"
  buildPhase: "running gradle"
  source: "stderr"
Dec 9 19:55:09 turtle[35094] INFO:  > String index out of range: 0
  platform: "android"
  buildPhase: "running gradle"
  source: "stderr"
Dec 9 19:55:09 turtle[35094] INFO:  * Try:
  platform: "android"
  buildPhase: "running gradle"
  source: "stderr"
Dec 9 19:55:09 turtle[35094] INFO:  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.
  platform: "android"
  buildPhase: "running gradle"
  source: "stderr"
Dec 9 19:55:09 turtle[35094] INFO:  * Get more help at https://help.gradle.org
  platform: "android"
  buildPhase: "running gradle"
  source: "stderr"
Dec 9 19:55:09 turtle[35094] INFO:  BUILD FAILED in 606ms
  platform: "android"
  buildPhase: "running gradle"
  source: "stderr"
Dec 9 19:55:09 turtle[35094] ERROR: Error: ./gradlew exited with non-zero code: 1
    at ChildProcess.completionListener (/home/caca/.nvm/versions/node/v14.18.2/lib/node_modules/turtle-cli/node_modules/@expo/spawn-async/src/spawnAsync.ts:65:13)
    at Object.onceWrapper (events.js:520:26)
    at ChildProcess.emit (events.js:400:28)
    at ChildProcess.emit (domain.js:475:12)
    at maybeClose (internal/child_process.js:1058:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
    ...
    at spawnAsync (/home/caca/.nvm/versions/node/v14.18.2/lib/node_modules/turtle-cli/node_modules/@expo/spawn-async/src/spawnAsync.ts:26:19)
    at spawnAsyncThrowError (/@expo/xdl@59.1.7/src/detach/ExponentTools.ts:111:19)
    at buildShellAppAsync (/@expo/xdl@59.1.7/src/detach/AndroidShellApp.js:1493:11)
    at Object.createAndroidShellAppAsync (/@expo/xdl@59.1.7/src/detach/AndroidShellApp.js:381:5)
    at runShellAppBuilder (/home/caca/.nvm/versions/node/v14.18.2/lib/node_modules/turtle-cli/src/builders/android.ts:91:5)
    at buildAndroid (/home/caca/.nvm/versions/node/v14.18.2/lib/node_modules/turtle-cli/src/builders/android.ts:23:26)
    at /home/caca/.nvm/versions/node/v14.18.2/lib/node_modules/turtle-cli/src/bin/utils/builder.ts:87:7
    at Command.<anonymous> (/home/caca/.nvm/versions/node/v14.18.2/lib/node_modules/turtle-cli/src/bin/index.ts:23:12)
  platform: "android"
Dec 9 19:55:09 turtle[35094] ERROR: Failed to build standalone app
  err: Error: ./gradlew exited with non-zero code: 1
      at ChildProcess.completionListener (/home/caca/.nvm/versions/node/v14.18.2/lib/node_modules/turtle-cli/node_modules/@expo/spawn-async/src/spawnAsync.ts:65:13)
      at Object.onceWrapper (events.js:520:26)
      at ChildProcess.emit (events.js:400:28)
      at ChildProcess.emit (domain.js:475:12)
      at maybeClose (internal/child_process.js:1058:16)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
      ...
      at spawnAsync (/home/caca/.nvm/versions/node/v14.18.2/lib/node_modules/turtle-cli/node_modules/@expo/spawn-async/src/spawnAsync.ts:26:19)
      at spawnAsyncThrowError (/@expo/xdl@59.1.7/src/detach/ExponentTools.ts:111:19)
      at buildShellAppAsync (/@expo/xdl@59.1.7/src/detach/AndroidShellApp.js:1493:11)
      at Object.createAndroidShellAppAsync (/@expo/xdl@59.1.7/src/detach/AndroidShellApp.js:381:5)
      at runShellAppBuilder (/home/caca/.nvm/versions/node/v14.18.2/lib/node_modules/turtle-cli/src/builders/android.ts:91:5)
      at buildAndroid (/home/caca/.nvm/versions/node/v14.18.2/lib/node_modules/turtle-cli/src/builders/android.ts:23:26)
      at /home/caca/.nvm/versions/node/v14.18.2/lib/node_modules/turtle-cli/src/bin/utils/builder.ts:87:7
      at Command.<anonymous> (/home/caca/.nvm/versions/node/v14.18.2/lib/node_modules/turtle-cli/src/bin/index.ts:23:12)
  platform: "android"
caca@zumit:~/diretorio-para-compilar/za$ 

Any idea? :-/

Thanks :slight_smile:

did you try a build on a previous known working commit?

No, and I don’t know if I can do that :frowning: ! Let me explain: when I switched to SDK43, I had to make a lot of changes to work because there were some outdated components.

Below is my app.json for verification:

{
  "expo": {
    "name": "Zumit",
    "slug": "zumit",
    "description": "Application for Tinnitus Treatment.",
    "privacy": "public",
    "platforms": [
      "ios",
      "android"
    ],
    "version": "0.9.2",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "splash": {
      "image": "./assets/splash.png",
      "backgroundColor": "#edeef0"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "zumit.app.fob.usp.br",
      "buildNumber": "00001",
      "config": {
        "usesNonExemptEncryption": false
      },
      "requireFullScreen": true
    },
    "android": {
      "package": "zumit.app.fob.usp.br"
    }
  }
}

Can you see my build logs on the Expo service?

Thanks again,
Carlos Frederico (Cacá)

Can you see my build logs on the Expo service?

can you share a link to your build page?

also you may want to try moving to eas build - this is easier to debug and has other benefits like smaller app size too

1 Like

See if you can get it :smiley:

Hi!
I think this issue is related to this one: Can't build Android AAB with AppCenter (Expo SDK 43) - githubmemory
Because it gives an error in this file, the settings.gradle.

Anyway, I did the test with a new project (expo init and chose blank… then I configured the Android keys, etc.) and the exact same error occurred.

I tested it on SDK44 beta and the same situation occurred!

I’m using the latest versions of turtle-cli and expo-cli on NodeJS 14 LTS (using NVM to install) on Ubuntu 20.0.4 LTS. Java is OpenJDK 8.

Thanks for listening,
Cacá.

this build looks like it succeeded?

Hi! @notbrent , this build was with error :frowning: !

Anyway, now I solved my problem using eas-cli! Thank you so much for your patience and for letting me know it.

1 Like

@carlnx Hi Can you share me the solution that worked for you…?

I’m having same issue when I try to build in on my MacBook. after upgrading project to expo 43

Hi @maulikrajpara

Are you using the Managed workflow or the.Bare workflow?
How are you building?
What error are you getting?
What dependencies do you have in package.json?

I believe @carlnx just switched to eas build --platform android instead of expo build:android

Hey @wodin ,
I’m using managed workflow.
And I’m trying to build the app via turtle-cli on my MacBook and I’m getting exactly same error which is posted here. Also this started happening after I updated my project to expo 43.
if I send build to expo via expo build:android then they are able to build it fine.
is there anyway I can know which node, expo and turtle is used by expo server…?.
As I’m getting this error if used node v14.18.2 and if use v16.13.0 then I’m getting different one which I have already posted earlier at turtle android setup error - #2 by youngjun.choi .

{
  "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",
    "lint": "tsc --noEmit && eslint --ext .js,.jsx,.ts,.tsx ./"
  },
  "dependencies": {
    "@ptomasroos/react-native-multi-slider": "^2.2.2",
    "@react-native-async-storage/async-storage": "~1.15.0",
    "expo": "^43.0.0",
    "expo-app-loading": "~1.2.1",
    "expo-constants": "~12.1.3",
    "expo-file-system": "~13.0.3",
    "expo-font": "~10.0.3",
    "expo-local-authentication": "~12.0.1",
    "expo-localization": "~11.0.0",
    "expo-notifications": "~0.13.3",
    "expo-status-bar": "~1.1.0",
    "libphonenumber-js": "1.9.19",
    "lodash": "^4.17.21",
    "mobx": "^6.2.0",
    "mobx-react-lite": "^3.2.0",
    "moment": "^2.29.1",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-native": "0.64.2",
    "react-native-calendar-picker": "^7.1.1",
    "react-native-canvas": "^0.1.37",
    "react-native-paper": "^4.7.2",
    "react-native-svg": "12.1.1",
    "react-native-waveview": "^1.1.0",
    "react-native-web": "0.17.1",
    "react-native-webview": "11.13.0",
    "rn-pdf-reader-js": "^4.1.1"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/plugin-proposal-decorators": "^7.13.15",
    "@types/lodash": "^4.14.168",
    "@types/react": "~17.0.21",
    "@types/react-dom": "~17.0.9",
    "@types/react-native": "~0.64.12",
    "@types/react-native-calendar-picker": "^7.0.1",
    "@typescript-eslint/eslint-plugin": "^4.21.0",
    "eslint": "^7.24.0",
    "eslint-config-airbnb-typescript": "^12.3.1",
    "eslint-config-prettier": "^8.1.0",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-react": "^7.23.2",
    "prettier": "^2.2.1",
    "typescript": "~4.3.5"
  },
  "private": true
}

Not sure about the errors, but you might try building with:

eas build --platform android --profile preview --local

(Or other profile/platform)

2 Likes

Hi people (@wodin and @maulikrajpara)!

Yes, I switched from turtle to eas. But there are some details here that made me change: the possibility for eas to compile locally. I cannot wait for the EAS service (which is excellent, of course) all the time.

That said, on processor M1 it is necessary to run on Intel architecture itself, so before running the eas command, first do arch -x86_64 /bin/zsh and then run the eas command.

Thanks to everyone involved :slight_smile:

Is this for building for iOS? I have not had to do that to build Android APKs/AABs. I haven’t yet tried building an iOS app locally.

For iOS yes.

For Android, maybe. I haven’t tested for Android because I do not like Java in my macOS, so I have built a virtual machine with Ubuntu Server 20.4.3 LTS and compile for Android inside it.

Interesting. Thanks.

No, this is definitely not needed for Android.

As a matter of interest, what virtualisation/hypervisor do you use for the Ubuntu VM?

Now I can compile on Mac M1 without command for Intel Arch… probably some EAS-CLI update, etc. Phew.

I use XCP-NG, but it’s perfectly usable with VirtualBox, QEMU, ProxMox, etc.

1 Like

Ah. I thought you meant you ran the VM on your M1 Mac.