402d / react-native-rawbt-api

API for working with thermal printers
MIT License
1 stars 0 forks source link

Using EAS Build throws "Type rawbt.api.BuildConfig is defined multiple times" on the "Run gradlew" section #1

Open ElianRruga0 opened 1 year ago

ElianRruga0 commented 1 year ago

Hello, I am using your library to connect a thermal printer with Bluetooth. Bought the license and everything works fine when running npx expo run:android but I can not build the app. I am using EAS Build from expo (https://docs.expo.dev/build/introduction/) to build an APK of the app but it throws the error I wrote on the title. If possible please let me know what I can do because most of the things I have tried are not working.

Thank you :)

ElianRruga0 commented 1 year ago

This is the log from building from expo dashboard, hopefully helps.

Running 'gradlew :app:bundleRelease' in /home/expo/workingdir/build/android Downloading https://services.gradle.org/distributions/gradle-7.5.1-all.zip 10 %. 20%. 30%. 40%. 50%. 60%. 70% 80%. 90%. 100% Welcome to Gradle 7.5.1! Here are the highlights of this release:

ElianRruga0 commented 1 year ago

Opened the package using android studio and changes the package name from rawbt.api to rawbt.apii, the app and the apk build successfully now but it crashes when running the apk

ElianRruga0 commented 1 year ago

For everyone else who may have the same problem I managed to fix it by:

  1. Clone the tutorial,
  2. Add your custom code,
  3. Rename the package react-native-rawbt-api on your components file, I renamed it by (thanks to https://stackoverflow.com/a/29092698/20458176) :
    • opened the android file react-native-rawbt-api with android studio (mac os)
    • In your Project panel, click on the little gear icon
    • Hover to Tree Appearance, uncheck Compact Middle Packages
    • Click on the react-native-rawbt-api in the tree, open the java folder
    • Right click on the rawbt or api folder , hover on refactor and click on rename
    • If a pop up shows that asks if you want to change it on the entire project click "on the entire project"
    • Set the new name of the folder you right clicked (rawbt or api)
    • You may need to change the package= attribute in the android manifest file in react-native-rawbt-api. So for example if you rename rawbt folder to rawbtt you need to set the package attribute in android manifest from rawbt.api to rawbtt.api.
    • Then go to build and clean project.
  4. Run the eas build command
ElianRruga0 commented 1 year ago

The APK builds but the printer does not work.

AndreaUnige commented 1 year ago

I have the exact same problem. I believe this is related to the the gradle.

In my case the command ./gradlew assembleRelease generates a classe.dex under the folder app/build/intermediates/external_libs_dex/release/mergeExtDexRelease/classes.dex

Manually removing it does not solve because it will be re-generated. I believe the solution (which unfortunately I do not have) lies in the warnings:

Gradle detected a problem with the following location:  ...
 eason: Task ':app:bundleReleaseJsAndAssets' uses this output of task ':react-native-rawbt-api:writeReleaseAarMetadata' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

Hopefully someone can help. Andrea