Which way we need to use to make an apk from prebuild expo project.

do we need to use ’ eas build -p android --profile preview’ command to make apk from expo prebuild project or do we need to use ./gradlew assembleRelease command.

Hi @amilaupendra

You can do it either way. It is your choice.

1 Like

Hi @amilaupendra

I am new to development with react-native and expo I have an EPSON printer and I want to practice doing print tests, I have seen a video on youtube where you can get the library to work
react-native-bluetooth-escpos-printer
and I would like to know if you can share the drive with the files you use to analyze them and learn how you did it.
the video is

sorry for my bad english

hello. I have updated the description. you can find the relevant links from comment section. i have pinned it. click here: https://youtu.be/BXbseqogkMQ . Also please comment the app works or not. I will help if you need further assistance. :slightly_smiling_face::slightly_smiling_face:

1 Like

Thank you very much, I’ll try and anything I need I’ll be asking in the comments. good day

1 Like

Hi @amilaupendra, I have managed to do my tests directly on my phone, when trying to compile on emulator it throws a “TypeError DIRECTION of null” error. On the other hand, when generating an APK with EAS BUILD, the library does not allow it because it detects an insecure dependency and does not allow termination,i search the entire project for the endpoint of the dependency and change it to HTTPS but it still returns the following

WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':react-native-bluetooth-escpos-printer'.
> Could not determine the dependencies of null.
Could not resolve all dependencies for configuration ':react-native-bluetooth-escpos-printer:classpath'.
Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'BintrayJCenter(http://jcenter.bintray.com/)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.5.1/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details. 
> 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 2m 32s
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
5 actionable tasks: 5 executed
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

I wanted to know if you were able to generate APK?

Thank you very much for the contribution and help.

Hi. did you manged to work it on development build? i also stried to make apk file using expo. but same error you mentioned came up. i couldn’t make apk with expo. but i made apk following react native apk creating way. follow this Publishing to Google Play Store · React Native

If you managed to build apk with expo eas. please drop a comment here. thanks!

Hi @jcfariasc and @amilaupendra

It seems that react-native-bluetooth-escpos-printer is no longer maintained. It was last updated 5 years ago.

I did find this, which may or may not help:

But even if the above helps you might run into other problems because the software has not been updated in so long.

If there’s some sort of official SDK for those printers, you might have more luck writing an Expo module for it using this: Expo Modules API

yes. the software is no longer maintained. anyhow i manged to work it. also i created the apk file and tested in android version 5,7,11 and 13. app is fully functioning with Bluetooth printing.

1 Like

@amilaupendra hi.

au I have not been able to compile the apk of the app.

I have not yet been able to compile the apk of the app.

With the command “./gradlew assembleRelease” after configuring the file “android/app/build.gradle” with the information of the “android/file-keystore.keystore” generated, it indicates the error:
“Task :react-native-bluetooth-escpos-printer:verifyReleaseResources FAILED
w: Detected multiple Kotlin daemon sessions at build\kotlin\sessions”

and when using “EAS BUILD” I found that the error is because the repository “jcenter.bintray.com” is no longer working and in addition to that the repository “https//repo.spring.io/plugins-release/” has changed the route of answers here they gave the notice

try to remove jcenter from “node_modules\react-native-bluetooth-escpos-printer\android\build.gradle” and add
maven { url “https//maven.aliyun.com/repository/jcenter” }
or add
maven { url “https//jitpack.io/” }
and also change “https//repo.spring.io/plugins-release/”
by
maven {url “https//repo.spring.io/plugins-snapshot/”}

but when compiling it always throws me the error of “https//jcenter.bintray.com” and I used a “grep -rnw jcenter” to eliminate it completely where it appeared and I did it but the “EAS BUILD” still throws me that error I don’t know if something should be changed more so that it no longer uses “https//jcenter.bintray.com” as a repository.

I know the repository is neglected but as I said before I have little experience developing applications with react-native and expo and I want to solve it to gain experience and learn.

Do you know any way to solve the error of the command “./gradlew assembleRelease”
or to change the root of the repository that the module uses so that it no longer points to “https//jcenter.bintray.com”
??

Thank you very much, I really appreciate your help

Go to node modules/react native bluetooth ecspos printer/android/build.gradle and then check and make sure compileSDK version and targetSDk,minSDK,buidtoolSDk versions same to the root/android/build.gradle mentioned versions.

The idea is both files should have same versions. Thats how i made the apk.

Otherwise conatact me through amilaupendra5@gmail.com.

thank you very much, yes! It was due to the difference in versions, I have already been able to generate the APK. I will continue trying with EAS build. If I manage to compile it from there, I will comment here again.

1 Like

@amilaupendra HI…
I have managed to compile in EAS BUILD.
The solution is to completely remove the jcenter in “node_modules\react-native-bluetooth-escpos-printer\android\build.gradle” update the links “https//repo.spring.io/plugins-release/” for "https/ /repo.spring.io/plugins-snapshot/”
and add the repository “gradlePluginPortal()”
once that is done install “patch-package”
and create the patch for the module “react-native-bluetooth-escpos-printer”
Once the patch is generated, you can compile with eas. the problem happened because EAS executes npx install to update the modules and this removes the changes made in the module, when using the patch the changes made are entered again automatically after the install is used.

Thank you very much for the help so far everything is working perfectly

After installing patch. How to create patch for the module?

is Easy, After use “npm install patch-package” in your project
add in your package.json

"scripts": {
   .
   .
    "postinstall": "patch-package",
}

then use
“npx patch-package react-native-bluetooth-escpos-printer”

and a patch folder will be created in the root of the project with en patch that contains the changes made to the module

1 Like

worked. well done

Hi @jcfariasc did your APK worked on android version 6? my app crashes on version 6. do you have any idea?

I suggest you connect the phone to your computer using a USB cable and enable USB debugging. Then run adb logcat -d and save the output to a file. Then search for “FATAL” or other errors related to your app. This will hopefully give you some information about the cause of the crash